2021-04-27 21:41:07 +08:00
|
|
|
name: 'Setup ko'
|
|
|
|
description: 'Install and authorize ko'
|
|
|
|
branding:
|
|
|
|
icon: box
|
|
|
|
color: green
|
|
|
|
inputs:
|
|
|
|
version:
|
|
|
|
description: 'Version of ko to install (tip, latest-release, v0.8.2, etc.)'
|
|
|
|
required: true
|
|
|
|
default: 'latest-release'
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- shell: bash
|
|
|
|
run: |
|
2021-04-30 23:06:59 +08:00
|
|
|
set -ex
|
|
|
|
|
2021-04-27 21:41:07 +08:00
|
|
|
# Install ko:
|
|
|
|
# - 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 ko using go get"
|
|
|
|
go get github.com/google/ko@main
|
|
|
|
;;
|
|
|
|
latest-release)
|
2021-07-23 23:36:22 +08:00
|
|
|
tag=$(curl -s -u "username:${{ github.token }}" https://api.github.com/repos/google/ko/releases/latest | jq -r '.tag_name')
|
2021-04-27 21:41:07 +08:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
tag="${{ inputs.version }}"
|
|
|
|
esac
|
|
|
|
|
2021-04-29 10:50:44 +08:00
|
|
|
os=${{ runner.os }}
|
|
|
|
if [[ $os == "macOS" ]]; then
|
|
|
|
os="Darwin"
|
|
|
|
fi
|
|
|
|
|
2021-04-27 21:41:07 +08:00
|
|
|
if [[ ! -z ${tag} ]]; then
|
2021-04-29 10:50:44 +08:00
|
|
|
echo "Installing ko @ ${tag} for ${os}"
|
|
|
|
curl -fsL https://github.com/google/ko/releases/download/${tag}/ko_${tag:1}_${os}_x86_64.tar.gz | sudo tar xzf - -C /usr/local/bin ko
|
2021-04-27 21:41:07 +08:00
|
|
|
fi
|
|
|
|
|
2021-05-01 10:33:35 +08:00
|
|
|
if [[ ! -z ${KO_DOCKER_REPO} ]]; then
|
|
|
|
echo "KO_DOCKER_REPO is already set"
|
|
|
|
echo "Skipping login to ghcr.io and passing KO_DOCKER_REPO=${KO_DOCKER_REPO} on to future steps"
|
|
|
|
echo "KO_DOCKER_REPO=${KO_DOCKER_REPO}" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
# NB: username doesn't seem to matter.
|
|
|
|
echo "${{ github.token }}" | ko login ghcr.io --username "dummy" --password-stdin
|
2021-04-27 21:41:07 +08:00
|
|
|
|
2021-05-01 10:33:35 +08:00
|
|
|
# Set KO_DOCKER_REPO for future steps.
|
|
|
|
echo "KO_DOCKER_REPO=ghcr.io/${{ github.repository }}"
|
|
|
|
echo "KO_DOCKER_REPO=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
|
|
|
|
fi
|