@ -94,10 +94,13 @@ the [check-latest input](docs/advanced-usage.md#check-latest-version).
The `go-version` input supports the following syntax:
The `go-version` input supports the following syntax:
- Specific versions: `1.25`, `1.24.11`, `1.24.0-rc.1`, `1.23.0-beta.1`
- Specific versions: `1.25`, `1.24.11`, `1.24.0-rc.1`, `1.23.0-beta.1`
- Native Go versions: `go1.21`, `go1.21.5`, `go1.18beta2`, `go1.21rc2`. `go1.21` resolves to exactly `1.21.0`, unlike `1.21`, which matches patch releases.
- SemVer version range syntax: `^1.25.1`, `~1.24.1`, `>=1.25.0-rc.1`, `<1.25.0`, `>=1.22.0 <1.24.0`
- SemVer version range syntax: `^1.25.1`, `~1.24.1`, `>=1.25.0-rc.1`, `<1.25.0`, `>=1.22.0 <1.24.0`
- Aliases: `stable`, `oldstable`
- Aliases: `stable`, `oldstable`
- Wildcards: `1.25.x`, `1.x`
- Wildcards: `1.25.x`, `1.x`
> **Note:** Native Go version validation and normalization apply only when no custom download base URL is configured. When `go-download-base-url` or `GO_DOWNLOAD_BASE_URL` is set, the `go-version` input is passed through unchanged.
For details on Semantic Versioning, see [the semver package documentation](https://github.com/npm/node-semver).
For details on Semantic Versioning, see [the semver package documentation](https://github.com/npm/node-semver).
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
@ -3,7 +3,7 @@ description: 'Setup a Go environment and add it to the PATH'
author:'GitHub'
author:'GitHub'
inputs:
inputs:
go-version:
go-version:
description:'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.'
description:'The Go version to download (if necessary) and use. Supports native Go versions (e.g. go1.21.5), semver specs and ranges. Be sure to enclose this option in single quotation marks.'
go-version-file:
go-version-file:
description:'Path to the go.mod, go.work, .go-version, or .tool-versions file.'
description:'Path to the go.mod, go.work, .go-version, or .tool-versions file.'
thrownewError(`Invalid Go version "${version}". Go-native versions must look like go1.21, go1.21.5, go1.18beta2, or go1.21rc2. For version ranges, use semver syntax (e.g. ~1.21, ^1.21).`);
Download and use beta or RC Go versions as needed.
Download and use beta or RC Go versions as needed.
When no custom download base URL is configured, the `go-version` input also accepts native Go version strings: `go1.21.5`, `go1.18beta2`, and `go1.21rc2` normalize to `1.21.5`, `1.18.0-beta.2`, and `1.21.0-rc.2`, respectively. `go1.21` resolves to exactly `1.21.0`; use `1.21` for matching patch releases. For ranges and wildcards, use SemVer syntax such as `~1.21` or `1.21.x`, not `go1.21.x`.
@ -215,6 +215,18 @@ function resolveVersionInput(): string {
}
}
if(version){
if(version){
// With a custom download URL leave the version unchanged.
constcustomBaseUrl=
core.getInput('go-download-base-url')||
process.env['GO_DOWNLOAD_BASE_URL'];
if(version.startsWith('go')&&!customBaseUrl){
if(!installer.isGoNativeVersion(version)){
thrownewError(
`Invalid Go version "${version}". Go-native versions must look like go1.21, go1.21.5, go1.18beta2, or go1.21rc2. For version ranges, use semver syntax (e.g. ~1.21, ^1.21).`