Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Go version from go.mod in CI workflows #5155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bestbeforetoday
Copy link
Member

No description provided.

Comment on lines -34 to -36
- name: Check Go module version
run: |
[[ "$(go list -m -f '{{.Version}}' go)" == "${GO_VER}" ]]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that the CI and go.mod versions match is no longer required since the CI uses the go.mod version.

Comment on lines +98 to +101
- name: Set GO_VER environment variable from go.mod
run: |
awk '/^go[ /t]/ { gsub(/^go[ \t]+|[ \t]+^/, ""); print "GO_VER="$0; exit }' < go.mod >> "${GITHUB_ENV}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative approach would be to set up go using actions/setup-go and the go.mod file, then read the go-version output from that action.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach looks good.

@bestbeforetoday
Copy link
Member Author

@denyeart Using the Go version from go.mod was easier than I thought since actions/setup-go provides a go-version-file input option.

This change could use some additional eyes to see if I missed anything. And perhaps a trial of the release workflow since that uses some scripting magic.

Copy link
Contributor

@denyeart denyeart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see the go-version-file option!

This looks good, I just did a test of the release from my personal fork and GO_VER does indeed get picked up correctly.

Comment on lines +98 to +101
- name: Set GO_VER environment variable from go.mod
run: |
awk '/^go[ /t]/ { gsub(/^go[ \t]+|[ \t]+^/, ""); print "GO_VER="$0; exit }' < go.mod >> "${GITHUB_ENV}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach looks good.

@bestbeforetoday bestbeforetoday marked this pull request as ready for review February 25, 2025 21:04
@bestbeforetoday bestbeforetoday requested a review from a team as a code owner February 25, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants