Skip to content

Commit

Permalink
Refactor installer to a single curl step
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Apr 23, 2024
1 parent aeee94d commit 890796c
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,59 @@ runs:
id: latest
shell: bash
working-directory: ${{ runner.temp }}
env:
REPO: balena-io/balena-cli
run: |
release="$(curl -s https://api.github.com/repos/balena-io/balena-cli/releases/latest | jq -r '.tag_name')"
release="$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r '.tag_name')"
echo "release=${release}" >> "${GITHUB_OUTPUT}"
- name: Restore balena CLI cache
- name: Restore tool cache
if: inputs.skip-cache != 'true'
id: cache
uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/balena-cli
key: balena-cli-${{ runner.os }}-${{ runner.arch }}-${{ steps.latest.outputs.release || inputs.cli-version }}

- name: Download balena CLI (Linux X64)
if: runner.os == 'Linux' && ! steps.cache.outputs.cache-hit
- name: Get runner os
if: steps.cache.outputs.cache-hit != true
id: os
shell: bash
working-directory: ${{ runner.temp }}
shell: bash --noprofile --norc -eo pipefail -x {0}
env:
REPO: https://github.com/balena-io/balena-cli
VERSION: ${{ steps.latest.outputs.release || inputs.cli-version }}
ARCH: ${{ runner.arch }}
OS: linux
run: |
curl -fsSL "${REPO}/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH,,}-standalone.zip" -o balena-cli.zip
unzip balena-cli.zip -d .
case "${{ runner.os }}" in
Linux) echo "target=linux" >> "${GITHUB_OUTPUT}" ;;
macOS) echo "target=macOS" >> "${GITHUB_OUTPUT}" ;;
Windows) echo "target=windows" >> "${GITHUB_OUTPUT}" ;;
*) echo "::error::Unsupported os: ${{ runner.os }}" ; exit 1 ;;
esac
- name: Download balena CLI (Windows X64)
if: runner.os == 'Windows' && ! steps.cache.outputs.cache-hit
- name: Get runner arch
if: steps.cache.outputs.cache-hit != true
id: arch
shell: bash
working-directory: ${{ runner.temp }}
shell: bash --noprofile --norc -eo pipefail -x {0}
env:
REPO: https://github.com/balena-io/balena-cli
VERSION: ${{ steps.latest.outputs.release || inputs.cli-version }}
ARCH: ${{ runner.arch }}
OS: windows
run: |
curl -fsSL "${REPO}/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH,,}-standalone.zip" -o balena-cli.zip
unzip balena-cli.zip -d .
case "${{ runner.arch }}" in
X64) echo "target=x64" >> "${GITHUB_OUTPUT}" ;;
ARM64) echo "target=arm64" >> "${GITHUB_OUTPUT}" ;;
*) echo "::error::Unsupported arch: ${{ runner.arch }}" ; exit 1 ;;
esac
- name: Download balena CLI (macOS)
if: runner.os == 'macOS' && ! steps.cache.outputs.cache-hit
- name: Download balena CLI
if: steps.cache.outputs.cache-hit != true
working-directory: ${{ runner.temp }}
shell: bash --noprofile --norc -eo pipefail -x {0}
env:
REPO: https://github.com/balena-io/balena-cli
REPO: balena-io/balena-cli
VERSION: ${{ steps.latest.outputs.release || inputs.cli-version }}
ARCH: ${{ runner.arch }}
OS: macOS
OS: ${{ steps.os.outputs.target }}
ARCH: ${{ steps.arch.outputs.target }}
run: |
curl -fsSL "${REPO}/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH,,}-standalone.zip" -o balena-cli.zip
curl -fsSL "http://github.com/${REPO}/releases/download/${VERSION}/balena-cli-${VERSION}-${OS}-${ARCH}-standalone.zip" -o balena-cli.zip
unzip balena-cli.zip -d .
- name: Install balena CLI to tool cache
- name: Update tool cache
uses: AnimMouse/tool-cache@v1
with:
folder_name: balena-cli
Expand Down

0 comments on commit 890796c

Please sign in to comment.