forked from imjasonh/setup-crane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
50 lines (45 loc) · 1.53 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
run: |
set -ex
# Install crane:
# - if version is "tip", install from tip of main.
# - if version is "latest-release", look up latest release.
# - otherwise, install the specified version.
case ${{ inputs.version }} in
tip)
echo "Installing crane using go get"
go install github.com/google/go-containerregistry/cmd/crane@main
;;
latest-release)
tag=$(curl -s -u "username:${{ github.token }}" https://api.github.com/repos/google/go-containerregistry/releases/latest | jq -r '.tag_name')
;;
*)
tag="${{ inputs.version }}"
esac
os=${{ runner.os }}
if [[ $os == "macOS" ]]; then
os="Darwin"
fi
arch=$(uname -m)
if [[ "$arch" =~ (aarch64|arm64) ]] ; then
arch=arm64
fi
if [[ ! -z ${tag} ]]; then
echo "Installing crane @ ${tag} for ${os} on ${arch}"
curl -fsL https://github.com/google/go-containerregistry/releases/download/${tag}/go-containerregistry_${os}_${arch}.tar.gz | sudo tar xzf - -C /usr/local/bin crane
fi
# NB: username doesn't seem to matter.
echo "${{ github.token }}" | crane auth login ghcr.io --username "dummy" --password-stdin