Skip to content

Clean up downloaded assets after verification and install #344

Clean up downloaded assets after verification and install

Clean up downloaded assets after verification and install #344

Workflow file for this run

---
name: "Testing"
on:
workflow_dispatch:
inputs:
github-token:
type: string
description: "GitHub token to use to download hc-releases"
required: true
version:
type: string
description: "Version of hc-releases to install"
pull_request:
push:
branches:
- main
- 'releases/*'
defaults:
run:
shell: bash
jobs:
unit:
runs-on: ubuntu-latest
# TODO test on all supported platforms (need GH-hosted darwin runners)
strategy:
matrix:
version:
- '${{ inputs.version }}'
- '0.1.14' # need not be the most recent
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: "Install tools (only for running locally via act)"
if: env.CI == 'true' && env.ACT == 'true'
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
run_quiet() { local logfile="${RUNNER_TEMP}/command.log" ; "$@" > "$logfile" 2>&1 || { cat "$logfile" ; exit 1 ; } ; }
type -p curl >/dev/null || (apt update && apt install --yes curl)
curl --silent --show-error --fail --location \
--output /usr/share/keyrings/githubcli-archive-keyring.gpg \
https://cli.github.com/packages/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list
run_quiet apt update
run_quiet apt install --yes gh
gh --version
- name: Install hc-releases
uses: ./
id: install
with:
github-token: ${{ inputs.github-token || secrets.TOKEN_DOWNLOAD_RELAPI }}
version: ${{ matrix.version }}
- name: Test reported version
env:
GH_TOKEN: ${{ inputs.github-token || secrets.TOKEN_DOWNLOAD_RELAPI }}
run: |
got_ver="${{ steps.install.outputs.version }}"
if [ -z "$got_ver" ]; then
echo "Failed to detect installed version: step output empty." 1>&2
exit 1
fi
exp_ver="${{ matrix.version }}"
if [ -z "$exp_ver" ]; then # default version, same method used by action.yml
echo "Identifying latest release..."
exp_ver="$(gh release list --repo=hashicorp/releases-api | awk '$2 == "Latest" { print $3 }')"
fi
if [ -z "$exp_ver" ]; then
echo "Failed to determine expected version of hc-releases" 1>&2
exit 1
fi
if [ "v${got_ver#v}" != "v${exp_ver#v}" ]; then
echo "Incorrect hc-releases found (wrong version installed? target version not first in PATH?)" 1>&2
exit 1
fi
# test that a single job can call the action multiple times
- name: Install hc-releases again
uses: ./
with:
github-token: ${{ inputs.github-token || secrets.TOKEN_DOWNLOAD_RELAPI }}
version: ${{ matrix.version }}