version-embed.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) Tailscale Inc & contributors
  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. // GoToolchainNextRev is like GoToolchainRev, but when using the
  24. // "go.toolchain.next.rev" when TS_GO_NEXT=1 is set in the environment.
  25. //
  26. //go:embed go.toolchain.next.rev
  27. var GoToolchainNextRev string
  28. //lint:ignore U1000 used by tests + assert_ts_toolchain_match.go w/ right build tags
  29. func tailscaleToolchainRev() (gitHash string, ok bool) {
  30. bi, ok := debug.ReadBuildInfo()
  31. if !ok {
  32. return "", false
  33. }
  34. for _, s := range bi.Settings {
  35. if s.Key == "tailscale.toolchain.rev" {
  36. return s.Value, true
  37. }
  38. }
  39. return "", false
  40. }