version-embed.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Package tailscaleroot embeds VERSION.txt into the binary.
  4. package tailscaleroot
  5. import (
  6. _ "embed"
  7. "runtime/debug"
  8. )
  9. // VersionDotTxt is the contents of VERSION.txt. Despite the tempting filename,
  10. // this does not necessarily contain the accurate version number of the build, which
  11. // depends on the branch type and how it was built. To get version information, use
  12. // the version package instead.
  13. //
  14. //go:embed VERSION.txt
  15. var VersionDotTxt string
  16. //go:embed ALPINE.txt
  17. var AlpineDockerTag string
  18. // GoToolchainRev is the git hash from github.com/tailscale/go that this release
  19. // should be built using. It may end in a newline.
  20. //
  21. //go:embed go.toolchain.rev
  22. var GoToolchainRev string
  23. func tailscaleToolchainRev() (gitHash string, ok bool) {
  24. bi, ok := debug.ReadBuildInfo()
  25. if !ok {
  26. return "", false
  27. }
  28. for _, s := range bi.Settings {
  29. if s.Key == "tailscale.toolchain.rev" {
  30. return s.Value, true
  31. }
  32. }
  33. return "", false
  34. }