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

chore: make it possible to install older versions of the heroku cli #1

Merged
merged 9 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ]
55 changes: 52 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
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: "Install Heroku CLI"
shell: bash
run: "curl -f https://cli-assets.heroku.com/install-ubuntu.sh | sh"
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
curl -o "$wd/heroku.tar.gz" -sq "$url"

sudo -n rm -rf /usr/local/lib/heroku
sudo -n mkdir -p /usr/local/lib/heroku
sudo -n tar -C /usr/local/lib -xpzf "$wd/heroku.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
Loading