Skip to content

Commit

Permalink
postrelease: prefer the Go version in go.mod's toolchain directive
Browse files Browse the repository at this point in the history
The go tool will automatically remove the toolchain directive if it
happens to be the same as the go directive. This means in order to
reliably get the version of Go that is used to build, we need to first
check the toolchain directive, and fall back to the go directive only
if the toolchain is not specified.

Additionally, the toolchain directive is prefixed with "go", so we
need to strip that to get consistent output.
  • Loading branch information
zmb3 authored and github-actions committed Dec 6, 2024
1 parent ce68573 commit fa74768
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/post-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "GitHub"
# get Go version from go.mod
GO_VERSION=$(go mod edit -json | jq -r .Go)
# get Go version from go.mod (preferring the toolchain directive if it's present)
GO_VERSION=$(go mod edit -json | jq -r 'if has("Toolchain") then .Toolchain | sub("go"; "") else .Go end')
# update versions in docs/config.json
# for docker images replace version number after <docker image name>:
Expand Down

0 comments on commit fa74768

Please sign in to comment.