From 268b11efc99ecb0005614c116941de0b2d80993a Mon Sep 17 00:00:00 2001 From: William Martin Date: Wed, 9 Jul 2025 17:10:08 +0200 Subject: [PATCH] Ensure go directive is always .0 version This is because go mod tidy will always add the final minor version so we might as well handle it in the script ahead of time. --- .github/workflows/scripts/bump-go.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index 812b90417..f0762f3d3 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -40,7 +40,9 @@ echo "Fetching latest stable Go version…" LATEST_JSON=$(curl -fsSL https://go.dev/dl/?mode=json | jq -c '[.[] | select(.stable==true)][0]') FULL_VERSION=$(jq -r '.version' <<< "$LATEST_JSON") # e.g. go1.23.4 TOOLCHAIN_VERSION="${FULL_VERSION#go}" # e.g. 1.23.4 -GO_DIRECTIVE_VERSION=$(cut -d. -f1-2 <<< "$TOOLCHAIN_VERSION") +# `go mod tidy` will always add `.0` if there is no minor version +# so let's just ensure .0 is suffixed to the go directive. +GO_DIRECTIVE_VERSION="$(cut -d. -f1-2 <<< "$TOOLCHAIN_VERSION").0" echo " → go : $GO_DIRECTIVE_VERSION" echo " → toolchain : $TOOLCHAIN_VERSION" @@ -76,9 +78,6 @@ if [[ "$CURRENT_TOOLCHAIN_DIRECTIVE" != "go$TOOLCHAIN_VERSION" ]]; then echo " • toolchain $CURRENT_TOOLCHAIN_DIRECTIVE → go$TOOLCHAIN_VERSION" fi -# ---- Run go mod tidy to ensure .0 minor version is added to go directive ---- -go mod tidy - rm -f "$GO_MOD.bak" git add "$GO_MOD"