Skip to content

Commit

Permalink
Only update the go version in go.mod update action.
Browse files Browse the repository at this point in the history
- running go mod tidy removes the toolchain version when it is identical to the go version (which it will always be).
- also fix a bug in the regex which was inadvertently bumping packages as well as the go version itself.
  • Loading branch information
robdimsdale committed Jul 15, 2024
1 parent e55cef0 commit 14c53b3
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions actions/update-go-mod-version/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ function main() {
fi

echo "Setting go version to: '${go_version}'"
sed -i "s/go .*/go ${go_version}/g" go.mod

echo "setting toolchain to: '${go_version}'"
if grep -qE 'toolchain go(.*)' < go.mod; then
sed -i "s/toolchain go.*/toolchain go${go_version}/g" go.mod
else
# Write the toolchain directive two lines below the go version
sed -i "/go ${go_version}/r"<(printf "\ntoolchain go%s\n" "${go_version}") go.mod
fi
sed -i "s/^go .*/go ${go_version}/g" go.mod
}

main "${@:-}"
Expand Down

0 comments on commit 14c53b3

Please sign in to comment.