Skip to content

Commit

Permalink
Merge pull request #1 from instrumentl/chore/heroku-9.5.1
Browse files Browse the repository at this point in the history
chore: make it possible to install older versions of the heroku cli
  • Loading branch information
Roguelazer authored Dec 13, 2024
2 parents f32710a + b188939 commit d27f3db
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
pull_request:
branches: ['*']
push:
branches: ['main']
schedule:
- cron: "18 18 * * 1"

jobs:
selfcheck:
name: Test Action
strategy:
matrix:
runner: [ubuntu-22.04, ubuntu-24.04, ubuntu-latest]
version: [latest, 9.5.1, 10.0.0]
runs-on: ${{ matrix.runner }}
steps:
# To use this repository's private action,
# you must check out the repository
- name: Checkout
uses: actions/checkout@v4
- uses: ./
with:
version: ${{matrix.version}}
lint-with-pre-commit:
runs-on: ubuntu-24.04
name: Lint with pre-commit
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: instrumentl/pre-commit-action@v4
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: fix-byte-order-marker
- id: check-json
- id: check-merge-conflict
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.4.20
hooks:
- id: actionlint
additional_dependencies: [ pyflakes>=3.0.1, shellcheck-py>=0.9.0.5 ]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ This is a small GitHub action that runs the Heroku installer to set up the `hero

```yaml
- uses: instrumentl/setup-heroku@v1
with:
# Pass "latest" here to use whatever heroku has made the default; otherwise, you
# can pass a specific version (e.g., '9.5.1') which must exactly match a version
# string in the undocumented heroku-cli manifest
version: 'latest'
```
71 changes: 68 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,79 @@
name: 'Set up Heroku'
description: 'Set up the Heroku CLI'
inputs:
version:
description: "Version to install"
required: true
default: "latest"
runs:
using: "composite"
steps:
- name: "Ensure GPG installed"
- name: "Ensure dependencies are installed"
shell: bash
run: "if ! command -v gpg; then apt-get install --no-install-recommends gnupg2 ; fi"
run: |
if ! command -v gpg; then sudo -n apt-get install --no-install-recommends gnupg2 ; fi
if ! command -v curl; then sudo -n apt-get install --no-install-recommends curl ; fi
if ! command -v jq; then sudo -n apt-get install --no-install-recommends jq ; fi
- name: "Determine download url"
id: get_url
shell: bash
env:
version: ${{ inputs.version }}
run: |
set -euo pipefail
wd="$(mktemp -d)"
on_exit() {
status=$?
[[ -n "$wd" ]] && rm -rf "$wd"
exit $status
}
trap on_exit EXIT INT TERM
raw_machine="$(uname -m)"
if [[ "$raw_machine" = "aarch64" ]]; then
machine="arm"
elif [[ "$raw_machine" = "x86_64" ]]; then
machine="x64"
else
echo >&2 "Unhandled machine type $raw_machine"
exit 1
fi
curl -fqs -o "$wd/versions.json" "https://cli-assets.heroku.com/versions/heroku-linux-${machine}-tar-gz.json"
if [[ "$version" = "latest" ]]; then
url="https://cli-assets.heroku.com/channels/stable/heroku-linux-${machine}.tar.gz"
else
url="$(jq -cr '.["'"${version}"'"]' < "$wd/versions.json")"
fi
if [[ -z "$url" ]] || [[ "$url" = "null" ]]; then
echo >&2 "Could not find download for ${version} for ${machine}"
exit 1
fi
echo "url=${url}" >> "$GITHUB_OUTPUT"
- name: Cache CLI
id: cache_cli
uses: actions/cache@v4
with:
path: /tmp/heroku-${{ inputs.version }}.tar.gz
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.get_url.outputs.url }}
- name: "Download CLI"
shell: bash
if: steps.cache_cli.outputs.cache-hit != 'true'
run: |
curl -o "/tmp/heroku-${{ inputs.version }}.tar.gz" -sq "${{ steps.get_url.outputs.url }}"
- name: "Install Heroku CLI"
shell: bash
run: "curl -f https://cli-assets.heroku.com/install-ubuntu.sh | sh"
run: |
set -euo pipefail
sudo -n rm -rf /usr/local/lib/heroku
sudo -n mkdir -p /usr/local/lib/heroku
sudo -n tar -C /usr/local/lib -xpzf "/tmp/heroku-${{ inputs.version }}.tar.gz"
sudo -n rm -f /usr/local/bin/heroku
sudo -n ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku
/usr/local/lib/heroku/bin/node -v || sudo -n rm /usr/local/lib/heroku/bin/node
- name: "Test that it runs correctly"
run: "heroku version"
shell: bash

0 comments on commit d27f3db

Please sign in to comment.