mirror of
https://github.com/actions/setup-go.git
synced 2025-12-12 16:31:15 +00:00
Document how to use Go version file as a fallback for Go matrix builds
This strategy is useful for projects that want to specify a default Go version for their CI builds, while still allowing overrides through the Go matrix to target the latest Go versions.
This commit is contained in:
parent
4dc6199c7b
commit
f354f7a36d
1 changed files with 21 additions and 0 deletions
21
README.md
21
README.md
|
|
@ -353,6 +353,7 @@ The `go-version` input supports the following syntax:
|
|||
| Wildcard (minor) | `1.*` | Latest available version in the major version |
|
||||
| Pre-release | `1.24.0-rc.1` | Beta/RC versions for testing upcoming releases |
|
||||
| Aliases | `stable`, `oldstable` | Latest stable or previous stable release |
|
||||
| Empty string | `''` | No version specified; relies on `go-version-file` when provided |
|
||||
|
||||
For more information about semantic versioning, see the [semver documentation](https://semver.org/).
|
||||
|
||||
|
|
@ -383,6 +384,26 @@ For more information about semantic versioning, see the [semver documentation](h
|
|||
architecture: 'x64'
|
||||
```
|
||||
|
||||
### Matrix Testing with go-version-file fallback
|
||||
|
||||
You can combine go-version with go-version-file in a matrix strategy to test across latest supported Go versions, and the minimal version specified in `go.mod` of your project.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ['stable', 'oldstable', ''] # empty string to fall back on go-version-file
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
go-version-file: "go.mod" # this one is only used when go-version is not specified.
|
||||
- run: go test ./...
|
||||
```
|
||||
|
||||
## Using setup-go on GHES
|
||||
|
||||
setup-go comes pre-installed on GHES when Actions is enabled. For dynamic Go version downloads, the action fetches distributions from the [go-versions repository](https://github.com/actions/go-versions/) on github.com (external to your appliance).
|
||||
|
|
|
|||
Loading…
Reference in a new issue