diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 403f7e1c..256d9ede 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,11 +7,6 @@ on: description: "Version name" required: true type: string - prerelease: - description: "Is prerelease" - required: true - type: boolean - default: true build: description: "Build type" required: true @@ -43,7 +38,6 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.outputs.outputs.version }} - prerelease: ${{ steps.outputs.outputs.prerelease }} steps: - name: Checkout uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 @@ -57,9 +51,7 @@ jobs: if: github.event_name == 'workflow_dispatch' run: |- echo "version=${{ inputs.version }}" - echo "prerelease=${{ inputs.prerelease }}" echo "version=${{ inputs.version }}" >> "$GITHUB_ENV" - echo "prerelease=${{ inputs.prerelease }}" >> "$GITHUB_ENV" - name: Calculate version if: github.event_name != 'workflow_dispatch' run: |- @@ -68,7 +60,6 @@ jobs: id: outputs run: |- echo "version=$version" >> "$GITHUB_OUTPUT" - echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT" build: name: Build binary if: github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Binary' @@ -249,12 +240,12 @@ jobs: JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64 ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - name: Checkout main branch - if: needs.calculate_version.outputs.prerelease == 'false' + if: github.ref == 'refs/heads/main-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/android git checkout main - name: Checkout dev branch - if: needs.calculate_version.outputs.prerelease == 'true' + if: github.ref == 'refs/heads/dev-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/android git checkout dev @@ -323,12 +314,12 @@ jobs: JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64 ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - name: Checkout main branch - if: needs.calculate_version.outputs.prerelease == 'false' + if: github.ref == 'refs/heads/main-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/android git checkout main - name: Checkout dev branch - if: needs.calculate_version.outputs.prerelease == 'true' + if: github.ref == 'refs/heads/dev-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/android git checkout dev @@ -409,12 +400,12 @@ jobs: git tag v${{ needs.calculate_version.outputs.version }} echo "VERSION=${{ needs.calculate_version.outputs.version }}" >> "$GITHUB_ENV" - name: Checkout main branch - if: matrix.if && needs.calculate_version.outputs.prerelease == 'false' + if: matrix.if && github.ref == 'refs/heads/main-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/apple git checkout main - name: Checkout dev branch - if: matrix.if && needs.calculate_version.outputs.prerelease == 'true' + if: matrix.if && github.ref == 'refs/heads/dev-next' && github.event_name != 'workflow_dispatch' run: |- cd clients/apple git checkout dev diff --git a/cmd/internal/build_shared/tag.go b/cmd/internal/build_shared/tag.go index 16a97f3e..15f05090 100644 --- a/cmd/internal/build_shared/tag.go +++ b/cmd/internal/build_shared/tag.go @@ -36,11 +36,3 @@ func ReadTagVersion() (badversion.Version, error) { } return version, nil } - -func IsDevBranch() bool { - branch, err := shell.Exec("git", "branch", "--show-current").ReadOutput() - if err != nil { - return false - } - return branch == "dev-next" -} diff --git a/cmd/internal/read_tag/main.go b/cmd/internal/read_tag/main.go index ae496ec6..2cebaf70 100644 --- a/cmd/internal/read_tag/main.go +++ b/cmd/internal/read_tag/main.go @@ -6,7 +6,6 @@ import ( "github.com/sagernet/sing-box/cmd/internal/build_shared" "github.com/sagernet/sing-box/log" - F "github.com/sagernet/sing/common/format" ) var nightly bool @@ -22,25 +21,14 @@ func main() { if err != nil { log.Fatal(err) } - var ( - versionStr string - isPrerelease bool - ) + var versionStr string if version.PreReleaseIdentifier != "" { - isPrerelease = true versionStr = version.VersionString() + "-nightly" } else { version.Patch++ versionStr = version.VersionString() + "-nightly" } - if build_shared.IsDevBranch() { - isPrerelease = true - } - err = setGitHubOutput("version", versionStr) - if err != nil { - log.Fatal(err) - } - err = setGitHubOutput("prerelease", F.ToString(isPrerelease)) + err = setGitHubEnv("version", versionStr) if err != nil { log.Fatal(err) } @@ -55,7 +43,7 @@ func main() { } } -func setGitHubOutput(name string, value string) error { +func setGitHubEnv(name string, value string) error { outputFile, err := os.OpenFile(os.Getenv("GITHUB_ENV"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644) if err != nil { return err