mirror of
https://github.com/imjasonh/setup-crane
synced 2026-07-06 22:52:45 +00:00
66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
name: 'Setup crane'
|
|
description: 'Install and authorize crane'
|
|
branding:
|
|
icon: box
|
|
color: green
|
|
inputs:
|
|
version:
|
|
description: 'Version of crane to install (tip, latest-release, v0.5.1, etc.)'
|
|
required: true
|
|
default: 'latest-release'
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- shell: bash
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
RUNNER_OS: ${{ runner.os }}
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -ex
|
|
|
|
# Install crane:
|
|
# - if version is "tip", install from tip of main.
|
|
# - if version is "latest-release", use the latest release URL.
|
|
# - otherwise, install the specified version.
|
|
case "${VERSION}" in
|
|
tip)
|
|
echo "Installing crane using go get"
|
|
go install github.com/google/go-containerregistry/cmd/crane@main
|
|
;;
|
|
latest-release)
|
|
url="https://github.com/google/go-containerregistry/releases/latest/download"
|
|
;;
|
|
*)
|
|
url="https://github.com/google/go-containerregistry/releases/download/${VERSION}"
|
|
esac
|
|
|
|
os="${RUNNER_OS}"
|
|
if [[ "$os" == "macOS" ]]; then
|
|
os="Darwin"
|
|
fi
|
|
|
|
arch=$(uname -m)
|
|
if [[ "$arch" =~ (aarch64|arm64) ]] ; then
|
|
arch=arm64
|
|
fi
|
|
|
|
out=crane
|
|
if [[ "${os}" == "Windows" ]]; then
|
|
out=crane.exe
|
|
fi
|
|
|
|
if [[ ! -z "${url}" ]]; then
|
|
echo "Installing crane for ${os} on ${arch}"
|
|
tmp=$(mktemp -d)
|
|
cd "${tmp}"
|
|
fname="go-containerregistry_${os}_${arch}.tar.gz"
|
|
curl -o "$fname" -fsSL --retry 5 --retry-delay 1 --retry-all-errors "${url}/${fname}"
|
|
tar xzf "$fname" "${out}"
|
|
chmod +x "${tmp}/${out}"
|
|
PATH="${PATH}:${tmp}"
|
|
echo "${tmp}" >> "$GITHUB_PATH"
|
|
fi
|
|
|
|
# NB: username doesn't seem to matter.
|
|
echo "${GITHUB_TOKEN}" | crane auth login ghcr.io --username "dummy" --password-stdin
|