mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-12-26 12:05:39 +08:00
release: Fix check prerelease
This commit is contained in:
parent
dd9de694f8
commit
483d9fa503
21
.github/workflows/build.yml
vendored
21
.github/workflows/build.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user