Skip to content

Commit bfdd357

Browse files
Implement "check-latest" flag to check if pre-cached version is latest one (actions#186)
1 parent 44e2214 commit bfdd357

17 files changed

+4828
-3616
lines changed

.github/workflows/check-dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v2
2525

2626
- name: Set Node.js 12.x
27-
uses: actions/setup-node@v1
27+
uses: actions/setup-node@v2
2828
with:
2929
node-version: 12.x
3030

.github/workflows/licensed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install licensed
1919
run: |
2020
cd $RUNNER_TEMP
21-
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
21+
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
2222
sudo tar -xzf licensed.tar.gz
2323
sudo mv licensed /usr/local/bin/licensed
2424
- run: licensed status

.github/workflows/versions.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ jobs:
3333
run: __tests__/verify-go.sh ${{ matrix.go }}
3434
shell: bash
3535

36+
check-latest:
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
os: [ubuntu-latest, windows-latest, macos-latest]
42+
go-version: [1.16, 1.17]
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Setup Go and check latest
46+
uses: ./
47+
with:
48+
go-version: ${{ matrix.go-version }}
49+
check-latest: true
50+
- name: Verify Go
51+
run: go version
52+
3653
setup-versions-from-manifest:
3754
name: Setup ${{ matrix.go }} ${{ matrix.os }}
3855
runs-on: ${{ matrix.os }}

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
node-version: 12
2626
cache: npm
2727

28-
- name: npm install
29-
run: npm install
28+
- name: npm ci
29+
run: npm ci
3030

3131
- name: Lint
3232
run: npm run format-check

.licenses/npm/@actions/core.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/http-client-1.0.11.dep.yml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ This action sets up a go environment for use in actions by:
1616
The V2 offers:
1717
- Adds GOBIN to the PATH
1818
- Proxy Support
19-
- stable input
19+
- `stable` input
20+
- Check latest version
2021
- Bug Fixes (including issues around version matching and semver)
2122

22-
It will first check the local cache for a version match. If version is not found locally, It will pull it from `main` branch of [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository and on miss or failure, it will fall back to the previous behavior of download directly from [go dist](https://storage.googleapis.com/golang).
23+
The action will first check the local cache for a version match. If a version is not found locally, it will pull it from the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. On miss or failure, it will fall back to downloading directly from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use the [check-latest input](#check-latest-version).
2324

2425
Matching by [semver spec](https://github.com/npm/node-semver):
2526
```yaml
@@ -46,17 +47,36 @@ steps:
4647
4748
See [action.yml](action.yml)
4849
49-
Basic:
50+
## Basic:
5051
```yaml
5152
steps:
52-
- uses: actions/checkout@master
53+
- uses: actions/checkout@v2
54+
- uses: actions/setup-go@v2
55+
with:
56+
go-version: '1.16.1' # The Go version to download (if necessary) and use.
57+
- run: go run hello.go
58+
```
59+
60+
61+
## Check latest version:
62+
63+
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific Go version is always used.
64+
65+
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a Go version will then be downloaded. Set `check-latest` to `true` if you want the most up-to-date Go version to always be used.
66+
67+
> Setting `check-latest` to `true` has performance implications as downloading Go versions is slower than using cached versions.
68+
69+
```yaml
70+
steps:
71+
- uses: actions/checkout@v2
5372
- uses: actions/setup-go@v2
5473
with:
55-
go-version: '1.9.3' # The Go version to download (if necessary) and use.
74+
go-version: '1.14'
75+
check-latest: true
5676
- run: go run hello.go
5777
```
5878

59-
Matrix Testing:
79+
## Matrix Testing:
6080
```yaml
6181
jobs:
6282
build:

__tests__/data/versions-manifest.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
[
2+
{
3+
"version": "1.17.6",
4+
"stable": true,
5+
"release_url": "https://github.com/actions/go-versions/releases/tag/1.17.6-1668090892",
6+
"files": [
7+
{
8+
"filename": "go-1.17.6-darwin-x64.tar.gz",
9+
"arch": "x64",
10+
"platform": "darwin",
11+
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz"
12+
},
13+
{
14+
"filename": "go-1.17.6-linux-x64.tar.gz",
15+
"arch": "x64",
16+
"platform": "linux",
17+
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-linux-x64.tar.gz"
18+
},
19+
{
20+
"filename": "go-1.17.6-win32-x64.zip",
21+
"arch": "x64",
22+
"platform": "win32",
23+
"download_url": "https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-win32-x64.zip"
24+
}
25+
]
26+
},
227
{
328
"version": "1.12.17",
429
"stable": true,

0 commit comments

Comments
 (0)