1 Commits

Author SHA1 Message Date
Jason Hall 3d230e42c8 Update action.yml 2025-01-15 14:03:26 -05:00
3 changed files with 57 additions and 9 deletions
+47
View File
@@ -0,0 +1,47 @@
name: Use Action
on:
pull_request:
branches: ['main']
push:
branches: ['main']
jobs:
use-action:
name: Use Action
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
- uses: actions/checkout@v4
- uses: ./
- run: |
crane digest ubuntu
crane manifest ubuntu | jq
crane copy ubuntu ghcr.io/${{ github.repository }}/ubuntu-copy
- name: Install old release
uses: ./
with:
version: v0.12.0
- name: Check installed version
run: crane version | grep 0.12.0
- name: Install from tip
uses: ./
with:
version: tip
- name: Check installed version (tip)
run: |
rm $(which crane) # Uninstall previous versions.
crane version
+1 -1
View File
@@ -1,4 +1,4 @@
# GitHub Action to install and setup [`crane`](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md)
# GitHub Action to install and setup [`crane`](https://github.com/google/go-containerregistry/cmd/crane/README.md)
[![Build](https://github.com/imjasonh/setup-crane/actions/workflows/use-action.yaml/badge.svg)](https://github.com/imjasonh/setup-crane/actions/workflows/use-action.yaml)
+9 -8
View File
@@ -15,9 +15,12 @@ runs:
run: |
set -ex
# test
# Install crane:
# - if version is "tip", install from tip of main.
# - if version is "latest-release", use the latest release URL.
# - if version is "latest-release", look up latest release.
# - otherwise, install the specified version.
case ${{ inputs.version }} in
tip)
@@ -25,10 +28,10 @@ runs:
go install github.com/google/go-containerregistry/cmd/crane@main
;;
latest-release)
url="https://github.com/google/go-containerregistry/releases/latest/download"
tag=$(curl -s -u "username:${{ github.token }}" https://api.github.com/repos/google/go-containerregistry/releases/latest | jq -r '.tag_name')
;;
*)
url="https://github.com/google/go-containerregistry/releases/download/${{ inputs.version }}"
tag="${{ inputs.version }}"
esac
os=${{ runner.os }}
@@ -46,13 +49,11 @@ runs:
out=crane.exe
fi
if [[ ! -z ${url} ]]; then
echo "Installing crane for ${os} on ${arch}"
if [[ ! -z ${tag} ]]; then
echo "Installing crane @ ${tag} 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}
curl -fsL https://github.com/google/go-containerregistry/releases/download/${tag}/go-containerregistry_${os}_${arch}.tar.gz | tar xz ${out}
chmod +x ${tmp}/${out}
PATH=${PATH}:${tmp}
echo "${tmp}" >> $GITHUB_PATH