mkversion

package
v1.105.0-pre Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: BSD-3-Clause Imports: 12 Imported by: 6

Documentation

Overview

Package mkversion gets version info from git and provides a bunch of differently formatted version strings that get used elsewhere in the build system to embed version numbers into binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VersionInfo

type VersionInfo struct {
	// Major is the major version number portion of Short.
	Major int
	// Minor is the minor version number portion of Short.
	Minor int
	// Patch is the patch version number portion of Short.
	Patch int
	// Short is the short version string. See the documentation of version.Short
	// for possible values.
	Short string
	// Long is the long version string. See the documentation for version.Long
	// for possible values.
	Long string
	// GitHash is the git hash of the tailscale.com Go module.
	GitHash string
	// OtherHash is the git hash of a supplemental git repository, if any. For
	// example, the commit of the tailscale-android repository.
	OtherHash string
	// Xcode is the version string that gets embedded into Xcode builds for the
	// Tailscale iOS app and macOS standalone (aka "macsys") app.
	//
	// It is the same as Short, but with 100 added to the major version number.
	// This is because Apple requires monotonically increasing version numbers,
	// and very early builds of Tailscale used a single incrementing integer,
	// which the Apple interprets as the major version number. When we switched
	// to the current scheme, we started the major version number at 100 (v0,
	// plus 100) to make the transition.
	Xcode string
	// XcodeMacOS is the version string that gets embedded into Xcode builds for
	// the Tailscale macOS app store app.
	//
	// This used to be the same as Xcode, but at some point Xcode reverted to
	// auto-incrementing build numbers instead of using the version we embedded.
	// As a result, we had to alter the version scheme again, and switched to
	// GitHash's commit date, in the format "YYYY.DDD.HHMMSS"
	XcodeMacOS string
	// Winres is the version string that gets embedded into Windows exe
	// metadata. It is of the form "x,y,z,0".
	Winres string
	// Synology is a map of Synology DSM version to the
	// Tailscale numeric version that gets embedded in Synology spk
	// files.
	Synology map[int]int64
	// GitDate is the unix timestamp of GitHash's commit date.
	GitDate string
	// OtherDate is the unix timestamp of OtherHash's commit date, if any.
	OtherDate string
	// Track is the release track of this build: "stable" if the minor version
	// number is even, "unstable" if it's odd.
	Track string
	// MSIProductCodes is a map of Windows CPU architecture names to UUIDv5
	// hashes that uniquely identify the version of the build. These are used in
	// the MSI installer logic to uniquely identify particular builds.
	MSIProductCodes map[string]string
}

VersionInfo is version information extracted from a git checkout.

func Info

func Info() VersionInfo

Info constructs a VersionInfo from the current working directory and returns it, or terminates the process via log.Fatal.

func InfoFrom

func InfoFrom(dir string) (VersionInfo, error)

InfoFrom constructs a VersionInfo from dir and returns it, or an error.

By default the version is derived from the git history of the checkout containing dir, which needs the full history back to the most recent VERSION.txt change. If dir is a tailscale.com tree without a .git directory, only VERSION.txt is consulted and the patch number is set to a visible sentinel. In this mode, TS_VERSION_OVERRIDE, if set to "major.minor.patch", replaces the version number read from VERSION.txt.

If TS_VERSION_LONG is non-empty, the version instead comes entirely from the environment: dir is ignored, no git commands are run, and neither VERSION.txt nor go.mod is read. This is for building from a shallow clone or a tree with no .git directory when the caller already knows the version. The variables are:

  • TS_VERSION_LONG (required): the complete version in version.Long format, e.g. "1.99.5-t8895cec85" or "1.98.2-3-t8895cec85-g15581c318".
  • TS_VERSION_GIT_HASH (required): the full 40-hex-digit hash of the tailscale.com commit. Its first 9 digits must match the "-t" part of TS_VERSION_LONG.
  • TS_VERSION_EXTRA_GIT_HASH: the full hash of the supplemental repository's commit. Required if and only if TS_VERSION_LONG has a "-g" part, which its first 9 digits must match.
  • TS_VERSION_GIT_DATE (optional): the tailscale.com commit's date in Unix seconds, for VersionInfo.GitDate.
  • TS_VERSION_EXTRA_GIT_DATE (optional): the supplemental commit's date in Unix seconds, for VersionInfo.OtherDate and hence VersionInfo.XcodeMacOS.

The remaining fields are derived from those by the same code as the git path, and the resulting VersionInfo.Long must reproduce TS_VERSION_LONG exactly or InfoFrom returns an error. TS_VERSION_OVERRIDE may not be set together with TS_VERSION_LONG.

func (VersionInfo) String

func (v VersionInfo) String() string

String returns v's information as shell variable assignments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL