Compare commits

...
Author SHA1 Message Date
v-mahabaleshwarsandmahabaleshwars b2a9ab24f0 Clarify description of go-bin-path output and its fallback behavior (#803)
* docs: clarify description of go-bin-path output and its fallback behavior

* fix: add newline at end of action.yml for proper formatting

* fix: remove unnecessary newline in action.yml

* fix: add missing newline at end of action.yml

---------

Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
2026-11-02 14:43:35 -06:00
v-jitenderpalsingh 3c1b57c66a Add support for native Go version syntax in go-version input (#804)
* Add support for native Go version syntax in go-version input

* Enhance Go-native version handling and update tests and documentation

* Update docs
2026-11-02 12:49:42 -06:00
Quim Muntal 90ad2b35f6 Merge pull request #794 from actions/chore/bump-actions-cache-6.3.0
chore(deps): bump @actions/cache to 6.3.0
2026-09-28 14:30:02 +02:00
qmuntal 0464ec84ca chore(deps): bump @actions/cache to 6.3.0
Pick up the Windows BSD tar temporary-file isolation fix from
actions/toolkit#2497.

Update the lockfile, license records, and generated action bundles.
2026-09-28 14:04:32 +02:00
v-mahabaleshwarsandmahabaleshwars 3bfff43db6 Preserve native Go environment names in action outputs (#793)
* preserve native Go environment names in action outputs

* implement review comment

* Add missing trailing newline to action.yml

---------

Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
2026-09-25 10:35:28 -05:00
v-mahabaleshwarsandmahabaleshwars e626ada899 Expose go env variables as action outputs (#791)
* feature implementation - output go env

* update action.yml

* fix action.yml

---------

Co-authored-by: mahabaleshwars <147705296+mahabaleshwars@users.noreply.github.com>
2026-09-18 10:05:51 -05:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 468e940882 Bump js-yaml from 3.15.1 to 3.15.2 (#790)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.15.1 to 3.15.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/3.15.2/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.15.1...3.15.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 3.15.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-16 12:34:25 -05:00
v-priya-kinthali 34829cb9ac fix: update macOS runner configuration to use macOS 15 Intel (#786) 2026-09-08 16:28:33 -05:00
Priya Gupta addc0880c9 Group verbose Go installation logs and normalize package.json line endings (#789)
* refactor: enhance logging and group setup for Go version installation

* refactor: update logging group name for Go version setup

* refactor: standardize formatting in package.json

* audit fix

* update package-lock.json
2026-09-08 14:17:06 -05:00
HarithaandCopilot fba3fb4ead fix: resolve audit/license failures (#784)
* fix: resolve brace-expansion high-severity vulnerability, refresh license cache, rebuild dist

- Regenerated package-lock.json to pick up brace-expansion@5.0.9 (fixes
  GHSA-rgw5-rvv9-x895, a DoS via unbounded intermediate arrays), which
  is already permitted by minimatch's existing ^5.0.8 semver range.
- Refreshed .licenses/npm cache to match the updated dependency tree.
- Added minimatch to the licensed.yml reviewed list: its detected
  license text doesn't cleanly match Blue Oak 1.0.0, which is already
  in the allowed list.
- Rebuilt dist/setup and dist/cache-save from source.

npm audit --audit-level=high now reports 0 vulnerabilities;
licensed status reports 0 errors; npm run pre-checkin passes locally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: narrow audit dependency updates

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 10:06:05 -05:00
25 changed files with 6965 additions and 8375 deletions
+39 -14
View File
@@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go Stable
@@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go oldStable
@@ -43,18 +43,43 @@ jobs:
- name: Verify Go
run: go version
go-env-outputs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go
id: setup-go
uses: ./
with:
go-version: stable
- name: Show Go environment outputs
run: |
echo "GOPATH: ${{ steps.setup-go.outputs.GOPATH }}"
echo "GOBIN: ${{ steps.setup-go.outputs.GOBIN }}"
echo "go-bin-path: ${{ steps.setup-go.outputs.go-bin-path }}"
echo "GOROOT: ${{ steps.setup-go.outputs.GOROOT }}"
echo "GOCACHE: ${{ steps.setup-go.outputs.GOCACHE }}"
echo "GOMODCACHE: ${{ steps.setup-go.outputs.GOMODCACHE }}"
echo "GOOS: ${{ steps.setup-go.outputs.GOOS }}"
echo "GOARCH: ${{ steps.setup-go.outputs.GOARCH }}"
echo "GOTOOLDIR: ${{ steps.setup-go.outputs.GOTOOLDIR }}"
aliases-arch:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
version: [stable, oldstable]
architecture: [x64, x32]
exclude:
- os: macos-latest
architecture: x32
- os: macos-latest-large
- os: macos-15-intel
architecture: x32
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -72,7 +97,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
os: [macos-latest, windows-latest, ubuntu-latest, macos-15-intel]
go: [1.21.13, 1.22.8, 1.23.2]
include:
- os: windows-latest
@@ -98,7 +123,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
go-version: ['1.20', '1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -115,7 +140,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go and check latest
@@ -131,7 +156,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go and check latest
@@ -147,7 +172,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go and check latest
@@ -163,7 +188,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go from .go-version file
@@ -179,7 +204,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
os: [macos-latest, windows-latest, ubuntu-latest, macos-15-intel]
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
steps:
- name: Checkout
@@ -199,7 +224,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest-large]
os: [windows-latest, ubuntu-latest, macos-15-intel]
go: [1.11.12]
steps:
- name: Checkout
@@ -219,7 +244,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
go-version: [1.20.14, 1.21, 1.22, 1.23]
include:
- os: macos-latest
@@ -228,7 +253,7 @@ jobs:
architecture: x64
- os: windows-latest
architecture: x64
- os: macos-latest-large
- os: macos-15-intel
architecture: x64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@actions/cache"
version: 6.2.0
version: 6.3.0
type: npm
summary: Actions cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
-20
View File
@@ -1,20 +0,0 @@
---
name: "@actions/glob"
version: 0.6.1
type: npm
summary: Actions glob lib
homepage: https://github.com/actions/toolkit/tree/main/packages/glob
license: mit
licenses:
- sources: LICENSE.md
text: |-
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@azure/core-rest-pipeline"
version: 1.24.0
version: 1.23.0
type: npm
summary: Isomorphic client library for making HTTP requests in node.js and browser.
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-rest-pipeline/README.md
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@azure/storage-blob"
version: 12.32.0
version: 12.31.0
type: npm
summary: Microsoft Azure Storage SDK for JavaScript - Blob
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob/README.md
-55
View File
@@ -1,55 +0,0 @@
---
name: balanced-match
version: 1.0.2
type: npm
summary: Match balanced character pairs, like "{" and "}"
homepage: https://github.com/juliangruber/balanced-match
license: mit
licenses:
- sources: LICENSE.md
text: |
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- sources: README.md
text: |-
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []
-55
View File
@@ -1,55 +0,0 @@
---
name: brace-expansion
version: 1.1.16
type: npm
summary: Brace expansion as known from sh/bash
homepage: https://github.com/juliangruber/brace-expansion
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- sources: README.md
text: |-
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []
@@ -1,6 +1,6 @@
---
name: brace-expansion
version: 5.0.8
version: 5.0.9
type: npm
summary: Brace expansion as known from sh/bash
homepage:
-31
View File
@@ -1,31 +0,0 @@
---
name: concat-map
version: 0.0.1
type: npm
summary: concatenative mapdashery
homepage: https://github.com/substack/node-concat-map#readme
license: other
licenses:
- sources: LICENSE
text: |
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- sources: README.markdown
text: MIT
notices: []
-26
View File
@@ -1,26 +0,0 @@
---
name: minimatch
version: 3.1.5
type: npm
summary: a glob matcher in javascript
homepage:
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: undici
version: 6.27.0
version: 6.28.0
type: npm
summary: An HTTP/1.1 client, written from scratch for Node.js
homepage: https://undici.nodejs.org
+1
View File
@@ -94,6 +94,7 @@ the [check-latest input](docs/advanced-usage.md#check-latest-version).
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`
- 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`
- Aliases: `stable`, `oldstable`
- Wildcards: `1.25.x`, `1.x`
+245
View File
@@ -17,6 +17,7 @@ import goTestManifest from './data/versions-manifest.json' with {type: 'json'};
import type {IGoVersion} from '../src/installer.js';
import type {IToolRelease} from '@actions/tool-cache';
import {GO_ENV_OUTPUTS} from '../src/constants.js';
const httpClientGetJson = jest.fn();
@@ -28,6 +29,8 @@ jest.unstable_mockModule('@actions/core', () => ({
getBooleanInput: jest.fn(),
info: jest.fn(),
debug: jest.fn(),
warning: jest.fn(),
setOutput: jest.fn(),
exportVariable: jest.fn()
}));
@@ -110,6 +113,8 @@ describe('setup-go', () => {
let findSpy: jest.Mock;
let cnSpy: jest.SpiedFunction<typeof process.stdout.write>;
let logSpy: jest.Mock;
let setOutputSpy: jest.Mock<typeof core.setOutput>;
let warningSpy: jest.Mock<typeof core.warning>;
let getSpy: jest.Mock;
let platSpy: jest.Mock;
let archSpy: jest.Mock;
@@ -198,6 +203,8 @@ describe('setup-go', () => {
// writes
cnSpy = jest.spyOn(process.stdout, 'write');
logSpy = core.info as jest.Mock;
setOutputSpy = core.setOutput as jest.Mock<typeof core.setOutput>;
warningSpy = core.warning as jest.Mock<typeof core.warning>;
dbgSpy = core.debug as jest.Mock;
getSpy.mockImplementation(() => goJsonData as IGoVersion[] | null);
cnSpy.mockImplementation(() => true);
@@ -646,6 +653,106 @@ describe('setup-go', () => {
expect(added).toBeTruthy();
});
describe('go env outputs', () => {
const goEnv = {
GOPATH: '/Users/testuser/go',
GOBIN: '',
GOROOT: '/usr/local/go',
GOCACHE: '/Users/testuser/.cache/go-build',
GOMODCACHE: '/Users/testuser/go/pkg/mod',
GOOS: 'darwin',
GOARCH: 'arm64',
GOTOOLDIR: '/usr/local/go/pkg/tool/darwin_arm64'
};
it('parses the output of go env -json', () => {
execFileSpy.mockImplementation(() => JSON.stringify(goEnv));
expect(main.readGoEnv('/usr/local/go/bin/go')).toEqual(goEnv);
});
it('returns undefined when go env -json is not supported', () => {
execFileSpy.mockImplementation(() => {
throw new Error('flag provided but not defined: -json');
});
expect(main.readGoEnv('/usr/local/go/bin/go')).toBeUndefined();
expect(logSpy).toHaveBeenCalledWith(
expect.stringContaining('flag provided but not defined: -json')
);
expect(warningSpy).not.toHaveBeenCalled();
});
it('returns undefined when the output is not valid JSON', () => {
execFileSpy.mockImplementation(() => 'GOPATH="/Users/testuser/go"');
expect(main.readGoEnv('/usr/local/go/bin/go')).toBeUndefined();
});
it('returns undefined when the output is not a JSON object', () => {
execFileSpy.mockImplementation(() => '[]');
expect(main.readGoEnv('/usr/local/go/bin/go')).toBeUndefined();
});
it('sets an output for each exposed variable', () => {
main.setGoEnvOutputs(goEnv);
expect(GO_ENV_OUTPUTS).toEqual([
'GOPATH',
'GOBIN',
'GOROOT',
'GOCACHE',
'GOMODCACHE',
'GOOS',
'GOARCH',
'GOTOOLDIR'
]);
for (const name of GO_ENV_OUTPUTS) {
expect(setOutputSpy).toHaveBeenCalledWith(name, goEnv[name] ?? '');
}
});
it('falls back to $GOPATH/bin when GOBIN is empty', () => {
main.setGoEnvOutputs(goEnv);
expect(setOutputSpy).toHaveBeenCalledWith(
'go-bin-path',
'/Users/testuser/go/bin'
);
});
it('prefers GOBIN over $GOPATH/bin when it is set', () => {
main.setGoEnvOutputs({...goEnv, GOBIN: '/Users/testuser/bin'});
expect(setOutputSpy).toHaveBeenCalledWith(
'go-bin-path',
'/Users/testuser/bin'
);
});
it('uses the first entry of a multi-entry GOPATH', () => {
const GOPATH = ['/Users/testuser/go', '/Users/testuser/other'].join(
path.delimiter
);
main.setGoEnvOutputs({...goEnv, GOPATH});
expect(setOutputSpy).toHaveBeenCalledWith('GOPATH', GOPATH);
expect(setOutputSpy).toHaveBeenCalledWith(
'go-bin-path',
'/Users/testuser/go/bin'
);
});
it('leaves variables missing from go env -json empty', () => {
main.setGoEnvOutputs({});
expect(setOutputSpy).toHaveBeenCalledWith('GOPATH', '');
expect(setOutputSpy).toHaveBeenCalledWith('go-bin-path', '');
});
});
interface Annotation {
file: string;
line: number;
@@ -759,6 +866,11 @@ describe('setup-go', () => {
expect(im.makeSemver('1.10rc1')).toBe('1.10.0-rc.1');
});
it('preserves already-normalized prerelease versions', () => {
expect(im.makeSemver('1.18.0-beta.2')).toBe('1.18.0-beta.2');
expect(im.makeSemver('1.21.0-rc.2')).toBe('1.21.0-rc.2');
});
it('converts dot zero versions', async () => {
expect(im.makeSemver('1.13')).toBe('1.13.0');
});
@@ -767,6 +879,102 @@ describe('setup-go', () => {
expect(im.makeSemver('1.13.1')).toBe('1.13.1');
});
it('isGoNativeVersion accepts supported Go-native version formats', () => {
expect(im.isGoNativeVersion('go1.21')).toBe(true);
expect(im.isGoNativeVersion('go1.21.5')).toBe(true);
expect(im.isGoNativeVersion('go1.18beta2')).toBe(true);
expect(im.isGoNativeVersion('go1.21rc2')).toBe(true);
expect(im.isGoNativeVersion('go1.21.x')).toBe(false);
expect(im.isGoNativeVersion('go^1.21')).toBe(false);
expect(im.isGoNativeVersion('1.21')).toBe(false);
expect(im.isGoNativeVersion('go1')).toBe(false);
expect(im.isGoNativeVersion('go1.21.5beta1')).toBe(false);
expect(im.isGoNativeVersion('go1.21.0rc1')).toBe(false);
});
it('accepts a Go-native go-version input and normalizes it', async () => {
os.platform = 'linux';
os.arch = 'x64';
inputs['go-version'] = 'go1.21';
findSpy.mockImplementation(() => path.normalize('/cache/go/1.21.0/x64'));
await main.run();
expect(logSpy).toHaveBeenCalledWith('Setup go version spec go1.21');
expect(findSpy).toHaveBeenCalledWith('go', '1.21.0', 'x64');
expect(logSpy).toHaveBeenCalledWith(
'Successfully set up Go version go1.21'
);
});
it('rejects a malformed Go-native go-version input', async () => {
os.platform = 'linux';
os.arch = 'x64';
inputs['go-version'] = 'go1.21.x';
await main.run();
expect(cnSpy).toHaveBeenCalledWith(
expect.stringContaining('Invalid Go version "go1.21.x"')
);
});
it('accepts a Go-native go-version input with beta suffix and normalizes it', async () => {
os.platform = 'linux';
os.arch = 'x64';
inputs['go-version'] = 'go1.18beta2';
findSpy.mockImplementation(() =>
path.normalize('/cache/go/1.18.0-beta.2/x64')
);
await main.run();
expect(logSpy).toHaveBeenCalledWith('Setup go version spec go1.18beta2');
expect(findSpy).toHaveBeenCalledWith('go', '1.18.0-beta.2', 'x64');
expect(logSpy).toHaveBeenCalledWith(
'Successfully set up Go version go1.18beta2'
);
});
it('accepts a Go-native go-version input with rc suffix and normalizes it', async () => {
os.platform = 'linux';
os.arch = 'x64';
inputs['go-version'] = 'go1.21rc2';
findSpy.mockImplementation(() =>
path.normalize('/cache/go/1.21.0-rc.2/x64')
);
await main.run();
expect(logSpy).toHaveBeenCalledWith('Setup go version spec go1.21rc2');
expect(findSpy).toHaveBeenCalledWith('go', '1.21.0-rc.2', 'x64');
expect(logSpy).toHaveBeenCalledWith(
'Successfully set up Go version go1.21rc2'
);
});
it('downloads a normalized Go-native version on cache miss', async () => {
os.platform = 'linux';
os.arch = 'x64';
inputs['go-version'] = 'go1.13';
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () =>
path.normalize('/cache/go/1.13.0/x64')
);
await main.run();
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.13.0...');
expect(dlSpy).toHaveBeenCalled();
expect(logSpy).toHaveBeenCalledWith(
'Successfully set up Go version go1.13'
);
});
describe('check-latest flag', () => {
it("use local version and don't check manifest if check-latest is not specified", async () => {
os.platform = 'linux';
@@ -1190,6 +1398,43 @@ use .
});
describe('go-download-base-url', () => {
it('normalizes native versions but preserves custom download filenames', async () => {
os.platform = 'linux';
os.arch = 'x64';
const versionSpec = 'go1.21rc2';
const customBaseUrl = 'https://example.com/golang';
const toolName = im.customToolCacheName(customBaseUrl);
const toolPath = path.normalize(`/cache/${toolName}/1.21.0-rc.2/x64`);
inputs['go-version'] = versionSpec;
inputs['go-download-base-url'] = customBaseUrl;
getSpy.mockImplementationOnce(() => {
throw new Error('Not a JSON endpoint');
});
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
execFileSpy.mockImplementation(() => 'go version go1.21rc2 linux/amd64');
cacheSpy.mockImplementation(async () => toolPath);
await main.run();
expect(findSpy).toHaveBeenCalledWith(toolName, '1.21.0-rc.2', 'x64');
expect(getSpy).toHaveBeenCalledWith(
`${customBaseUrl}/?mode=json&include=all`
);
expect(dlSpy).toHaveBeenCalledWith(
`${customBaseUrl}/go1.21rc2.linux-amd64.tar.gz`,
undefined,
undefined
);
expect(cnSpy).toHaveBeenCalledWith(
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
);
});
it('downloads a version from custom base URL using version listing', async () => {
os.platform = 'linux';
os.arch = 'x64';
+19 -1
View File
@@ -3,7 +3,7 @@ description: 'Setup a Go environment and add it to the PATH'
author: 'GitHub'
inputs:
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:
description: 'Path to the go.mod, go.work, .go-version, or .tool-versions file.'
check-latest:
@@ -26,6 +26,24 @@ outputs:
description: 'The installed Go version. Useful when given a version range as input.'
cache-hit:
description: 'A boolean value to indicate if a cache was hit'
GOPATH:
description: 'The value of `go env GOPATH`.'
GOBIN:
description: 'The value of `go env GOBIN`.'
go-bin-path:
description: 'The base Go binary directory: the `GOBIN` value, otherwise `bin` under the first `GOPATH` entry when `GOBIN` is empty.'
GOROOT:
description: 'The value of `go env GOROOT`.'
GOCACHE:
description: 'The value of `go env GOCACHE`, the build cache directory.'
GOMODCACHE:
description: 'The value of `go env GOMODCACHE`, the module cache directory.'
GOOS:
description: 'The value of `go env GOOS`, the target OS in Go notation (linux, darwin, windows).'
GOARCH:
description: 'The value of `go env GOARCH`, the target architecture in Go notation (amd64, arm64).'
GOTOOLDIR:
description: 'The value of `go env GOTOOLDIR`, the directory holding the toolchain binaries.'
runs:
using: 'node24'
main: 'dist/setup/index.js'
+3089 -2206
View File
File diff suppressed because it is too large Load Diff
+3274 -5773
View File
File diff suppressed because it is too large Load Diff
+40 -1
View File
@@ -12,6 +12,9 @@
- [Restore-only caches](advanced-usage.md#restore-only-caches)
- [Parallel builds](advanced-usage.md#parallel-builds)
- [Outputs](advanced-usage.md#outputs)
- [go-version](advanced-usage.md#go-version)
- [cache-hit](advanced-usage.md#cache-hit)
- [Go environment outputs](advanced-usage.md#go-environment-outputs)
- [Custom download URL](advanced-usage.md#custom-download-url)
- [Using `setup-go` on GHES](advanced-usage.md#using-setup-go-on-ghes)
@@ -47,9 +50,13 @@ steps:
- The preinstalled patch version is generally the latest available. When a new patch is released, it replaces the previously preinstalled version on the runner.
- Using the most recent patch version speeds up setup because the required Go version is already installed on the runner and no download is needed.
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`.
To try a **pre-release**:
Download and use beta or RC Go versions as needed.
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`.
```yaml
# RC version
steps:
@@ -420,12 +427,44 @@ jobs:
- run: echo "Was the Go cache restored? ${{ steps.go124.outputs.cache-hit }}" # true if cache-hit occurred
```
### Go environment outputs
Once Go is on the `PATH`, the action exposes the most commonly needed `go env` variables as outputs, so workflows don't have to query them in duplicated `bash`/`pwsh` steps — one expression works on Linux, macOS, and Windows. The values are a snapshot from setup time: anything a later step changes, such as setting `GOOS`/`GOARCH` to cross-compile, is not reflected.
| Output | Notes |
| --- | --- |
| `GOPATH` | Go workspace root; `bin` and `pkg/mod` live under it |
| `GOBIN` | Go 1.27+ reports an implicit `$GOPATH/bin` default; earlier releases are empty unless `GOBIN` is set |
| `go-bin-path` | Uses `GOBIN`, or falls back to `bin` under the first `GOPATH` entry when `GOBIN` is empty. It normally matches `GOBIN` on Go 1.27+; the fallback is a convenience for earlier releases. When `GOBIN` is not explicitly set (in the environment or via `go env -w`), cross-compiled binaries go one level deeper, in `$GOPATH/bin/${GOOS}_${GOARCH}` |
| `GOROOT` | Installation directory of the Go toolchain in use |
| `GOCACHE` | Build cache directory |
| `GOMODCACHE` | Module cache directory |
| `GOOS` | Go notation (`linux`, `darwin`, `windows`), unlike `runner.os` |
| `GOARCH` | Go notation (`amd64`, `arm64`), unlike `runner.arch` or the `x64` in the action's cache key |
| `GOTOOLDIR` | Holds `compile`, `link`, `vet` and the other toolchain binaries |
```yaml
steps:
- uses: actions/setup-go@v7
id: setup-go
with:
go-version: '1.25.5'
- run: echo "Modules are cached in ${{ steps.setup-go.outputs.GOMODCACHE }}"
```
Quote `go-bin-path` in shell commands, since it may contain spaces. Variables without a dedicated output are not exposed; run `go env <NAME>` in a step when you need one.
> [!NOTE]
> These outputs need Go 1.9 or newer (`go env -json`); on older releases the action logs a message, leaves them unset and does not fail. `GOCACHE` needs Go 1.10 and `GOMODCACHE` needs Go 1.15.
## Custom download URL
The `go-download-base-url` input lets you download Go from a mirror or alternative source instead of the default `https://go.dev/dl`. This can also be set via the `GO_DOWNLOAD_BASE_URL` environment variable; the input takes precedence over the environment variable.
When a custom base URL is provided, the action skips the `actions/go-versions` manifest lookup and downloads directly from the specified URL.
> **Note:** When constructing direct-download filenames, the original version string is preserved; native Go version normalization is used only for matching and tool cache lookups.
**Using the [Microsoft build of Go](https://github.com/microsoft/go):**
```yaml
@@ -495,4 +534,4 @@ with:
If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache.
See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
for more information.
for more information.
+54 -91
View File
@@ -9,7 +9,7 @@
"version": "7.0.0",
"license": "MIT",
"dependencies": {
"@actions/cache": "^6.2.0",
"@actions/cache": "^6.3.0",
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/glob": "^0.7.0",
@@ -42,58 +42,20 @@
}
},
"node_modules/@actions/cache": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-6.2.0.tgz",
"integrity": "sha512-Nv0xWRmbxfDbAn/70flO/F6tj2Nv4XTYMAsQHiDFSojCDfso/Zni+fRKa14ToI9hnmOW/rQcY1WYb6wsM7Pgwg==",
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-6.3.0.tgz",
"integrity": "sha512-SJKaVMqTgetQgJF0wifi5N2+2mffCLy/D4w/3sJtRanBBGECdi1/OD0wswyLVmqEmPbYB/rVJk41Qn/xEbFjAw==",
"license": "MIT",
"dependencies": {
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/glob": "^0.6.1",
"@actions/glob": "^0.7.0",
"@actions/http-client": "^4.0.1",
"@actions/io": "^3.0.2",
"@azure/core-rest-pipeline": "^1.23.0",
"@azure/storage-blob": "^12.31.0",
"@azure/core-rest-pipeline": "~1.23.0",
"@azure/storage-blob": "~12.31.0",
"@protobuf-ts/runtime-rpc": "^2.11.1",
"semver": "^7.7.4"
}
},
"node_modules/@actions/cache/node_modules/@actions/glob": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.6.1.tgz",
"integrity": "sha512-K4+2Ac5ILcf2ySdJCha+Pop9NcKjxqCL4xL4zI50dgB2PbXgC0+AcP011xfH4Of6b4QEJJg8dyZYv7zl4byTsw==",
"license": "MIT",
"dependencies": {
"@actions/core": "^3.0.0",
"minimatch": "^3.0.4"
}
},
"node_modules/@actions/cache/node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"license": "MIT"
},
"node_modules/@actions/cache/node_modules/brace-expansion": {
"version": "1.1.16",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.16.tgz",
"integrity": "sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==",
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/@actions/cache/node_modules/minimatch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
"semver": "^7.8.5"
}
},
"node_modules/@actions/core": {
@@ -242,9 +204,9 @@
}
},
"node_modules/@azure/core-rest-pipeline": {
"version": "1.24.0",
"resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.24.0.tgz",
"integrity": "sha512-PpLsoDQ3AMmKZ0VU+0GrmqMxgp/sExjlVm4R+nLWngeoEGAzOIPVifaxKGU5gMv+nWELUoHfvrolWD+ZS/nFJg==",
"version": "1.23.0",
"resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.23.0.tgz",
"integrity": "sha512-Evs1INHo+jUjwHi1T6SG6Ua/LHOQBCLuKEEE6efIpt4ZOoNonaT1kP32GoOcdNDbfqsD2445CPri3MubBy5DEQ==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.1.2",
@@ -312,9 +274,9 @@
}
},
"node_modules/@azure/storage-blob": {
"version": "12.32.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.32.0.tgz",
"integrity": "sha512-80LzSNnFQye2LCCBFghAJS6jJQJ7N4bfgZ6qDMgVGRtugZ7TLDKQZ2hczMigmZH3jAcMRdma/IygsC5+0gT7Tw==",
"version": "12.31.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.31.0.tgz",
"integrity": "sha512-DBgNv10aCSxopt92DkTDD0o9xScXeBqPKGmR50FPZQaEcH4JLQ+GEOGEDv19V5BMkB7kxr+m4h6il/cCDPvmHg==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.1.2",
@@ -328,7 +290,7 @@
"@azure/core-util": "^1.11.0",
"@azure/core-xml": "^1.4.5",
"@azure/logger": "^1.1.4",
"@azure/storage-common": "^12.4.0",
"@azure/storage-common": "^12.3.0",
"events": "^3.0.0",
"tslib": "^2.8.1"
},
@@ -2703,9 +2665,9 @@
}
},
"node_modules/baseline-browser-mapping": {
"version": "2.10.38",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.38.tgz",
"integrity": "sha512-31/02mVB4yuQU6adKk5SlY6m+mxDwUq5KZkyYgnLrrKl7TEm1+3PyDtDBz2kOv/wxZz41GHsvV1A/u6RmiyBvw==",
"version": "2.11.20",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz",
"integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -2716,9 +2678,9 @@
}
},
"node_modules/brace-expansion": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
@@ -2728,9 +2690,9 @@
}
},
"node_modules/browserslist": {
"version": "4.28.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
"integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==",
"version": "4.28.8",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
"integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
"dev": true,
"funding": [
{
@@ -2748,11 +2710,11 @@
],
"license": "MIT",
"dependencies": {
"baseline-browser-mapping": "^2.10.12",
"caniuse-lite": "^1.0.30001782",
"electron-to-chromium": "^1.5.328",
"node-releases": "^2.0.36",
"update-browserslist-db": "^1.2.3"
"baseline-browser-mapping": "^2.11.12",
"caniuse-lite": "^1.0.30001809",
"electron-to-chromium": "^1.5.402",
"node-releases": "^2.0.53",
"update-browserslist-db": "^1.3.0"
},
"bin": {
"browserslist": "cli.js"
@@ -2812,9 +2774,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001799",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001799.tgz",
"integrity": "sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw==",
"version": "1.0.30001810",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
"integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
"dev": true,
"funding": [
{
@@ -3002,6 +2964,7 @@
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true,
"license": "MIT"
},
"node_modules/convert-source-map": {
@@ -3093,9 +3056,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.5.376",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.376.tgz",
"integrity": "sha512-cUVA7/RvbFTEuw/i3obUwDTRIXojaxkResf+ibByPFxjc6XK3VNtcQXV0NSbAlJ0FMjcJGgftVVB4Qo184EXvA==",
"version": "1.5.418",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.418.tgz",
"integrity": "sha512-UzS26r3AEbG5wSoGVpJKqwHIU9zwQN7LHdVIThDrJpS0I5KdlXFMEb8543fhc9dVnIIAST6ar8rhwa00AL5MlA==",
"dev": true,
"license": "ISC"
},
@@ -3874,9 +3837,9 @@
"license": "MIT"
},
"node_modules/glob/node_modules/brace-expansion": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.2.tgz",
"integrity": "sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==",
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -4824,9 +4787,9 @@
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.0.tgz",
"integrity": "sha512-ttBQIIQPDeLjpPOohtUdXuXUVoA2uIB6fEH9HyJ7234s5mBJ5wTx20njxplLZQgLaOfpmPQA7X2t5AX6tIPbog==",
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.2.tgz",
"integrity": "sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -5116,9 +5079,9 @@
"license": "MIT"
},
"node_modules/node-releases": {
"version": "2.0.48",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.48.tgz",
"integrity": "sha512-1uz8041X6LoI6ZSdZacM9lVY28vuzDlSKitnpbSNK0RfKoIJkX29NBPVEFXhnuSuEOA9Ww0xnPJ+ILWbGAv8DA==",
"version": "2.0.54",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
"integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -5957,9 +5920,9 @@
"license": "MIT"
},
"node_modules/test-exclude/node_modules/brace-expansion": {
"version": "1.1.16",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.16.tgz",
"integrity": "sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==",
"version": "1.1.18",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -6185,9 +6148,9 @@
}
},
"node_modules/undici": {
"version": "6.27.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.27.0.tgz",
"integrity": "sha512-YmfV3YnEDzXRC5lZ2jWtWWHKGUm1zIt8AhesR1tens+HTNv+YZlN/dp6G727LOvMJ8xjP9Be7Y2Sdr96LDm+pg==",
"version": "6.28.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz",
"integrity": "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA==",
"license": "MIT",
"engines": {
"node": ">=18.17"
@@ -6239,9 +6202,9 @@
}
},
"node_modules/update-browserslist-db": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
"integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==",
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
"integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
"dev": true,
"funding": [
{
+60 -60
View File
@@ -1,60 +1,60 @@
{
"name": "setup-go",
"version": "7.0.0",
"type": "module",
"private": true,
"description": "setup go action",
"main": "lib/setup-go.js",
"engines": {
"node": ">=24.0.0"
},
"scripts": {
"build": "tsc && ncc build -o dist/setup src/setup-go.ts && ncc build -o dist/cache-save src/cache-save.ts",
"format": "prettier --no-error-on-unmatched-pattern --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint \"**/*.ts\"",
"lint:fix": "eslint \"**/*.ts\" --fix",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --runInBand --coverage",
"pre-checkin": "npm run format && npm run lint:fix && npm run build && npm test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/setup-go.git"
},
"keywords": [
"actions",
"go",
"setup"
],
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "^6.2.0",
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/glob": "^0.7.0",
"@actions/http-client": "^4.0.1",
"@actions/io": "^3.0.2",
"@actions/tool-cache": "^4.0.0",
"semver": "^7.8.5"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@jest/globals": "^30.4.1",
"@types/node": "^24.0.0",
"@types/semver": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^8.62.0",
"@typescript-eslint/parser": "^8.62.0",
"@vercel/ncc": "^0.44.0",
"eslint": "^10.5.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-jest": "^29.15.2",
"eslint-plugin-n": "^18.1.0",
"globals": "^17.7.0",
"jest": "^30.4.2",
"nock": "^14.0.0",
"prettier": "^3.8.4",
"ts-jest": "^29.4.11",
"typescript": "^6.0.3"
}
}
{
"name": "setup-go",
"version": "7.0.0",
"type": "module",
"private": true,
"description": "setup go action",
"main": "lib/setup-go.js",
"engines": {
"node": ">=24.0.0"
},
"scripts": {
"build": "tsc && ncc build -o dist/setup src/setup-go.ts && ncc build -o dist/cache-save src/cache-save.ts",
"format": "prettier --no-error-on-unmatched-pattern --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint \"**/*.ts\"",
"lint:fix": "eslint \"**/*.ts\" --fix",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --runInBand --coverage",
"pre-checkin": "npm run format && npm run lint:fix && npm run build && npm test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/setup-go.git"
},
"keywords": [
"actions",
"go",
"setup"
],
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "^6.3.0",
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/glob": "^0.7.0",
"@actions/http-client": "^4.0.1",
"@actions/io": "^3.0.2",
"@actions/tool-cache": "^4.0.0",
"semver": "^7.8.5"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@jest/globals": "^30.4.1",
"@types/node": "^24.0.0",
"@types/semver": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^8.62.0",
"@typescript-eslint/parser": "^8.62.0",
"@vercel/ncc": "^0.44.0",
"eslint": "^10.5.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-jest": "^29.15.2",
"eslint-plugin-n": "^18.1.0",
"globals": "^17.7.0",
"jest": "^30.4.2",
"nock": "^14.0.0",
"prettier": "^3.8.4",
"ts-jest": "^29.4.11",
"typescript": "^6.0.3"
}
}
+16 -1
View File
@@ -4,5 +4,20 @@ export enum State {
}
export enum Outputs {
CacheHit = 'cache-hit'
CacheHit = 'cache-hit',
GoBinPath = 'go-bin-path'
}
export const GO_ENV_OUTPUTS = [
'GOPATH',
'GOBIN',
'GOROOT',
'GOCACHE',
'GOMODCACHE',
'GOOS',
'GOARCH',
'GOTOOLDIR'
] as const;
export type GoEnvVar = (typeof GO_ENV_OUTPUTS)[number];
export type GoEnv = Partial<Record<GoEnvVar, string>>;
+27 -4
View File
@@ -60,6 +60,11 @@ export async function getGo(
const osPlat: string = os.platform();
const customBaseUrl = goDownloadBaseUrl?.replace(/\/+$/, '');
const originalVersionSpec = versionSpec;
if (isGoNativeVersion(versionSpec)) {
versionSpec = makeSemver(versionSpec);
}
if (
versionSpec === StableReleaseAlias.Stable ||
versionSpec === StableReleaseAlias.OldStable
@@ -146,7 +151,11 @@ export async function getGo(
core.info(
'Skipping version listing for known direct-download URL. Constructing download URL directly.'
);
info = getInfoFromDirectDownload(versionSpec, arch, customBaseUrl);
info = getInfoFromDirectDownload(
originalVersionSpec,
arch,
customBaseUrl
);
} else {
try {
info = await getInfoFromDist(versionSpec, arch, customBaseUrl);
@@ -156,7 +165,11 @@ export async function getGo(
);
}
if (!info) {
info = getInfoFromDirectDownload(versionSpec, arch, customBaseUrl);
info = getInfoFromDirectDownload(
originalVersionSpec,
arch,
customBaseUrl
);
}
}
@@ -167,13 +180,13 @@ export async function getGo(
const downloadUrl = info?.downloadUrl || customBaseUrl;
if (err instanceof tc.HTTPError && err.httpStatusCode === 404) {
throw new Error(
`The requested Go version ${versionSpec} is not available for platform ${osPlat}/${arch}. ` +
`The requested Go version ${originalVersionSpec} is not available for platform ${osPlat}/${arch}. ` +
`Download URL returned HTTP 404: ${downloadUrl}`,
{cause: err}
);
}
throw new Error(
`Failed to download Go ${versionSpec} for platform ${osPlat}/${arch} ` +
`Failed to download Go ${originalVersionSpec} for platform ${osPlat}/${arch} ` +
`from ${downloadUrl}: ${err}`,
{cause: err}
);
@@ -610,6 +623,12 @@ export async function findMatch(
return result;
}
export function isGoNativeVersion(version: string): boolean {
const expression =
/^go[1-9]\d*\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)|(?:beta|rc)[1-9]\d*)?$/;
return expression.test(version);
}
//
// Convert the go version syntax into semver for semver matching
// 1.13.1 => 1.13.1
@@ -617,6 +636,10 @@ export async function findMatch(
// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1
// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1
export function makeSemver(version: string): string {
const validVersion = semver.valid(version);
if (validVersion) {
return validVersion;
}
version = version.replace('go', '');
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
const parts = version.split('-');
+96 -32
View File
@@ -10,6 +10,7 @@ import cp from 'child_process';
import fs from 'fs';
import os from 'os';
import {Architecture} from './types.js';
import {GO_ENV_OUTPUTS, GoEnv, Outputs} from './constants.js';
export async function run() {
try {
@@ -21,7 +22,6 @@ export async function run() {
setGoToolchain();
const cache = core.getBooleanInput('cache');
core.info(`Setup go version spec ${versionSpec}`);
let arch = core.getInput('architecture') as Architecture;
@@ -30,41 +30,48 @@ export async function run() {
}
if (versionSpec) {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
core.startGroup('Installed version');
try {
core.info(`Setup go version spec ${versionSpec}`);
const checkLatest = core.getBooleanInput('check-latest');
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const goDownloadBaseUrl =
core.getInput('go-download-base-url') ||
process.env['GO_DOWNLOAD_BASE_URL'] ||
undefined;
const checkLatest = core.getBooleanInput('check-latest');
if (goDownloadBaseUrl) {
core.info(`Using custom Go download base URL: ${goDownloadBaseUrl}`);
const goDownloadBaseUrl =
core.getInput('go-download-base-url') ||
process.env['GO_DOWNLOAD_BASE_URL'] ||
undefined;
if (goDownloadBaseUrl) {
core.info(`Using custom Go download base URL: ${goDownloadBaseUrl}`);
}
const installDir = await installer.getGo(
versionSpec,
checkLatest,
auth,
arch,
goDownloadBaseUrl
);
const installDirVersion = path.basename(path.dirname(installDir));
core.addPath(path.join(installDir, 'bin'));
core.info('Added go to the path');
const version = installer.makeSemver(installDirVersion);
// Go versions less than 1.9 require GOROOT to be set
if (semver.lt(version, '1.9.0')) {
core.info('Setting GOROOT for Go version < 1.9');
core.exportVariable('GOROOT', installDir);
}
core.info(`Successfully set up Go version ${versionSpec}`);
} finally {
core.endGroup();
}
const installDir = await installer.getGo(
versionSpec,
checkLatest,
auth,
arch,
goDownloadBaseUrl
);
const installDirVersion = path.basename(path.dirname(installDir));
core.addPath(path.join(installDir, 'bin'));
core.info('Added go to the path');
const version = installer.makeSemver(installDirVersion);
// Go versions less than 1.9 require GOROOT to be set
if (semver.lt(version, '1.9.0')) {
core.info('Setting GOROOT for Go version < 1.9');
core.exportVariable('GOROOT', installDir);
}
core.info(`Successfully set up Go version ${versionSpec}`);
} else {
core.info(
'[warning]go-version input was not specified. The action will try to use pre-installed version.'
@@ -76,6 +83,11 @@ export async function run() {
const goPath = await io.which('go');
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
const goEnvJson = readGoEnv(goPath);
if (goEnvJson) {
setGoEnvOutputs(goEnvJson);
}
if (cache && isCacheFeatureAvailable()) {
const packageManager = 'default';
@@ -113,6 +125,46 @@ export async function run() {
}
}
export function readGoEnv(goPath: string): GoEnv | undefined {
try {
const rawGoEnv = cp.execFileSync(goPath, ['env', '-json'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe']
});
const parsed: unknown = JSON.parse(rawGoEnv);
if (
typeof parsed !== 'object' ||
parsed === null ||
Array.isArray(parsed)
) {
throw new Error("'go env -json' did not return a JSON object");
}
return parsed as GoEnv;
} catch (error) {
core.info(
`Unable to read 'go env -json', the Go environment outputs will not be set: ${
(error as Error).message
}`
);
return undefined;
}
}
export function setGoEnvOutputs(goEnv: GoEnv): void {
for (const name of GO_ENV_OUTPUTS) {
core.setOutput(name, goEnv[name] ?? '');
}
core.setOutput(Outputs.GoBinPath, goEnv.GOBIN || goPathBin(goEnv));
}
function goPathBin(goEnv: GoEnv): string {
const goPath = (goEnv.GOPATH ?? '').split(path.delimiter)[0];
return goPath ? path.join(goPath, 'bin') : '';
}
export async function addBinToPath(): Promise<boolean> {
let added = false;
const g = await io.which('go');
@@ -163,6 +215,18 @@ function resolveVersionInput(): string {
}
if (version) {
const customBaseUrl =
core.getInput('go-download-base-url') ||
process.env['GO_DOWNLOAD_BASE_URL'];
if (
version.startsWith('go') &&
!customBaseUrl &&
!installer.isGoNativeVersion(version)
) {
throw new Error(
`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).`
);
}
return version;
}