-
Notifications
You must be signed in to change notification settings - Fork 41
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
Allow setting Go version from go.mod file #46
Comments
@bewuethr Exposing a |
Having done this for another GitHub Action, I thought I'd share the solution we ended up with: inputs:
go-version:
description: The version of go to use.
required: false
go-version-file:
description: Path to the go.mod or go.work file to determine version of go to use
required: false
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
# The default go version is managed here because actions/setup-go favors go-version over go-version-file,
# requiring us to only pass it if no other inputs are provided.
#
# Otherwise, we pass along the values given, letting the user catch the warning notice in the logs
# and picking either go-version or go-version-file.
go-version: ${{(inputs.go-version-file == '' && inputs.go-version == '') && '1.20' || inputs.go-version}}
go-version-file: ${{inputs.go-version-file}} In keeping with |
Couldn't you use inputs:
go-version:
description: The version of go to use.
required: false
default: '1.20'
go-version-file:
description: Path to the go.mod or go.work file to determine version of go to use
required: false
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
go-version-file: ${{ inputs.go-version-file }} |
So the problem is that |
created #47 for this |
setup-go supports setting the Go version from the go.mod file; for Go 1.20 and older, it'll use the latest cached patch version on the same minor version, and for Go 1.21+, it'll use the exact version from
go.mod
, which now also includes the patch version.Would it be possible to expose the
go-version-file
input in gh-extension-precompile as well? I previously extracted the Go version in a separate run step withgo mod edit -json | jq -r '.Go'
, but that breaks ifgo.mod
uses 1.21.0 or later, since the default Go on Actions runners, 1.20.8, considers thego.mod
incorrectly formatted. I now use awk, which is less robust, but it would be nice to just leverage the existing setup-go functionality.Happy to create a PR for this if there's interest, potentially including the
check-latest
flag from setup-go as well.The text was updated successfully, but these errors were encountered: