mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2026-08-28 04:54:58 -04:00
Add support for rc and beta versions in go.mod file
The regex in `parseGoVersionFile()` didn't consider rc and beta versions. The regex has been extended. In `findMatch()` the match is checked using `semver.satisfies()`. But `semver.satisfies()` doesn't no about Go's non-semver rc and beta version formats (1.16c1 instead of 1.16.0-rc.1). We cannot use `makeSemver()` on `versionSpec` and compare the result using `semver.satisfies()` because `versionSpec` could be, well, a spec. Instead we first check if there is a strict match between the candidate version and the versionSpec. Fixes #525.
This commit is contained in:
parent
b7ad1dad31
commit
1adbf3753d
4 changed files with 242 additions and 20 deletions
5
dist/setup/index.js
vendored
5
dist/setup/index.js
vendored
|
|
@ -43510,7 +43510,8 @@ async function findMatch(versionSpec, arch = external_os_default().arch(), dlUrl
|
|||
const candidate = candidates[i];
|
||||
const version = makeSemver(candidate.version);
|
||||
core_debug(`check ${version} satisfies ${versionSpec}`);
|
||||
if (node_modules_semver.satisfies(version, versionSpec)) {
|
||||
if (candidate.version.replace(/^go/, '') === versionSpec ||
|
||||
node_modules_semver.satisfies(version, versionSpec)) {
|
||||
goFile = candidate.files.find(file => {
|
||||
core_debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
|
||||
return file.arch === archFilter && file.os === platFilter;
|
||||
|
|
@ -43566,7 +43567,7 @@ function parseGoVersionFile(versionFilePath) {
|
|||
}
|
||||
}
|
||||
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
const matchGo = contents.match(/^go (\d+(\.\d+)*(?:\.\d+|(beta|rc)\d+)?)/m);
|
||||
return matchGo ? matchGo[1] : '';
|
||||
}
|
||||
else if (external_path_.basename(versionFilePath) === '.tool-versions') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue