From f573758b54e657c91cf9762aa8c2ae85c244808e Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Wed, 28 Feb 2024 15:06:41 -0800 Subject: [PATCH] CI: Use a script to get the latest version of baton. (#16) --- .github/workflows/ci.yaml | 2 +- scripts/get-baton.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 scripts/get-baton.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 25bcb3e..d645b26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,7 +66,7 @@ jobs: # PGPASSWORD: secretpassword # run: psql -h localhost --user postgres -f test/ci.sql - name: Install baton - run: wget https://github.com/ConductorOne/baton/releases/download/v0.1.2/baton-v0.1.2-linux-amd64.tar.gz && tar xzf baton-v0.1.2-linux-amd64.tar.gz && mv baton /usr/local/bin + run: ./scripts/get-baton.sh && mv baton /usr/local/bin - name: Build baton-postgresql run: go build ./cmd/baton-postgresql - name: Run baton-postgresql diff --git a/scripts/get-baton.sh b/scripts/get-baton.sh new file mode 100755 index 0000000..5b4d755 --- /dev/null +++ b/scripts/get-baton.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) +if [ "${ARCH}" = "x86_64" ]; then + ARCH="amd64" +fi + +RELEASES_URL="https://api.github.com/repos/conductorone/baton/releases/latest" +BASE_URL="https://github.com/conductorone/baton/releases/download" + +DOWNLOAD_URL=$(curl "${RELEASES_URL}" | jq --raw-output ".assets[].browser_download_url | match(\"${BASE_URL}/v[.0-9]+/baton-v[.0-9]+-${OS}-${ARCH}.*\"; \"i\").string") + +FILENAME=$(basename ${DOWNLOAD_URL}) + +curl -LO ${DOWNLOAD_URL} +tar xzf ${FILENAME}