-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
base: main
Are you sure you want to change the base?
Use Go version from go.mod in CI workflows #5155
Conversation
Signed-off-by: Mark S. Lewis <[email protected]>
- name: Check Go module version | ||
run: | | ||
[[ "$(go list -m -f '{{.Version}}' go)" == "${GO_VER}" ]] |
There was a problem hiding this comment.
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.
- 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}" | ||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks good.
@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. |
There was a problem hiding this 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.
- 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}" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks good.
No description provided.