release: Fix check prerelease

This commit is contained in:
世界 2024-12-12 14:46:03 +08:00
parent dd9de694f8
commit 483d9fa503
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 9 additions and 38 deletions

View file

@ -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"
}

View file

@ -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