diff --git a/version/version.go b/version/version.go index 962d073010..a878fdaefd 100644 --- a/version/version.go +++ b/version/version.go @@ -1,6 +1,7 @@ package version import ( + "fmt" "strings" ) @@ -15,6 +16,9 @@ var ( // for tests to work. Version = "1.12.0" + // https://semver.org/#spec-item-10 + VersionMetadata = "" + // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. @@ -26,13 +30,14 @@ var ( func GetHumanVersion() string { version := Version release := VersionPrerelease + metadata := VersionMetadata if release != "" { - suffix := "-" + release - if !strings.HasSuffix(version, suffix) { - // if we tagged a prerelease version then the release is in the version already - version += suffix - } + version += fmt.Sprintf("-%s", release) + } + + if metadata != "" { + version += fmt.Sprintf("+%s", metadata) } // Strip off any single quotes added by the git information.