Skip to content

Add support for specifying release constraints for GitHub releases

Pre-release
Pre-release
Compare
Choose a tag to compare
@radu-matei radu-matei released this 02 Sep 22:34

This release introduces a new execution mode for the action - providing a URL template and a semver version or range to be selected from GitHub releases. In this mode, the action iterates through the GitHub releases to find the latest version that satisfies the version (or range) constraint, constructs the download URL, and adds the tool to the path.

Example - a cross-platform action that selects the latest Helm version that satisfies the ^3.1.2 release constraint - meaning it selects any minor and patch update, or, in other words, the latest v3.x.x version:

jobs:
  configurator:
    runs-on: ${{ matrix.config.os }}
    strategy:
      matrix:
        config:
          - {
              os: "ubuntu-latest",
              urlTemplate: "https://get.helm.sh/helm-{{version}}-linux-amd64.tar.gz",
              name: "h3",
              pathInArchive: "linux-amd64/helm",
            }
          - {
              os: "windows-latest",
              urlTemplate: "https://get.helm.sh/helm-{{version}}-windows-amd64.zip",
              name: "h3.exe",
              pathInArchive: "windows-amd64/helm.exe",
            }
    steps:
      - uses: engineerd/configurator@v0.0.3
        with:
          name: ${{ matrix.config.name }}
          pathInArchive: ${{ matrix.config.pathInArchive }}
          fromGitHubReleases: "true"
          repo: "helm/helm"
          version: "^v3.1.2"
          urlTemplate: ${{ matrix.config.urlTemplate }}
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Testing
        run: |
          h3 --help

Instead of a version or range, latest can be used to force the action to always select the latest GitHub release (note that this can change major versions and introduce breaking changes!):

jobs:
  kind:
    runs-on: ubuntu-latest
    steps:
      - uses: engineerd/configurator@v0.0.3
        with:
          name: "kind"
          fromGitHubReleases: "true"
          repo: "kubernetes-sigs/kind"
          urlTemplate: "https://github.com/kubernetes-sigs/kind/releases/download/{{version}}/kind-linux-amd64"
          version: "latest"
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Testing
        run: |
          kind --help