mirror of
https://github.com/actions/setup-go.git
synced 2025-09-06 10:16:02 -06:00
squash! Prefer installing version from toolchain
directive
Avoid installing from `toolchain` if `GOTOOLCHAIN` is `local`, also better regex for matching toolchain directive
This commit is contained in:
parent
277ab1eb0e
commit
b967a467e1
3 changed files with 82 additions and 33 deletions
12
dist/setup/index.js
vendored
12
dist/setup/index.js
vendored
|
@ -94666,10 +94666,14 @@ function parseGoVersionFile(versionFilePath) {
|
|||
const contents = fs_1.default.readFileSync(versionFilePath).toString();
|
||||
if (path.basename(versionFilePath) === 'go.mod' ||
|
||||
path.basename(versionFilePath) === 'go.work') {
|
||||
// toolchain directive: https://go.dev/ref/mod#go-mod-file-toolchain
|
||||
const matchToolchain = contents.match(/^toolchain go(\d+(\.\d+)*)/m);
|
||||
if (matchToolchain) {
|
||||
return matchToolchain[1];
|
||||
// for backwards compatibility: use version from go directive if
|
||||
// 'GOTOOLCHAIN' has been explicitly set
|
||||
if (process.env[exports.GOTOOLCHAIN_ENV_VAR] !== exports.GOTOOLCHAIN_LOCAL_VAL) {
|
||||
// toolchain directive: https://go.dev/ref/mod#go-mod-file-toolchain
|
||||
const matchToolchain = contents.match(/^toolchain go(1\.\d+(?:\.\d+|rc\d+)?)/m);
|
||||
if (matchToolchain) {
|
||||
return matchToolchain[1];
|
||||
}
|
||||
}
|
||||
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue