mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2026-08-28 04:54:58 -04:00
Add go-version-file-behavior input
By default an exact version read from go-version-file is used as written, so a "go 1.22.0" directive pins CI to the oldest patch release of the minor even when newer patches with security fixes exist. Dependencies can force such an exact version into go.mod. Setting go-version-file-behavior to latest-patch widens an exact major.minor.patch version into a ~X.Y.Z range, resolving the newest available patch release of the same minor while keeping the file's version as a floor. Bare minors and prereleases pass through unchanged. The default behavior (exact) is unchanged.
This commit is contained in:
parent
5064d95ba1
commit
71b6f8926f
7 changed files with 168 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
- [Specifying a go version](advanced-usage.md#specifying-a-go-version)
|
||||
- [Matrix testing](advanced-usage.md#matrix-testing)
|
||||
- [Using the go-version-file input](advanced-usage.md#using-the-go-version-file-input)
|
||||
- [Using the latest patch release](advanced-usage.md#using-the-latest-patch-release)
|
||||
- [Check latest version](advanced-usage.md#check-latest-version)
|
||||
- [Caching](advanced-usage.md#caching)
|
||||
- [Caching in monorepos](advanced-usage.md#caching-in-monorepos)
|
||||
|
|
@ -212,6 +213,24 @@ steps:
|
|||
- run: go version
|
||||
```
|
||||
|
||||
### Using the latest patch release
|
||||
|
||||
By default, an exact version read from the version file is used as written: a `go 1.22.0` directive installs exactly Go 1.22.0, even if newer 1.22.x patch releases with security fixes are available.
|
||||
|
||||
Set `go-version-file-behavior` to `latest-patch` to instead resolve the newest available patch release of the same minor version that is at least the version in the file (e.g., `go 1.22.0` resolves to the newest 1.22.x):
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
go-version-file-behavior: 'latest-patch'
|
||||
- run: go version
|
||||
```
|
||||
|
||||
Versions without a patch component (e.g., `go 1.22`) already resolve to the latest available patch release, and prerelease versions (e.g., `go1.22rc1` from a `toolchain` directive) are always used as written, so `latest-patch` leaves both unchanged. As with any version range, the resolved patch release depends on what is available in the runner's tool cache and the versions manifest.
|
||||
|
||||
## Check latest version
|
||||
|
||||
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability
|
||||
|
|
|
|||
Loading…
Reference in a new issue