1
0
Fork 0
mirror of https://github.com/imjasonh/setup-crane synced 2026-07-06 22:52:45 +00:00
setup-crane/action.yml

67 lines
1.9 KiB
YAML
Raw Normal View History

2021-07-23 11:08:28 -04:00
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 }}
2021-07-23 11:08:28 -04:00
run: |
set -ex
# Install crane:
# - if version is "tip", install from tip of main.
# - if version is "latest-release", use the latest release URL.
2021-07-23 11:08:28 -04:00
# - otherwise, install the specified version.
case "${VERSION}" in
2021-07-23 11:08:28 -04:00
tip)
echo "Installing crane using go get"
2022-07-25 17:40:07 -07:00
go install github.com/google/go-containerregistry/cmd/crane@main
2021-07-23 11:08:28 -04:00
;;
latest-release)
url="https://github.com/google/go-containerregistry/releases/latest/download"
2021-07-23 11:08:28 -04:00
;;
*)
url="https://github.com/google/go-containerregistry/releases/download/${VERSION}"
2021-07-23 11:08:28 -04:00
esac
os="${RUNNER_OS}"
2026-06-26 22:30:41 +00:00
if [[ "$os" == "macOS" ]]; then
2021-07-23 11:08:28 -04:00
os="Darwin"
fi
arch=$(uname -m)
2023-02-15 17:27:44 +01:00
if [[ "$arch" =~ (aarch64|arm64) ]] ; then
2023-02-15 17:19:05 +01:00
arch=arm64
fi
out=crane
if [[ "${os}" == "Windows" ]]; then
out=crane.exe
fi
2026-06-26 22:30:41 +00:00
if [[ ! -z "${url}" ]]; then
echo "Installing crane for ${os} on ${arch}"
tmp=$(mktemp -d)
2026-06-26 22:31:13 +00:00
cd "${tmp}"
fname="go-containerregistry_${os}_${arch}.tar.gz"
curl -o "$fname" -fsSL --retry 5 --retry-delay 1 --retry-all-errors "${url}/${fname}"
2026-06-26 22:30:41 +00:00
tar xzf "$fname" "${out}"
chmod +x "${tmp}/${out}"
2026-06-26 22:31:13 +00:00
PATH="${PATH}:${tmp}"
echo "${tmp}" >> "$GITHUB_PATH"
2021-07-23 11:08:28 -04:00
fi
# NB: username doesn't seem to matter.
echo "${GITHUB_TOKEN}" | crane auth login ghcr.io --username "dummy" --password-stdin