Commit Graph

23 Commits (b9260615dfecf329a17e94426990d164e22dbeeb)

Author SHA1 Message Date
Berk D. Demir b9260615df Add `version-resolver` input
Tool cache can be stale in GitHub and self-hosted runners. If supplied
`go-version` is a semver range--instead of an explicit version--it will
be tried through the version inventory in cache, first. Even though
the GitHub local copy or origin distribution may have newer versions
matching the passed range, as long as the cache can satisfy the range,
the latest version from cache will be used.

Introduce an optional input, `version-resolver`. If defined, it tries to
resolve the version spec against either GitHub local copy or Go's
canonical source of version manifest.
If the value of `version-resolver` is:
  - "manifest": the manifest file under @actions/go-version get used.
  - "dist": the manifest at https://golang.org/dl/?mode=json&include=all
  gets used.  It can take values

Example:
--------
- Latest Go Version: 1.15.2
- tool-cache has go1.15 (1.15.0), latest.

build.yml:
```
[...]
  - uses: actions/setup-go@v2
    with:
      go-version: '>=1.5 <2'
[...]
```

Although the intention of the user might be to get latest
version between "oldest Go 1.15.0, newest--not inclusive--Go 2.0", the
cache will match this range with Go 1.15.0.

build.yml (v2):
```
[...]
  - uses: actions/setup-go@v2
    with:
      go-version: '>=1.5 <2'
      version-resolver: 'manifest'
[...]
```

With supplied version resolver, the semver range will be checked against
the local GitHub version manifest from @actions/go-versions[1], and
match 1.15.2. Cache will be queried with the resolved version, instead
of the range. When the cache gets updated globally, next runs will use
the tool from the cache, instead of downloading locally or in case of
resolver 'dist', directly from Google.

[1]: https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json

Closes #73
5 years ago
Dmitry Shibanov 1616116e1b
Use GitHub releases to download Go versions. (#58) 5 years ago
Bryan MacFarlane 6613fc89fc go env block 5 years ago
Bryan MacFarlane 0dbc7e4965 toString 5 years ago
Bryan MacFarlane f32657ccaf output version of go it resolved to 5 years ago
Bryan MacFarlane cec6ecefb4 output version of go it resolved to 5 years ago
Bryan MacFarlane 1c06f0e82e couple tests 5 years ago
Bryan MacFarlane 262468e92f only needed to do once 5 years ago
Bryan MacFarlane 4e8106ca18 create profiles go dir if go installed but not exists 5 years ago
Bryan MacFarlane 93ddff5bef lint 5 years ago
Bryan MacFarlane 3d89e603f2 more debug 5 years ago
Bryan MacFarlane 1fea44b3f0 create bin if not under go env GOPATH 5 years ago
Bryan MacFarlane 3e014ec8a4 lint 5 years ago
Bryan MacFarlane 75899f8cdf add debug 5 years ago
Bryan MacFarlane 1fdcb9b160 oops 5 years ago
Bryan MacFarlane 3d0e3826ed prefer globally installed bin 5 years ago
Bryan MacFarlane 43880314e9 CR feedback 6 years ago
Bryan MacFarlane 7ea80d8e5f casing 6 years ago
Bryan MacFarlane a6a701e18e better user output 6 years ago
Bryan MacFarlane cfc658b90a format 6 years ago
Bryan MacFarlane 3c844703e7 bugs 6 years ago
Bryan MacFarlane dc575ee3b3 format 6 years ago
Bryan MacFarlane 4282769cc0 starting v2 and proxy support 6 years ago