mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
fix(nightly): inject correct semver 0.<next-minor>.0-nightly-abc1234 for nightly builds
This commit is contained in:
@@ -38,10 +38,11 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// currentVersion is the version of this binary (CLI or daemon).
|
||||
currentVersion = semver.MustParse(version.String())
|
||||
// zeroVersion is used when no version is specified (treated as 0.0.0).
|
||||
zeroVersion = semver.MustParse("0.0.0")
|
||||
// currentVersion is the version of this binary (CLI or daemon). It's injected via an ldflag at build time.
|
||||
// Fall back to zeroVersion if the injected string isn't valid semver.
|
||||
currentVersion = parseVersionOrZero(version.String())
|
||||
// Pre-parsed minimum versions for comparison.
|
||||
minClientVersion = semver.MustParse(MinClientVersion)
|
||||
minServerVersion = semver.MustParse(MinServerVersion)
|
||||
@@ -55,6 +56,15 @@ var (
|
||||
WarnWriter io.Writer = os.Stderr
|
||||
)
|
||||
|
||||
// parseVersionOrZero parses v as a semver, returning zeroVersion if parsing fails.
|
||||
func parseVersionOrZero(v string) *semver.Version {
|
||||
parsed, err := semver.NewVersion(v)
|
||||
if err != nil {
|
||||
return zeroVersion
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
func extractVersion(md metadata.MD, key string) *semver.Version {
|
||||
if md == nil {
|
||||
return zeroVersion
|
||||
|
||||
Reference in New Issue
Block a user