diff --git a/.github/update_clients.sh b/.github/update_clients.sh new file mode 100755 index 00000000..c77afbb4 --- /dev/null +++ b/.github/update_clients.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +PROJECTS=$(dirname "$0")/../.. + +function updateClient() { + pushd clients/$1 + git fetch + git reset FETCH_HEAD --hard + popd + git add clients/$1 +} + +updateClient "apple" +updateClient "android" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..45ffb563 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "clients/apple"] + path = clients/apple + url = https://github.com/SagerNet/sing-box-for-apple.git +[submodule "clients/android"] + path = clients/android + url = https://github.com/SagerNet/sing-box-for-android.git diff --git a/Makefile b/Makefile index 322f8f69..4a18aa16 100644 --- a/Makefile +++ b/Makefile @@ -78,11 +78,12 @@ update_android_version: go run ./cmd/internal/update_android_version build_android: - cd ../sing-box-for-android && ./gradlew :app:assemblePlayRelease && ./gradlew --stop + cd ../sing-box-for-android && ./gradlew :app:assemblePlayRelease && ./gradlew :app:assembleOtherRelease && ./gradlew --stop upload_android: mkdir -p dist/release_android cp ../sing-box-for-android/app/build/outputs/apk/play/release/*.apk dist/release_android + cp ../sing-box-for-android/app/build/outputs/apk/other/release/*-universal.apk dist/release_android ghr --replace --draft --prerelease -p 3 "v${VERSION}" dist/release_android rm -rf dist/release_android diff --git a/clients/android b/clients/android new file mode 160000 index 00000000..3b9d24a0 --- /dev/null +++ b/clients/android @@ -0,0 +1 @@ +Subproject commit 3b9d24a0bb757a0b55f5590485934e1012757ba6 diff --git a/clients/apple b/clients/apple new file mode 160000 index 00000000..60f96985 --- /dev/null +++ b/clients/apple @@ -0,0 +1 @@ +Subproject commit 60f96985a39c8af7dd66d57efd08bb0b150fcb6d diff --git a/cmd/internal/build_shared/sdk.go b/cmd/internal/build_shared/sdk.go index 1bcd40bb..0c447ba1 100644 --- a/cmd/internal/build_shared/sdk.go +++ b/cmd/internal/build_shared/sdk.go @@ -11,7 +11,9 @@ import ( "github.com/sagernet/sing-box/log" "github.com/sagernet/sing/common" + E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/rw" + "github.com/sagernet/sing/common/shell" ) var ( @@ -40,6 +42,14 @@ func FindSDK() { log.Fatal("android NDK not found") } + javaVersion, err := shell.Exec("java", "--version").ReadOutput() + if err != nil { + log.Fatal(E.Cause(err, "check java version")) + } + if !strings.Contains(javaVersion, "openjdk 17") { + log.Fatal("java version should be openjdk 17") + } + os.Setenv("ANDROID_HOME", androidSDKPath) os.Setenv("ANDROID_SDK_HOME", androidSDKPath) os.Setenv("ANDROID_NDK_HOME", androidNDKPath) diff --git a/cmd/internal/update_android_version/main.go b/cmd/internal/update_android_version/main.go index ce380b98..040ba5d2 100644 --- a/cmd/internal/update_android_version/main.go +++ b/cmd/internal/update_android_version/main.go @@ -3,6 +3,7 @@ package main import ( "os" "path/filepath" + "runtime" "strconv" "strings" @@ -18,34 +19,46 @@ func main() { log.Fatal(err) } common.Must(os.Chdir(androidPath)) - localProps := common.Must1(os.ReadFile("local.properties")) + localProps := common.Must1(os.ReadFile("version.properties")) var propsList [][]string for _, propLine := range strings.Split(string(localProps), "\n") { propsList = append(propsList, strings.Split(propLine, "=")) } + var ( + versionUpdated bool + goVersionUpdated bool + ) for _, propPair := range propsList { - if propPair[0] == "VERSION_NAME" { - if propPair[1] == newVersion.String() { - log.Info("version not changed") - return + switch propPair[0] { + case "VERSION_NAME": + if propPair[1] != newVersion.String() { + versionUpdated = true + propPair[1] = newVersion.String() + log.Info("updated version to ", newVersion.String()) + } + case "GO_VERSION": + if propPair[1] != runtime.Version() { + goVersionUpdated = true + propPair[1] = runtime.Version() + log.Info("updated Go version to ", runtime.Version()) } - propPair[1] = newVersion.String() - log.Info("updated version to ", newVersion.String()) } } + if !(versionUpdated || goVersionUpdated) { + log.Info("version not changed") + return + } for _, propPair := range propsList { switch propPair[0] { case "VERSION_CODE": versionCode := common.Must1(strconv.ParseInt(propPair[1], 10, 64)) propPair[1] = strconv.Itoa(int(versionCode + 1)) log.Info("updated version code to ", propPair[1]) - case "RELEASE_NOTES": - propPair[1] = "sing-box " + newVersion.String() } } var newProps []string for _, propPair := range propsList { newProps = append(newProps, strings.Join(propPair, "=")) } - common.Must(os.WriteFile("local.properties", []byte(strings.Join(newProps, "\n")), 0o644)) + common.Must(os.WriteFile("version.properties", []byte(strings.Join(newProps, "\n")), 0o644)) }