Skip to content

Commit

Permalink
fix: install supported Terramate system/arch.
Browse files Browse the repository at this point in the history
Signed-off-by: i4k <[email protected]>
  • Loading branch information
i4ki committed Sep 13, 2024
1 parent b5d1461 commit b733b79
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,44 @@ defaults:
run:
shell: bash

permissions:
contents: read

jobs:
simple:
name: Terramate latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- if: runner.os == 'macOS'
name: "install jq on macos"
run: brew install jq

- name: Install latest Terramate
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate execution
run: terramate version

asdf:
name: Terramate asdf
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
version: [0.4.2, 0.4.3, skip]
steps:
- name: Checkout
uses: actions/checkout@v4

- if: runner.os == 'macOS'
name: "install jq on macos"
run: brew install jq

- name: Prepare asdf config
if: ${{ matrix.version != 'skip' }}
run: echo "terramate ${{ matrix.version}}" >.tool-versions
Expand All @@ -44,6 +58,8 @@ jobs:

- name: Install asdf Terramate
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate execution
run: terramate version
Expand All @@ -60,9 +76,10 @@ jobs:

wrapper:
name: Terramate with wrapper
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
version: [0.4.3, latest]
steps:
- name: Checkout
Expand All @@ -72,6 +89,8 @@ jobs:
uses: ./
with:
version: ${{ matrix.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate execution - ${{ matrix.version }}
run: terramate version
Expand All @@ -87,9 +106,10 @@ jobs:

no-wrapper:
name: Terramate without wrapper
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
version: [0.4.3, latest]
steps:
- name: Checkout
Expand All @@ -100,6 +120,8 @@ jobs:
with:
version: ${{ matrix.version }}
use_wrapper: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate execution - ${{ matrix.version }}
run: terramate version
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ The [`terramate-io/terramate-action`] is a GitHub composite action that sets up
- It installs a wrapper script by default so that calls to `terramate` binary will expose GitHub Action outputs to access the `stderr`, `stderr`, and the `exitcode` of the `terramate` execution.
- It allows you to configure a default [Terramate Cloud] organization to use Terramate Cloud Features like Drift Detection and Stack Health Information.

## Compatbility
## Compatibility

The action currently only supports `ubuntu` runners.
The action currently only supports `ubuntu` and `macos` runners.
Please open an issue, if more runner support is required.

## Usage
Expand Down
26 changes: 24 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ get_latest_version() {
echo >&2 "latest version: Getting latest Terramate release information from GitHub Releases"

latest_url="https://api.github.com/repos/terramate-io/terramate/releases/latest"
latest_json=$(curl -s "${latest_url}")
latest_json=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${latest_url}")
tag_version=$(jq -r .tag_name <<<"${latest_json}")

if [ -z "${tag_version}" ] || [ "${tag_version}" == "null" ] ; then
Expand Down Expand Up @@ -86,7 +86,29 @@ install() {
tmpdir=$(mktemp -d)
echo >&2 "install: Created tmp directory at ${tmpdir}"

url="https://github.com/terramate-io/terramate/releases/download/v${version}/terramate_${version}_linux_x86_64.tar.gz"
system=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m)

if ! [[ "${system}" =~ ^(linux|darwin)$ ]]; then
echo >&2 "install: Unsupported system ${system}."
exit 1
fi

case "${arch}" in
x86_64|x64) arch=x86_64 ;;
aarch64|arm64) arch=arm64 ;;
i386|i686) arch=i386 ;;
*) echo >&2 "install: Unsupported architecture ${arch}." && exit 1 ;;
esac

if [ "${system}" == "darwin" ] && [ "${arch}" == "i386" ] ; then
echo >&2 "install: Unsupported architecture: darwin/i386"
exit 1
fi

echo >&2 "install: Downloading terramate binary for ${system}/${arch}"

url="https://github.com/terramate-io/terramate/releases/download/v${version}/terramate_${version}_${system}_${arch}.tar.gz"

status=$(curl -w "%{http_code}" -o "${tmpdir}/terramate.tar.gz" -L "${url}")
if [ "${status}" != "200" ] ; then
Expand Down

0 comments on commit b733b79

Please sign in to comment.