Commit Graph

58 Commits

Author SHA1 Message Date
George Adams 8f19afcc70 feat: add go-download-base-url input for custom Go distributions (#721)
* feat: add go-download-base-url input for custom Go distributions

Add support for downloading Go from custom sources such as Microsoft Go
(aka.ms). Users can specify a custom download base URL via the
`go-download-base-url` input or the `GO_DOWNLOAD_BASE_URL` environment
variable (input takes precedence).

When a custom URL is provided, the action skips the GitHub-hosted
manifest and attempts to resolve versions from the custom URL's JSON
listing. If the listing is unavailable (as with aka.ms redirect links),
it falls back to constructing the download URL directly from the
version, platform, and architecture.

Usage:
  - uses: actions/setup-go@v6
    with:
      go-version: '1.25'
      go-download-base-url: 'https://aka.ms/golang/release/latest'

Changes:
- action.yml: add go-download-base-url optional input
- installer.ts: add getInfoFromDirectDownload() for URL construction
  fallback, thread custom URL through getGo/getInfoFromDist/findMatch
- main.ts: read new input and GO_DOWNLOAD_BASE_URL env var
- setup-go.test.ts: add 12 unit tests for custom URL behavior
- microsoft-validation.yml: add E2E workflow testing Microsoft build of Go
  across ubuntu/windows/macos with versions 1.24 and 1.25
- README.md: document new input with Microsoft build of Go examples

* run prettier

* fixup PR review

* revert cache-save

* fixup

* handle distinct cache

* skip json for known URL

* fix bug in JSON with custom URL
2026-03-16 12:43:44 -05:00
Priya Gupta a5f9b05d2d Update default Go module caching to use go.mod (#705)
* Update module cache to use go.mod as key

* Fix typo

* Revise breaking changes in README for V6

Updated breaking changes section with enhanced formatting and clarified toolchain management details.
2026-01-26 10:59:03 -06:00
mahabaleshwars f3787be646 Add comprehensive breaking changes documentation for v6 (#674)
* v6 documentation update

* v6 documentation update

* Readme file update

* update documentation

* documentation update

* update documentation

* Updated documentation

* Updated Documentation

* documentation update

* update documentation. action.yml and versions.yml

* Update documentation to organize go-version-file

* update v6 features and improve version patterns table

* Update documentation to specify supported syntaxes for `go-version` input
2025-11-19 09:40:16 -06:00
priya-kinthali faf52423ec Add support for .tool-versions file in setup-go, update workflow (#673)
* setup go in local

* add .tool-versions file support
2025-10-28 10:26:52 -05:00
Nicholas Ngai 7bc60db215 Fall back to downloading from go.dev/dl instead of storage.googleapis.com/golang (#665)
* Fall back to downloading from dl.google.com/go instead of storage.googleapis.com/golang

* Use go.dev/dl instead
2025-10-27 15:43:21 -05:00
Matthew Hughes 1d76b952eb Improve toolchain handling (#460)
* Configure environment to avoid toolchain installs

Force `go` to always use the local toolchain (i.e. the one the one that
shipped with the go command being run) via setting the `GOTOOLCHAIN`
environment variable to `local`[1]:

> When GOTOOLCHAIN is set to local, the go command always runs the
bundled Go toolchain.

This is how things are setup in the official Docker images (e.g.[2], see
also the discussion around that change[3]). The motivation behind this
is to:

* Reduce duplicate work: if the `toolchain` version in `go.mod` was
  greated than the `go` version, the version from the `go` directive
  would be installed, then Go would detect the `toolchain` version and
  additionally install that
* Avoid Unexpected behaviour: if you specify this action runs with some Go
  version (e.g. `1.21.0`) but your go.mod contains a `toolchain` or `go`
  directive for a newer version (e.g. `1.22.0`) then, without any other
  configuration/environment setup, any go commands will be run using go
  `1.22.0`

This will be a **breaking change** for some workflows. Given a `go.mod`
like:

    module proj

    go 1.22.0

Then running any `go` command, e.g. `go mod tidy`, in an environment
where only go versions before `1.22.0` were installed would previously
trigger a toolchain download of Go `1.22.0` and that version being used
to execute the command. With this change the above would error out with
something like:

> go: go.mod requires go >= 1.22.0 (running go 1.21.7;
GOTOOLCHAIN=local)

[1] https://go.dev/doc/toolchain#select
[2] https://github.com/docker-library/golang/blob/dae3405a325073e8ad7c8c378ebdf2540d8565c4/Dockerfile-linux.template#L163
[3] https://github.com/docker-library/golang/issues/472

* Prefer installing version from `toolchain` directive

Prefer this over the version from the `go` directive. Per the docs[1]

> The toolchain line declares a suggested toolchain to use with the
module or workspace

It seems reasonable to use this, since running this action in a
directory containing a `go.mod` (or `go.work`) suggests the user is
wishing to work _with the module or workspace_.

Link: https://go.dev/doc/toolchain#config [1]
Issue: https://github.com/actions/setup-go/issues/457

* squash! Configure environment to avoid toolchain installs

Only modify env if `GOTOOLCHAIN` is not set

* squash! Prefer installing version from `toolchain` directive

Avoid installing from `toolchain` if `GOTOOLCHAIN` is `local`, also
better regex for matching toolchain directive
2025-08-28 22:21:56 -05:00
Priya Gupta dca8468d37 Update self-hosted environment validation and bump undici version (#556)
* Fix self-hosted environment check

* Update isSelfHosted logic
2025-04-01 10:32:30 -05:00
Tobias 3041bf56c9 feat: fallback to "raw" endpoint for manifest when rate limit is reached (#496)
* feat: fallback to "raw" endpoint for manifest when rate limit is reached

* add information about raw access to the README

* prettier

* update cross-spawn to 7.0.6 to fix vulnerability
2024-11-25 12:37:21 -06:00
John Wesley Walker III 941977282c Revise isGhes logic (#511)
* Revise `isGhes` logic

* ran `npm run format`

* added unit test

* tweaked unit test

* ran `npm run format`
2024-10-21 11:56:08 -05:00
HarithaVattikuti 4ab57d7ea2 Fix versions check failure (#479)
* Update to latest Go versions

* Updated versions

* Update test data

* Update test data
2024-05-10 11:25:20 -05:00
Sergey Dolin 93397bea11 Fix Install on Windows is very slow (#393)
* Fix Install on Windows is very slow

* Add unit test

* Improve readability

* Add e2e test

* fix lint

* Fix unit tests

* Fix unit tests

* limit to github hosted runners

* test hosted version of go

* AzDev environment

* rename lnkSrc

* refactor conditions

* improve tests

* refactoring

* Fix e2e test

* improve isHosted readability
2023-08-03 14:33:56 +02:00
Ivan 7406d654ad Add and configure ESLint and update configuration for Prettier (#341)
* Turn on ESLint and update Prettier

* Update eslint config

* Update eslint config

* Update dependencies

* Update ESLint and Prettier configurations

* update package.json

* Update prettier command

* Update prettier config file

* Change CRLF to LF

* Update docs

* Update docs
2023-03-08 10:45:16 +02:00
Evgenii Korolevskii 17106403fa Allow to use only GOCACHE for cache (#305) 2022-12-19 11:22:17 +01:00
Jongwoo Han bb5ff97ab9 refactor: Use early return pattern to avoid nested conditions (#302) 2022-12-16 15:05:54 +01:00
Milos Pantic 38dbe75f81 Add stable and oldstable aliases (#300) 2022-12-12 10:58:49 +01:00
koba1t 7678c83214 add support gowork for go-version-file 2022-11-01 21:25:30 +09:00
n33pm c4a742cab1 fix(): cache resolve version input (#267) 2022-10-17 18:33:22 +02:00
Evgenii Korolevskii 57452eb902 fix debug lines in test 2022-09-08 13:24:00 +02:00
Evgenii Korolevskii 5547b9ed8d fix(cache): Not throw err if no cache folders 2022-09-08 13:18:41 +02:00
Milos Pantic 268d8c0ca0 Add support for arm32 go arch (#253) 2022-08-12 12:29:48 +02:00
Javier Romero e0dce94eb0 Use explicit filename when downloading Windows go package
Using the explicit filename for Windows is necessary to
satisfy `Expand-Archive`'s requirement on '.zip' extension.

Signed-off-by: Javier Romero <root@jromero.codes>
2022-07-28 19:01:53 -05:00
IvanZosimov b22fbbc292 Implementation of caching functionality for setup-go action (#228) 2022-05-25 12:07:29 +02:00
So Jomura 265edc1beb Add go-version-file option (#62) 2022-05-12 10:04:39 +02:00
Brian Cristante 193b404f8a Successfully set up (#231) 2022-05-03 08:43:40 -04:00
Nick 4a4352b330 Add 'go-version' Output (#85)
* Add go-version to action outputs

This provides the semver version of Go that has been installed. This is useful
if only a major or minor version has been provided as the input go-version
value.

* Convert version extraction to a function

Simplify how the version is extracted and add a simple test at the same
time.

Co-authored-by: Peter Mescalchin <peter@magnetikonline.com>
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>

Co-authored-by: Peter Mescalchin <peter@magnetikonline.com>
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2022-04-08 12:23:10 -04:00
Josh Gross 0c03929337 Remove duplicated spyOn 2022-03-14 12:32:36 -04:00
Josh Gross 802876f7c7 Fix formatting 2022-03-14 12:23:03 -04:00
Josh Gross 2a34c33bd7 Export GOROOT for versions < 1.9 2022-03-14 12:21:30 -04:00
Manuel Mendez 83124a14b6 Do not export GOROOT
This has not been necessary since [Go 1.9](https://go.dev/doc/go1.9#goroot) at
least (although clunky to do so then) but definitely not since
[Go 1.10](https://go.dev/doc/go1.10#goroot).

This is cargo culting code that is more than 2 years out of date and runs into
issues when multiple go versions are used in an action run.

Signed-off-by: Manuel Mendez <mmendez534@gmail.com>
2022-03-11 08:26:16 -05:00
Manuel Mendez ec07be593a Add test for export of GOROOT to env var
Signed-off-by: Manuel Mendez <mmendez534@gmail.com>
2022-03-09 08:56:55 -05:00
Dmitry Shibanov f6164bd8c8 Remove stable input and fix SemVer notation (#195) 2022-02-28 10:16:32 +03:00
Dmitry Shibanov bfdd3570ce Implement "check-latest" flag to check if pre-cached version is latest one (#186) 2022-02-09 14:59:04 +03:00
Dominik Honnef fdeec47002 Don't require relative paths to start with ./ or ../ (#98) 2021-12-17 18:47:05 +03:00
Thomas Boop 37335c7bb2 Swap to Environment Files (#76)
* Swap to env files
2020-10-01 10:45:00 -04:00
Dmitry Shibanov 1616116e1b Use GitHub releases to download Go versions. (#58) 2020-06-29 11:41:13 -04:00
Bryan MacFarlane e36ce1d6cf tabs or spaces 2020-03-30 10:46:01 -04:00
Bryan MacFarlane 0a62a734da another test case 2020-03-30 09:12:21 -04:00
Bryan MacFarlane 5156bc5dd3 lint 2020-03-27 20:21:13 -04:00
Bryan MacFarlane 7837b03976 more tests 2020-03-27 20:14:29 -04:00
Bryan MacFarlane 74c8095946 lint 2020-03-27 19:58:10 -04:00
Bryan MacFarlane 34223181a5 starting 2020-03-27 19:56:10 -04:00
Bryan MacFarlane 1c06f0e82e couple tests 2020-03-27 00:55:12 -04:00
Bryan MacFarlane 768458bd0b pre-release version and test 2020-02-10 19:18:01 -05:00
Bryan MacFarlane 43880314e9 CR feedback 2020-02-10 15:21:04 -05:00
Bryan MacFarlane 7d57e56d4d update tests 2020-02-09 19:05:20 -05:00
Bryan MacFarlane 6cb99a33d7 another test 2020-02-09 18:48:40 -05:00
Bryan MacFarlane 241a335117 mock os instead of system 2020-02-09 18:22:24 -05:00
Bryan MacFarlane 79b62adb05 another test and bugs 2020-02-09 18:09:15 -05:00
Bryan MacFarlane 7af81a4a65 bit of cleanup 2020-02-09 14:39:34 -05:00
Bryan MacFarlane f4b0281c15 mocked tests work with no internet 2020-02-09 09:25:20 -05:00