version/mkversion: allow version override with $TS_VERSION_OVERRIDE (#10799)

This is useful to build local binaries with custom versions to test
version-specific logic (like updates).

Updates https://github.com/tailscale/corp/issues/16703

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
Andrew Lytvynov 2024-01-10 09:03:11 -08:00 committed by GitHub
parent 4ec6a78551
commit 86e476c8d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -199,6 +199,13 @@ func tailscaleModuleRef(modBs []byte) (string, error) {
}
func mkOutput(v verInfo) (VersionInfo, error) {
if override := os.Getenv("TS_VERSION_OVERRIDE"); override != "" {
var err error
v.major, v.minor, v.patch, err = parseVersion(override)
if err != nil {
return VersionInfo{}, fmt.Errorf("failed to parse TS_VERSION_OVERRIDE: %w", err)
}
}
var changeSuffix string
if v.minor%2 == 1 {
// Odd minor numbers are unstable builds.