Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version-resolver input #75

Closed
wants to merge 3 commits into from
Closed

Add version-resolver input #75

wants to merge 3 commits into from

Commits on Dec 16, 2020

  1. 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 actions#73
    bdd committed Dec 16, 2020
    Configuration menu
    Copy the full SHA
    b926061 View commit details
    Browse the repository at this point in the history
  2. Cannot reuse IGoVersionInfo from dist for manifest

    ...and vice versa.
    
    While here, also free versionInfo and versionSpec so we don't
    (un)intentionally overwrite them somewhere down below.
    bdd committed Dec 16, 2020
    Configuration menu
    Copy the full SHA
    47f75dd View commit details
    Browse the repository at this point in the history
  3. Canonicalize versions with makeSemver in getInfoFromDist

    While getInfoFromManifest stores semver versions in IGoVersionInfo
    struct, getInfoFromDist uses "goX.Y.Z" versions with "go" prefix. To
    make it consistent between two, convert versions from golang.org/dl
    version registry to semver versions.
    bdd committed Dec 16, 2020
    Configuration menu
    Copy the full SHA
    38f5ff1 View commit details
    Browse the repository at this point in the history