Skip to content

Commit 80d1aeb

Browse files
committed
platform: Unify client versions
1 parent 5583e01 commit 80d1aeb

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

.github/update_clients.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
PROJECTS=$(dirname "$0")/../..
4+
5+
function updateClient() {
6+
pushd clients/$1
7+
git fetch
8+
git reset FETCH_HEAD --hard
9+
popd
10+
git add clients/$1
11+
}
12+
13+
updateClient "apple"
14+
updateClient "android"

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "clients/apple"]
2+
path = clients/apple
3+
url = https://github.com/SagerNet/sing-box-for-apple.git
4+
[submodule "clients/android"]
5+
path = clients/android
6+
url = https://github.com/SagerNet/sing-box-for-android.git

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ update_android_version:
7878
go run ./cmd/internal/update_android_version
7979

8080
build_android:
81-
cd ../sing-box-for-android && ./gradlew :app:assemblePlayRelease && ./gradlew --stop
81+
cd ../sing-box-for-android && ./gradlew :app:assemblePlayRelease && ./gradlew :app:assembleOtherRelease && ./gradlew --stop
8282

8383
upload_android:
8484
mkdir -p dist/release_android
8585
cp ../sing-box-for-android/app/build/outputs/apk/play/release/*.apk dist/release_android
86+
cp ../sing-box-for-android/app/build/outputs/apk/other/release/*-universal.apk dist/release_android
8687
ghr --replace --draft --prerelease -p 3 "v${VERSION}" dist/release_android
8788
rm -rf dist/release_android
8889

clients/android

Submodule android added at 3b9d24a

clients/apple

Submodule apple added at 60f9698

cmd/internal/build_shared/sdk.go

+10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import (
1111

1212
"github.com/sagernet/sing-box/log"
1313
"github.com/sagernet/sing/common"
14+
E "github.com/sagernet/sing/common/exceptions"
1415
"github.com/sagernet/sing/common/rw"
16+
"github.com/sagernet/sing/common/shell"
1517
)
1618

1719
var (
@@ -40,6 +42,14 @@ func FindSDK() {
4042
log.Fatal("android NDK not found")
4143
}
4244

45+
javaVersion, err := shell.Exec("java", "--version").ReadOutput()
46+
if err != nil {
47+
log.Fatal(E.Cause(err, "check java version"))
48+
}
49+
if !strings.Contains(javaVersion, "openjdk 17") {
50+
log.Fatal("java version should be openjdk 17")
51+
}
52+
4353
os.Setenv("ANDROID_HOME", androidSDKPath)
4454
os.Setenv("ANDROID_SDK_HOME", androidSDKPath)
4555
os.Setenv("ANDROID_NDK_HOME", androidNDKPath)

cmd/internal/update_android_version/main.go

+23-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"os"
55
"path/filepath"
6+
"runtime"
67
"strconv"
78
"strings"
89

@@ -18,34 +19,46 @@ func main() {
1819
log.Fatal(err)
1920
}
2021
common.Must(os.Chdir(androidPath))
21-
localProps := common.Must1(os.ReadFile("local.properties"))
22+
localProps := common.Must1(os.ReadFile("version.properties"))
2223
var propsList [][]string
2324
for _, propLine := range strings.Split(string(localProps), "\n") {
2425
propsList = append(propsList, strings.Split(propLine, "="))
2526
}
27+
var (
28+
versionUpdated bool
29+
goVersionUpdated bool
30+
)
2631
for _, propPair := range propsList {
27-
if propPair[0] == "VERSION_NAME" {
28-
if propPair[1] == newVersion.String() {
29-
log.Info("version not changed")
30-
return
32+
switch propPair[0] {
33+
case "VERSION_NAME":
34+
if propPair[1] != newVersion.String() {
35+
versionUpdated = true
36+
propPair[1] = newVersion.String()
37+
log.Info("updated version to ", newVersion.String())
38+
}
39+
case "GO_VERSION":
40+
if propPair[1] != runtime.Version() {
41+
goVersionUpdated = true
42+
propPair[1] = runtime.Version()
43+
log.Info("updated Go version to ", runtime.Version())
3144
}
32-
propPair[1] = newVersion.String()
33-
log.Info("updated version to ", newVersion.String())
3445
}
3546
}
47+
if !(versionUpdated || goVersionUpdated) {
48+
log.Info("version not changed")
49+
return
50+
}
3651
for _, propPair := range propsList {
3752
switch propPair[0] {
3853
case "VERSION_CODE":
3954
versionCode := common.Must1(strconv.ParseInt(propPair[1], 10, 64))
4055
propPair[1] = strconv.Itoa(int(versionCode + 1))
4156
log.Info("updated version code to ", propPair[1])
42-
case "RELEASE_NOTES":
43-
propPair[1] = "sing-box " + newVersion.String()
4457
}
4558
}
4659
var newProps []string
4760
for _, propPair := range propsList {
4861
newProps = append(newProps, strings.Join(propPair, "="))
4962
}
50-
common.Must(os.WriteFile("local.properties", []byte(strings.Join(newProps, "\n")), 0o644))
63+
common.Must(os.WriteFile("version.properties", []byte(strings.Join(newProps, "\n")), 0o644))
5164
}

0 commit comments

Comments
 (0)