Files
ziti/setup-cli/action.yml
T

76 lines
2.5 KiB
YAML

name: ziti-cli
description: Get ziti binary and add it to the PATH
inputs:
version:
required: false
default: stable
description: |
version of ziti CLI to download,
use tag regex (like v1.6) or special values:
'stable' (default) means latest release (GitHub marked `latest`),
regex can be used to pick latest release matching the pattern,
for example, `2.0.[0-9]+$` will match latest 2.0.x release ignoring any 2.0.x-pre* releases
outputs:
version:
value: ${{ steps.version.outputs.ZITI_VERSION }}
description: version of ziti CLI that was downloaded
runs:
using: composite
steps:
- name: process version
shell: bash
id: version
run: |
ver=${{ inputs.version }}
if [[ ${{ inputs.version }} == "stable" ]]; then
echo "fetching stable version"
ver=$(gh release view --repo openziti/ziti | awk '/^tag/{ print $2 }')
else
echo "computing specified[${ver}] version"
ver=$(gh release list --repo openziti/ziti --limit 200 --json "tagName,publishedAt" --jq "sort_by(.publishedAt) | .[].tagName" | grep -E "^${ver}" | tail -1)
fi
if [[ -z "$ver" ]]; then
echo "::error ::Failed to find version matching ${{ inputs.version }}"
exit 1
fi
echo "using version = $ver"
echo "ZITI_VERSION=$ver" >> $GITHUB_ENV
echo "ZITI_VERSION=$ver" >> $GITHUB_OUTPUT
- name: download ziti CLI
shell: bash
run: |
os=${{ runner.os }}
case ${os} in
Linux) os=linux
;;
macOS) os=darwin
;;
Windows) os=windows
;;
esac
arch=$(uname -m)
if [[ "${arch}" == "x86_64" ]]; then
arch="amd64"
fi
echo "downloading ziti-${os}-${arch} ${ZITI_VERSION} tarball"
mkdir -p '${{ runner.temp }}'
cd '${{ runner.temp }}'
gh release download ${ZITI_VERSION} --repo openziti/ziti --pattern "ziti-${os}-${arch}-*" --output ziti.bundle
- name: extract ziti CLI and add to PATH
shell: bash
run: |
cd '${{ runner.temp }}'
mkdir -p ziti-cli/bin
if [[ ${{ runner.os }} == "Windows" ]]; then
mkdir -p ziti-cli/bin
unzip -d 'ziti-cli\bin' ziti.bundle
else
tar -xpf ziti.bundle -C ziti-cli/bin
fi
./ziti-cli/bin/ziti version
echo "${{ runner.temp }}/ziti-cli/bin" >> $GITHUB_PATH