mirror of
https://github.com/actions/setup-go.git
synced 2025-05-21 04:09:43 +08:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d35c59abb0 | ||
|
29694d72cd | ||
|
78535dd5f2 | ||
|
bb65d8857b | ||
|
7f17e836c0 | ||
|
dca8468d37 | ||
|
691cc3533f | ||
|
0aaccfd150 | ||
|
c4c1141886 | ||
|
5a083d0e9a | ||
|
1d82324e53 | ||
|
f111f3307d | ||
|
3d10edb4c2 | ||
|
43e13893cf | ||
|
f81f022188 | ||
|
3041bf56c9 | ||
|
41dfa10bad | ||
|
941977282c | ||
|
d60b41a563 | ||
|
e09f57f6a9 | ||
|
df1a11710e | ||
|
49582f6476 | ||
|
b26d40294f | ||
|
0a12ed9d6a | ||
|
4ab57d7ea2 | ||
|
cdcb360436 | ||
|
99176a8f9a | ||
|
be1aa1186e | ||
|
6c1fd22b67 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -7,7 +7,7 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||||
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -5,7 +5,7 @@ title: ''
|
|||||||
labels: feature request, needs triage
|
labels: feature request, needs triage
|
||||||
assignees: ''
|
assignees: ''
|
||||||
---
|
---
|
||||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||||
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
22
.github/dependabot.yml
vendored
Normal file
22
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
# Enable version updates for npm
|
||||||
|
- package-ecosystem: 'npm'
|
||||||
|
# Look for `package.json` and `lock` files in the `root` directory
|
||||||
|
directory: '/'
|
||||||
|
# Check the npm registry for updates every day (weekdays)
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
||||||
|
|
||||||
|
# Enable version updates for GitHub Actions
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
# Workflow files stored in the default location of `.github/workflows`
|
||||||
|
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: 'Publish Immutable Action Version'
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checking out
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Publish
|
||||||
|
id: publish
|
||||||
|
uses: actions/publish-immutable-action@v0.0.4
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
uses: actions/publish-action@v0.2.2
|
uses: actions/publish-action@v0.3.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
55
.github/workflows/versions.yml
vendored
55
.github/workflows/versions.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go Stable
|
- name: Setup Go Stable
|
||||||
@ -33,7 +33,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go oldStable
|
- name: Setup Go oldStable
|
||||||
@ -48,12 +48,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
version: [stable, oldstable]
|
version: [stable, oldstable]
|
||||||
architecture: [x64, x32]
|
architecture: [x64, x32]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
architecture: x32
|
architecture: x32
|
||||||
|
- os: macos-13
|
||||||
|
architecture: x32
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
|
||||||
@ -70,8 +72,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.17, 1.18, 1.19]
|
go: [1.21.13, 1.22.8, 1.23.2]
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
go: 1.20.14
|
||||||
|
exclude:
|
||||||
|
- os: windows-latest
|
||||||
|
go: 1.23.2
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -90,8 +98,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
go-version: [1.16, 1.17]
|
go-version: ['1.20', '1.21', '1.22', '1.23']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
@ -107,7 +115,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
@ -115,7 +123,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version-file: __tests__/data/go.mod
|
go-version-file: __tests__/data/go.mod
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh 1.14
|
run: __tests__/verify-go.sh 1.20.14
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
go-version-file-with-gowork:
|
go-version-file-with-gowork:
|
||||||
@ -123,7 +131,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
@ -131,17 +139,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version-file: __tests__/data/go.work
|
go-version-file: __tests__/data/go.work
|
||||||
- name: verify go
|
- name: verify go
|
||||||
run: __tests__/verify-go.sh 1.19
|
run: __tests__/verify-go.sh 1.21
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-versions-from-manifest:
|
setup-versions-from-manifest:
|
||||||
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.12.16, 1.13.11, 1.14.3]
|
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -156,13 +163,12 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-versions-from-dist:
|
setup-versions-from-dist:
|
||||||
name: Setup ${{ matrix.go }} ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [windows-latest, ubuntu-latest, macos-13]
|
||||||
go: [1.9, 1.8.6]
|
go: [1.11.12]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -181,14 +187,23 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
||||||
go-version: [1.16, 1.17]
|
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
||||||
|
include:
|
||||||
|
- os: macos-latest
|
||||||
|
architecture: arm64
|
||||||
|
- os: ubuntu-latest
|
||||||
|
architecture: x64
|
||||||
|
- os: windows-latest
|
||||||
|
architecture: x64
|
||||||
|
- os: macos-13
|
||||||
|
architecture: x64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
architecture: x64
|
architecture: ${{ matrix.architecture }}
|
||||||
- name: Verify Go
|
- name: Verify Go
|
||||||
run: go version
|
run: go version
|
||||||
|
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/core.dep.yml
generated
BIN
.licenses/npm/@actions/core.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
BIN
.licenses/npm/@actions/http-client.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Normal file
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
BIN
.licenses/npm/@types/node.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lru-cache.dep.yml
generated
BIN
.licenses/npm/lru-cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/typescript.dep.yml
generated
Normal file
BIN
.licenses/npm/typescript.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/yallist.dep.yml
generated
BIN
.licenses/npm/yallist.dep.yml
generated
Binary file not shown.
77
README.md
77
README.md
@ -8,6 +8,14 @@ This action sets up a go environment for use in actions by:
|
|||||||
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
|
- Optionally downloading and caching a version of Go by version and adding to `PATH`.
|
||||||
- Registering problem matchers for error output.
|
- Registering problem matchers for error output.
|
||||||
|
|
||||||
|
# V5
|
||||||
|
|
||||||
|
The V5 edition of the action offers:
|
||||||
|
|
||||||
|
- Upgraded Node.js runtime from node16 to node20
|
||||||
|
|
||||||
|
See full release notes on the [releases page](https://github.com/actions/setup-go/releases).
|
||||||
|
|
||||||
# V4
|
# V4
|
||||||
|
|
||||||
The V4 edition of the action offers:
|
The V4 edition of the action offers:
|
||||||
@ -43,7 +51,7 @@ Matching by [semver spec](https://github.com/npm/node-semver):
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -52,7 +60,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '>=1.17.0'
|
go-version: '>=1.17.0'
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -62,15 +70,16 @@ steps:
|
|||||||
>
|
>
|
||||||
> ```yaml
|
> ```yaml
|
||||||
> go-version: '1.20'
|
> go-version: '1.20'
|
||||||
> ```
|
> ```
|
||||||
>
|
>
|
||||||
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.
|
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.
|
||||||
|
|
||||||
Matching an unstable pre-release:
|
Matching an unstable pre-release:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -79,7 +88,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -94,7 +103,7 @@ See [action.yml](action.yml)
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
go-version: '1.16.1' # The Go version to download (if necessary) and use.
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
@ -115,7 +124,7 @@ want the most up-to-date Go version to always be used.
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.14'
|
go-version: '1.14'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
@ -136,7 +145,7 @@ set to `true`
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 'stable'
|
go-version: 'stable'
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
@ -145,7 +154,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 'oldstable'
|
go-version: 'oldstable'
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
@ -168,7 +177,7 @@ If some problem that prevents success caching happens then the action issues the
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.17'
|
go-version: '1.17'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
@ -182,11 +191,13 @@ steps:
|
|||||||
|
|
||||||
## Getting go version from the go.mod file
|
## Getting go version from the go.mod file
|
||||||
|
|
||||||
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be
|
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project.
|
||||||
used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the
|
|
||||||
latest available patch version sequentially in the runner's directory with the cached tools, in
|
The `go` directive in `go.mod` can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`).
|
||||||
the [versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go
|
If a patch version is specified, that specific patch version will be used.
|
||||||
servers.
|
If no patch version is specified, it will search for the latest available patch version in the cache,
|
||||||
|
[versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the
|
||||||
|
[official Go language website](https://golang.org/dl/?mode=json&include=all), in that order.
|
||||||
|
|
||||||
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
|
||||||
> The action will search for the `go.mod` file relative to the repository root
|
> The action will search for the `go.mod` file relative to the repository root
|
||||||
@ -194,7 +205,7 @@ If both the `go-version` and the `go-version-file` inputs are provided then the
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'path/to/go.mod'
|
go-version-file: 'path/to/go.mod'
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -213,7 +224,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
- run: go run hello.go
|
- run: go run hello.go
|
||||||
@ -231,31 +242,35 @@ documentation.
|
|||||||
|
|
||||||
## Using `setup-go` on GHES
|
## Using `setup-go` on GHES
|
||||||
|
|
||||||
`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Go
|
`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled.
|
||||||
distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions)
|
When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance).
|
||||||
on github.com (outside of the appliance). These calls to `actions/go-versions` are made via unauthenticated requests,
|
|
||||||
which are limited
|
|
||||||
to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If
|
|
||||||
more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks
|
|
||||||
like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly
|
|
||||||
from https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token.
|
|
||||||
|
|
||||||
To get a higher rate limit, you
|
These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
|
||||||
can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token`
|
If more requests are made within the time frame, then the action leverages the `raw API` to retrieve the version-manifest. This approach does not impose a rate limit and hence facilitates unrestricted consumption. This is particularly beneficial for GHES runners, which often share the same IP, to avoid the quick exhaustion of the unauthenticated rate limit.
|
||||||
input for the action:
|
If that fails as well the action will try to download versions directly from https://storage.googleapis.com/golang.
|
||||||
|
|
||||||
|
If that fails as well you can get a higher rate limit with [generating a personal access token on github.com](https://github.com/settings/tokens/new) and passing it as the `token` input to the action:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
||||||
go-version: '1.18'
|
go-version: '1.18'
|
||||||
```
|
```
|
||||||
|
|
||||||
If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the
|
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.
|
||||||
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)"
|
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.
|
||||||
|
|
||||||
|
## Recommended permissions
|
||||||
|
|
||||||
|
When using the `setup-go` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
permissions:
|
||||||
|
contents: read # access to check out code and install dependencies
|
||||||
|
```
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => {
|
|||||||
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isGhes', () => {
|
||||||
|
const pristineEnv = process.env;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...pristineEnv};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = pristineEnv;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
|
||||||
|
delete process.env['GITHUB_SERVER_URL'];
|
||||||
|
expect(cacheUtils.isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
expect(cacheUtils.isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
||||||
|
expect(cacheUtils.isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
||||||
|
expect(cacheUtils.isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
||||||
|
expect(cacheUtils.isGhes()).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module example.com/mymodule
|
module example.com/mymodule
|
||||||
|
|
||||||
go 1.14
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
example.com/othermodule v1.2.3
|
example.com/othermodule v1.2.3
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
go 1.19
|
go 1.21
|
||||||
|
|
||||||
use .
|
use .
|
||||||
|
@ -7,6 +7,7 @@ import osm, {type} from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as im from '../src/installer';
|
import * as im from '../src/installer';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
|
||||||
import goJsonData from './data/golang-dl.json';
|
import goJsonData from './data/golang-dl.json';
|
||||||
import matchers from '../matchers.json';
|
import matchers from '../matchers.json';
|
||||||
@ -46,6 +47,7 @@ describe('setup-go', () => {
|
|||||||
let execSpy: jest.SpyInstance;
|
let execSpy: jest.SpyInstance;
|
||||||
let getManifestSpy: jest.SpyInstance;
|
let getManifestSpy: jest.SpyInstance;
|
||||||
let getAllVersionsSpy: jest.SpyInstance;
|
let getAllVersionsSpy: jest.SpyInstance;
|
||||||
|
let httpmGetJsonSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
||||||
@ -90,6 +92,9 @@ describe('setup-go', () => {
|
|||||||
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
getAllVersionsSpy = jest.spyOn(im, 'getManifest');
|
getAllVersionsSpy = jest.spyOn(im, 'getManifest');
|
||||||
|
|
||||||
|
// httm
|
||||||
|
httpmGetJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
// io
|
// io
|
||||||
whichSpy = jest.spyOn(io, 'which');
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
existsSpy = jest.spyOn(fs, 'existsSync');
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
@ -151,6 +156,21 @@ describe('setup-go', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return manifest from repo', async () => {
|
||||||
|
const manifest = await im.getManifest(undefined);
|
||||||
|
expect(manifest).toEqual(goTestManifest);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return manifest from raw URL if repo fetch fails', async () => {
|
||||||
|
getManifestSpy.mockRejectedValue(new Error('Fetch failed'));
|
||||||
|
httpmGetJsonSpy.mockResolvedValue({
|
||||||
|
result: goTestManifest
|
||||||
|
});
|
||||||
|
const manifest = await im.getManifest(undefined);
|
||||||
|
expect(httpmGetJsonSpy).toHaveBeenCalled();
|
||||||
|
expect(manifest).toEqual(goTestManifest);
|
||||||
|
});
|
||||||
|
|
||||||
it('can find 1.9 from manifest on linux', async () => {
|
it('can find 1.9 from manifest on linux', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
@ -790,6 +810,9 @@ describe('setup-go', () => {
|
|||||||
getManifestSpy.mockImplementation(() => {
|
getManifestSpy.mockImplementation(() => {
|
||||||
throw new Error('Unable to download manifest');
|
throw new Error('Unable to download manifest');
|
||||||
});
|
});
|
||||||
|
httpmGetJsonSpy.mockRejectedValue(
|
||||||
|
new Error('Unable to download manifest from raw URL')
|
||||||
|
);
|
||||||
getAllVersionsSpy.mockImplementationOnce(() => undefined);
|
getAllVersionsSpy.mockImplementationOnce(() => undefined);
|
||||||
|
|
||||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
52
__tests__/utils.test.ts
Normal file
52
__tests__/utils.test.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import {isSelfHosted} from '../src/utils';
|
||||||
|
|
||||||
|
describe('utils', () => {
|
||||||
|
describe('isSelfHosted', () => {
|
||||||
|
let AGENT_ISSELFHOSTED: string | undefined;
|
||||||
|
let RUNNER_ENVIRONMENT: string | undefined;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
AGENT_ISSELFHOSTED = process.env['AGENT_ISSELFHOSTED'];
|
||||||
|
delete process.env['AGENT_ISSELFHOSTED'];
|
||||||
|
RUNNER_ENVIRONMENT = process.env['RUNNER_ENVIRONMENT'];
|
||||||
|
delete process.env['RUNNER_ENVIRONMENT'];
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (AGENT_ISSELFHOSTED === undefined) {
|
||||||
|
delete process.env['AGENT_ISSELFHOSTED'];
|
||||||
|
} else {
|
||||||
|
process.env['AGENT_ISSELFHOSTED'] = AGENT_ISSELFHOSTED;
|
||||||
|
}
|
||||||
|
if (RUNNER_ENVIRONMENT === undefined) {
|
||||||
|
delete process.env['RUNNER_ENVIRONMENT'];
|
||||||
|
} else {
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] = RUNNER_ENVIRONMENT;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isSelfHosted should be true if no environment variables set', () => {
|
||||||
|
expect(isSelfHosted()).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isSelfHosted should be true if environment variable is not set to denote GitHub hosted', () => {
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] = 'some';
|
||||||
|
expect(isSelfHosted()).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isSelfHosted should be true if environment variable set to denote Azure Pipelines self hosted', () => {
|
||||||
|
process.env['AGENT_ISSELFHOSTED'] = '1';
|
||||||
|
expect(isSelfHosted()).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isSelfHosted should be false if environment variable set to denote GitHub hosted', () => {
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] = 'github-hosted';
|
||||||
|
expect(isSelfHosted()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isSelfHosted should be false if environment variable is not set to denote Azure Pipelines self hosted', () => {
|
||||||
|
process.env['AGENT_ISSELFHOSTED'] = 'some';
|
||||||
|
expect(isSelfHosted()).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
7906
dist/cache-save/index.js
vendored
7906
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load Diff
9003
dist/setup/index.js
vendored
9003
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -6,13 +6,13 @@ We have prepared a short guide so that the process of making your contribution i
|
|||||||
|
|
||||||
## How can I contribute...
|
## How can I contribute...
|
||||||
|
|
||||||
* [Contribute Documentation:green_book:](#contribute-documentation)
|
* [Contribute Documentation :green_book:](#contribute-documentation)
|
||||||
|
|
||||||
* [Contribute Code :computer:](#contribute-code)
|
* [Contribute Code :computer:](#contribute-code)
|
||||||
|
|
||||||
* [Provide Support on Issues:pencil:](#provide-support-on-issues)
|
* [Provide Support on Issues :pencil:](#provide-support-on-issues)
|
||||||
|
|
||||||
* [Review Pull Requests:mag:](#review-pull-requests)
|
* [Review Pull Requests :mag:](#review-pull-requests)
|
||||||
|
|
||||||
## Contribute documentation
|
## Contribute documentation
|
||||||
|
|
||||||
@ -113,4 +113,4 @@ Another great way to contribute is pull request reviews. Please, be extra kind:
|
|||||||
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
||||||
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
||||||
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
||||||
- Submit your review, which may include comments, an approval, or a changes request
|
- Submit your review, which may include comments, an approval, or a changes request
|
||||||
|
1023
package-lock.json
generated
1023
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -25,31 +25,31 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.2.1",
|
"@actions/cache": "^4.0.3",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/glob": "^0.4.0",
|
"@actions/glob": "^0.5.0",
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.2.1",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"semver": "^7.5.4"
|
"semver": "^7.6.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.10",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^20.10.3",
|
"@types/node": "^20.11.28",
|
||||||
"@types/semver": "^7.5.6",
|
"@types/semver": "^7.5.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||||
"@typescript-eslint/parser": "^5.54.0",
|
"@typescript-eslint/parser": "^8.31.1",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^28.11.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"nock": "^10.0.6",
|
"nock": "^10.0.6",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^2.8.4",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.3.2",
|
||||||
"typescript": "^5.3.2"
|
"typescript": "^5.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ export const restoreCache = async (
|
|||||||
) => {
|
) => {
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
|
const arch = process.arch;
|
||||||
|
|
||||||
const cachePaths = await getCacheDirectoryPath(packageManagerInfo);
|
const cachePaths = await getCacheDirectoryPath(packageManagerInfo);
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ export const restoreCache = async (
|
|||||||
|
|
||||||
const linuxVersion =
|
const linuxVersion =
|
||||||
process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : '';
|
process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : '';
|
||||||
const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`;
|
const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`;
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
@ -63,7 +63,13 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
);
|
);
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
|
||||||
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
|
||||||
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
|
@ -6,7 +6,12 @@ import * as httpm from '@actions/http-client';
|
|||||||
import * as sys from './system';
|
import * as sys from './system';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {StableReleaseAlias} from './utils';
|
import {StableReleaseAlias, isSelfHosted} from './utils';
|
||||||
|
|
||||||
|
const MANIFEST_REPO_OWNER = 'actions';
|
||||||
|
const MANIFEST_REPO_NAME = 'go-versions';
|
||||||
|
const MANIFEST_REPO_BRANCH = 'main';
|
||||||
|
const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
|
||||||
|
|
||||||
type InstallationType = 'dist' | 'manifest';
|
type InstallationType = 'dist' | 'manifest';
|
||||||
|
|
||||||
@ -175,11 +180,7 @@ async function cacheWindowsDir(
|
|||||||
if (os.platform() !== 'win32') return false;
|
if (os.platform() !== 'win32') return false;
|
||||||
|
|
||||||
// make sure the action runs in the hosted environment
|
// make sure the action runs in the hosted environment
|
||||||
if (
|
if (isSelfHosted()) return false;
|
||||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
|
||||||
process.env['AGENT_ISSELFHOSTED'] === '1'
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
||||||
if (!defaultToolCacheRoot) return false;
|
if (!defaultToolCacheRoot) return false;
|
||||||
@ -274,8 +275,78 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
|||||||
return extPath;
|
return extPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getManifest(auth: string | undefined) {
|
function isIToolRelease(obj: any): obj is tc.IToolRelease {
|
||||||
return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
return (
|
||||||
|
typeof obj === 'object' &&
|
||||||
|
obj !== null &&
|
||||||
|
typeof obj.version === 'string' &&
|
||||||
|
typeof obj.stable === 'boolean' &&
|
||||||
|
Array.isArray(obj.files) &&
|
||||||
|
obj.files.every(
|
||||||
|
(file: any) =>
|
||||||
|
typeof file.filename === 'string' &&
|
||||||
|
typeof file.platform === 'string' &&
|
||||||
|
typeof file.arch === 'string' &&
|
||||||
|
typeof file.download_url === 'string'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getManifest(
|
||||||
|
auth: string | undefined
|
||||||
|
): Promise<tc.IToolRelease[]> {
|
||||||
|
try {
|
||||||
|
const manifest = await getManifestFromRepo(auth);
|
||||||
|
if (
|
||||||
|
Array.isArray(manifest) &&
|
||||||
|
manifest.length &&
|
||||||
|
manifest.every(isIToolRelease)
|
||||||
|
) {
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
let errorMessage =
|
||||||
|
'An unexpected error occurred while fetching the manifest.';
|
||||||
|
if (
|
||||||
|
typeof manifest === 'object' &&
|
||||||
|
manifest !== null &&
|
||||||
|
'message' in manifest
|
||||||
|
) {
|
||||||
|
errorMessage = (manifest as {message: string}).message;
|
||||||
|
}
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
} catch (err) {
|
||||||
|
core.debug('Fetching the manifest via the API failed.');
|
||||||
|
if (err instanceof Error) {
|
||||||
|
core.debug(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await getManifestFromURL();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getManifestFromRepo(
|
||||||
|
auth: string | undefined
|
||||||
|
): Promise<tc.IToolRelease[]> {
|
||||||
|
core.debug(
|
||||||
|
`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`
|
||||||
|
);
|
||||||
|
return tc.getManifestFromRepo(
|
||||||
|
MANIFEST_REPO_OWNER,
|
||||||
|
MANIFEST_REPO_NAME,
|
||||||
|
auth,
|
||||||
|
MANIFEST_REPO_BRANCH
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getManifestFromURL(): Promise<tc.IToolRelease[]> {
|
||||||
|
core.debug('Falling back to fetching the manifest using raw URL.');
|
||||||
|
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
||||||
|
const response = await http.getJson<tc.IToolRelease[]>(MANIFEST_URL);
|
||||||
|
if (!response.result) {
|
||||||
|
throw new Error(`Unable to get manifest from ${MANIFEST_URL}`);
|
||||||
|
}
|
||||||
|
return response.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInfoFromManifest(
|
export async function getInfoFromManifest(
|
||||||
|
10
src/utils.ts
10
src/utils.ts
@ -2,3 +2,13 @@ export enum StableReleaseAlias {
|
|||||||
Stable = 'stable',
|
Stable = 'stable',
|
||||||
OldStable = 'oldstable'
|
OldStable = 'oldstable'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isSelfHosted = (): boolean =>
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||||
|
(process.env['AGENT_ISSELFHOSTED'] === '1' ||
|
||||||
|
process.env['AGENT_ISSELFHOSTED'] === undefined);
|
||||||
|
/* the above is simplified from:
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' && process.env['AGENT_ISSELFHOSTED'] === '1'
|
||||||
|
||
|
||||||
|
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' && process.env['AGENT_ISSELFHOSTED'] === undefined
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user