From 5858bb7193ef21e6ad4dffdcc736ea931b951926 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 16 Oct 2026 14:23:10 +0200 Subject: [PATCH] Take the Go version for releases from go.mod release.yml installs a fixed Go version for building a release, and it must match the release.yml on master. A patch release from a branch off an older tag is therefore built with master's Go version, not with the one that branch uses. For example, once master moves to Go 1.27, a v0.66.3 built from a branch off v0.66.2 would no longer run on macOS 12, although v0.66.2 does. Read the version from the go line of the checked-out go.mod instead, and add ".x" so that setup-go installs the latest patch release. setup-go's go-version-file input can't do this; for "go 1.26.0" it installs exactly 1.26.0. Read the version before pushing the tag, so that a go.mod without a go line stops the release early. This also removes release.yml from the files to edit when updating Go. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/release.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fd637aec..102000f0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -161,6 +161,24 @@ jobs: echo "New tag: $new_tag" echo "new_tag=$new_tag" >> $GITHUB_ENV + - name: Get Go version + run: | + # Take the Go version from the go.mod of the code being released, so + # that a patch release from a branch off an older tag is built with + # that branch's Go version, not with master's. + # + # Turn "go 1.26.0" into "1.26.x" so that setup-go installs the latest + # patch release. With go-version-file, it would install exactly 1.26.0. + go_version=$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1.x/p' go.mod) + + if ! [[ $go_version =~ ^[0-9]+\.[0-9]+\.x$ ]]; then + echo "Error: Could not read the go version from go.mod" + exit 1 + fi + + echo "Go version: $go_version" + echo "go_version=$go_version" >> $GITHUB_ENV + - name: Create and Push Tag env: NEW_TAG: ${{ env.new_tag }} @@ -174,7 +192,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: ${{ env.go_version }} - name: Run goreleaser uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3