Skip to content

Commit

Permalink
release: Test workflow build
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 7, 2024
1 parent 8d83c6b commit 4935068
Show file tree
Hide file tree
Showing 10 changed files with 645 additions and 240 deletions.
556 changes: 556 additions & 0 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

219 changes: 0 additions & 219 deletions .github/workflows/debug.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
mkdir -p $HOME/.gnupg
cat > $HOME/.gnupg/sagernet.key <<EOF
${{ secrets.GPG_KEY }}
echo "HOME=$HOME" >> "$GITHUB_ENV"
EOF
echo "HOME=$HOME" >> "$GITHUB_ENV"
- name: Publish release
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,6 @@ release:
ids:
- archive
- package
skip_upload: true
skip_upload: true
partial:
by: target
20 changes: 19 additions & 1 deletion cmd/internal/build_libbox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
_ "github.com/sagernet/gomobile"
"github.com/sagernet/sing-box/cmd/internal/build_shared"
"github.com/sagernet/sing-box/log"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/rw"
"github.com/sagernet/sing/common/shell"
)

var (
Expand Down Expand Up @@ -62,6 +64,22 @@ func init() {
func buildAndroid() {
build_shared.FindSDK()

var javaPath string
javaHome := os.Getenv("JAVA_HOME")
if javaHome == "" {
javaPath = "java"
} else {
javaPath = filepath.Join(javaHome, "bin", "java")
}

javaVersion, err := shell.Exec(javaPath, "--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")
}

args := []string{
"bind",
"-v",
Expand All @@ -86,7 +104,7 @@ func buildAndroid() {
command := exec.Command(build_shared.GoBinPath+"/gomobile", args...)
command.Stdout = os.Stdout
command.Stderr = os.Stderr
err := command.Run()
err = command.Run()
if err != nil {
log.Fatal(err)
}
Expand Down
14 changes: 4 additions & 10 deletions cmd/internal/build_shared/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ 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 (
Expand Down Expand Up @@ -42,14 +40,6 @@ 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)
Expand All @@ -64,6 +54,10 @@ func findNDK() bool {
androidNDKPath = fixedPath
return true
}
if ndkHomeEnv := os.Getenv("ANDROID_NDK_HOME"); rw.IsFile(filepath.Join(ndkHomeEnv, versionFile)) {
androidNDKPath = ndkHomeEnv
return true
}
ndkVersions, err := os.ReadDir(filepath.Join(androidSDKPath, "ndk"))
if err != nil {
return false
Expand Down
11 changes: 11 additions & 0 deletions cmd/internal/build_shared/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ func ReadTag() (string, error) {
return version.String() + "-" + shortCommit, nil
}

func ReadTagNightly() (string, error) {
currentTagRev := common.Must1(shell.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput())
version := badversion.Parse(currentTagRev[1:])
if version.PreReleaseIdentifier != "" {
return version.VersionString() + "-nightly", nil
} else {
version.Patch++
return version.VersionString() + "-nightly", nil
}
}

func ReadTagVersion() (badversion.Version, error) {
currentTag := common.Must1(shell.Exec("git", "describe", "--tags").ReadOutput())
currentTagRev := common.Must1(shell.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput())
Expand Down
20 changes: 18 additions & 2 deletions cmd/internal/read_tag/main.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
package main

import (
"flag"
"os"

"github.com/sagernet/sing-box/cmd/internal/build_shared"
"github.com/sagernet/sing-box/log"
)

var nightly bool

func init() {
flag.BoolVar(&nightly, "nightly", false, "Print nightly tag")
}

func main() {
currentTag, err := build_shared.ReadTag()
flag.Parse()
var (
tag string
err error
)
if nightly {
tag, err = build_shared.ReadTagNightly()
} else {
tag, err = build_shared.ReadTag()
}
if err != nil {
log.Error(err)
_, err = os.Stdout.WriteString("unknown\n")
} else {
_, err = os.Stdout.WriteString(currentTag + "\n")
_, err = os.Stdout.WriteString(tag + "\n")
}
if err != nil {
log.Error(err)
Expand Down
Loading

0 comments on commit 4935068

Please sign in to comment.