version-embed.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. //lint:ignore U1000 used by tests + assert_ts_toolchain_match.go w/ right build tags
  24. func tailscaleToolchainRev() (gitHash string, ok bool) {
  25. bi, ok := debug.ReadBuildInfo()
  26. if !ok {
  27. return "", false
  28. }
  29. for _, s := range bi.Settings {
  30. if s.Key == "tailscale.toolchain.rev" {
  31. return s.Value, true
  32. }
  33. }
  34. return "", false
  35. }