Skip to content

Commit bf15628

Browse files
committed
[tailscale] runtime/debug: embed Tailscale toolchain git rev
This is another take on #49 (which we stopped using?), and less intrusive, and also always on. This puts puts the the Tailscale Go toolchain's git rev in the binary, accessible as a new "tailscale.toolchain.rev" runtime/debug.BuildInfo Setting. Caller code will have to access it guarded by the "tailscale_go" build tag. Updates #49 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 4771bca commit bf15628

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4242
with:
4343
ref: ${{ inputs.ref || github.ref }}
44+
- name: set runtime/debug.tailscaleGitRev
45+
run: sed -i "s/TAILSCALE_GIT_REV_TO_BE_REPLACED_AT_BUILD_TIME/${{ github.sha }}/" src/runtime/debug/mod.go
4446
- name: build
4547
run: cd src && ./make.bash
4648
env:

src/runtime/debug/mod.go

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"strings"
1212
)
1313

14+
const tailscaleGitRev = `TAILSCALE_GIT_REV_TO_BE_REPLACED_AT_BUILD_TIME`
15+
1416
// exported from runtime.
1517
func modinfo() string
1618

@@ -34,6 +36,13 @@ func ReadBuildInfo() (info *BuildInfo, ok bool) {
3436
// awkwardness from the user.
3537
bi.GoVersion = runtime.Version()
3638

39+
if len(tailscaleGitRev) > 0 && tailscaleGitRev[0] != 'T' {
40+
bi.Settings = append(bi.Settings, BuildSetting{
41+
Key: "tailscale.toolchain.rev",
42+
Value: tailscaleGitRev,
43+
})
44+
}
45+
3746
return bi, true
3847
}
3948

0 commit comments

Comments
 (0)