feat: add setup-gordon composite GitHub Action
- commit
- 5b7cfeab6e19bc83f008268f2505ae03cc212650
- author
- brice · · 2026-03-19 04:26 UTC
- committer
- brice · · 2026-03-19 04:26 UTC
- parent
- 3433b85
- signature
- unsigned
1 file · +78 -0
A .github/actions/setup-gordon/action.yml +78 -0
| @@ -0,0 +1,78 @@ | |||
| 1 | + | name: 'Setup Gordon' | |
| 2 | + | description: 'Install the Gordon CLI binary into the runner PATH' | |
| 3 | + | author: 'Gordon Contributors' | |
| 4 | + | ||
| 5 | + | branding: | |
| 6 | + | icon: 'download-cloud' | |
| 7 | + | color: 'blue' | |
| 8 | + | ||
| 9 | + | inputs: | |
| 10 | + | version: | |
| 11 | + | description: 'Gordon version to install (e.g. v2.0.0 or latest)' | |
| 12 | + | required: false | |
| 13 | + | default: 'latest' | |
| 14 | + | ||
| 15 | + | outputs: | |
| 16 | + | version: | |
| 17 | + | description: 'The version of Gordon that was installed' | |
| 18 | + | value: ${{ steps.install.outputs.version }} | |
| 19 | + | path: | |
| 20 | + | description: 'Path to the installed Gordon binary' | |
| 21 | + | value: ${{ steps.install.outputs.path }} | |
| 22 | + | ||
| 23 | + | runs: | |
| 24 | + | using: 'composite' | |
| 25 | + | steps: | |
| 26 | + | - name: Install Gordon | |
| 27 | + | id: install | |
| 28 | + | shell: bash | |
| 29 | + | run: | | |
| 30 | + | set -euo pipefail | |
| 31 | + | ||
| 32 | + | # Map RUNNER_OS to gordon OS identifier | |
| 33 | + | case "${RUNNER_OS}" in | |
| 34 | + | Linux) os="linux" ;; | |
| 35 | + | macOS) os="darwin" ;; | |
| 36 | + | *) echo "Unsupported OS: ${RUNNER_OS}" >&2; exit 1 ;; | |
| 37 | + | esac | |
| 38 | + | ||
| 39 | + | # Map RUNNER_ARCH to gordon arch identifier | |
| 40 | + | case "${RUNNER_ARCH}" in | |
| 41 | + | X64) arch="amd64" ;; | |
| 42 | + | ARM64) arch="arm64" ;; | |
| 43 | + | *) echo "Unsupported architecture: ${RUNNER_ARCH}" >&2; exit 1 ;; | |
| 44 | + | esac | |
| 45 | + | ||
| 46 | + | version="${{ inputs.version }}" | |
| 47 | + | ||
| 48 | + | # Resolve 'latest' to an actual tag via redirect URL | |
| 49 | + | if [ "${version}" = "latest" ]; then | |
| 50 | + | redirect_url="$(curl -fsSL -o /dev/null -w '%{redirect_url}' "https://github.com/bnema/gordon/releases/latest")" | |
| 51 | + | version="${redirect_url##*/}" | |
| 52 | + | if [ -z "${version}" ]; then | |
| 53 | + | echo "Failed to resolve latest Gordon version" >&2 | |
| 54 | + | exit 1 | |
| 55 | + | fi | |
| 56 | + | fi | |
| 57 | + | ||
| 58 | + | archive="gordon_${os}_${arch}.tar.gz" | |
| 59 | + | url="https://github.com/bnema/gordon/releases/download/${version}/${archive}" | |
| 60 | + | dest="/tmp/${archive}" | |
| 61 | + | install_path="/usr/local/bin/gordon" | |
| 62 | + | ||
| 63 | + | echo "Installing Gordon ${version} (${os}/${arch}) from ${url}" | |
| 64 | + | ||
| 65 | + | # Download the release archive | |
| 66 | + | curl -fsSL -o "${dest}" "${url}" | |
| 67 | + | ||
| 68 | + | # Extract just the gordon binary and clean up | |
| 69 | + | tar -xzf "${dest}" -C /usr/local/bin/ gordon | |
| 70 | + | rm -f "${dest}" | |
| 71 | + | ||
| 72 | + | # Make executable and verify | |
| 73 | + | chmod +x "${install_path}" | |
| 74 | + | gordon version | |
| 75 | + | ||
| 76 | + | # Set outputs | |
| 77 | + | echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
| 78 | + | echo "path=${install_path}" >> "${GITHUB_OUTPUT}" | |
| @@ -0,0 +1,78 @@ | |||||
| 1 | + | name: 'Setup Gordon' | |||
| 2 | + | description: 'Install the Gordon CLI binary into the runner PATH' | |||
| 3 | + | author: 'Gordon Contributors' | |||
| 4 | + | ||||
| 5 | + | branding: | |||
| 6 | + | icon: 'download-cloud' | |||
| 7 | + | color: 'blue' | |||
| 8 | + | ||||
| 9 | + | inputs: | |||
| 10 | + | version: | |||
| 11 | + | description: 'Gordon version to install (e.g. v2.0.0 or latest)' | |||
| 12 | + | required: false | |||
| 13 | + | default: 'latest' | |||
| 14 | + | ||||
| 15 | + | outputs: | |||
| 16 | + | version: | |||
| 17 | + | description: 'The version of Gordon that was installed' | |||
| 18 | + | value: ${{ steps.install.outputs.version }} | |||
| 19 | + | path: | |||
| 20 | + | description: 'Path to the installed Gordon binary' | |||
| 21 | + | value: ${{ steps.install.outputs.path }} | |||
| 22 | + | ||||
| 23 | + | runs: | |||
| 24 | + | using: 'composite' | |||
| 25 | + | steps: | |||
| 26 | + | - name: Install Gordon | |||
| 27 | + | id: install | |||
| 28 | + | shell: bash | |||
| 29 | + | run: | | |||
| 30 | + | set -euo pipefail | |||
| 31 | + | ||||
| 32 | + | # Map RUNNER_OS to gordon OS identifier | |||
| 33 | + | case "${RUNNER_OS}" in | |||
| 34 | + | Linux) os="linux" ;; | |||
| 35 | + | macOS) os="darwin" ;; | |||
| 36 | + | *) echo "Unsupported OS: ${RUNNER_OS}" >&2; exit 1 ;; | |||
| 37 | + | esac | |||
| 38 | + | ||||
| 39 | + | # Map RUNNER_ARCH to gordon arch identifier | |||
| 40 | + | case "${RUNNER_ARCH}" in | |||
| 41 | + | X64) arch="amd64" ;; | |||
| 42 | + | ARM64) arch="arm64" ;; | |||
| 43 | + | *) echo "Unsupported architecture: ${RUNNER_ARCH}" >&2; exit 1 ;; | |||
| 44 | + | esac | |||
| 45 | + | ||||
| 46 | + | version="${{ inputs.version }}" | |||
| 47 | + | ||||
| 48 | + | # Resolve 'latest' to an actual tag via redirect URL | |||
| 49 | + | if [ "${version}" = "latest" ]; then | |||
| 50 | + | redirect_url="$(curl -fsSL -o /dev/null -w '%{redirect_url}' "https://github.com/bnema/gordon/releases/latest")" | |||
| 51 | + | version="${redirect_url##*/}" | |||
| 52 | + | if [ -z "${version}" ]; then | |||
| 53 | + | echo "Failed to resolve latest Gordon version" >&2 | |||
| 54 | + | exit 1 | |||
| 55 | + | fi | |||
| 56 | + | fi | |||
| 57 | + | ||||
| 58 | + | archive="gordon_${os}_${arch}.tar.gz" | |||
| 59 | + | url="https://github.com/bnema/gordon/releases/download/${version}/${archive}" | |||
| 60 | + | dest="/tmp/${archive}" | |||
| 61 | + | install_path="/usr/local/bin/gordon" | |||
| 62 | + | ||||
| 63 | + | echo "Installing Gordon ${version} (${os}/${arch}) from ${url}" | |||
| 64 | + | ||||
| 65 | + | # Download the release archive | |||
| 66 | + | curl -fsSL -o "${dest}" "${url}" | |||
| 67 | + | ||||
| 68 | + | # Extract just the gordon binary and clean up | |||
| 69 | + | tar -xzf "${dest}" -C /usr/local/bin/ gordon | |||
| 70 | + | rm -f "${dest}" | |||
| 71 | + | ||||
| 72 | + | # Make executable and verify | |||
| 73 | + | chmod +x "${install_path}" | |||
| 74 | + | gordon version | |||
| 75 | + | ||||
| 76 | + | # Set outputs | |||
| 77 | + | echo "version=${version}" >> "${GITHUB_OUTPUT}" | |||
| 78 | + | echo "path=${install_path}" >> "${GITHUB_OUTPUT}" | |||