From 5ee9ffb96a49185c3146ff74686d8f9ae50b63e6 Mon Sep 17 00:00:00 2001 From: Joonas Loppi Date: Sun, 18 Aug 2024 12:57:50 +0300 Subject: [PATCH] support making release for OCI image reference --- publish-docker.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 publish-docker.sh diff --git a/publish-docker.sh b/publish-docker.sh new file mode 100755 index 0000000..2460281 --- /dev/null +++ b/publish-docker.sh @@ -0,0 +1,52 @@ +#!/bin/bash -eu + +githubUser="" +githubRepo="" +imageRefBase="" + +# Usage function to display help +usage() { + echo "Usage: $0 --user --repo --image-ref-base " + echo + echo "Options:" + echo " --user GitHub username (required)" + echo " --repo GitHub repository name (required)" + echo " --image-ref-base Base image reference (required, without the :tag suffix)" + echo + exit 1 +} + +# Parse named CLI arguments using getopt +OPTS=$(getopt -o '' --long user:,repo:,image-ref-base: -- "$@") +eval set -- "$OPTS" + +# Extract options and their arguments into variables +while true; do + case "$1" in + --user) + githubUser="$2"; shift 2;; + --repo) + githubRepo="$2"; shift 2;; + --image-ref-base) + imageRefBase="$2"; shift 2;; + --) + shift; break;; + *) + usage;; + esac +done + +# Check if any required arguments are missing +if [ -z "$githubUser" ] || [ -z "$githubRepo" ] || [ -z "$imageRefBase" ]; then + echo "Error: Missing required arguments." + usage +fi + +# it's not nice that we've to guess here *what the primary image ref will be*, but we've to do this +# until Turbo Bob makes "what will be the primary imageRef" visible to build steps. +# (see https://github.com/function61/turbobob/issues/63) +# +# => ghcr.io/joonas-fi/joonas.fi:sha-105ea4e +imageRef="${imageRefBase}:sha-${REV_ID:0:7}" + +deployer releases oci-image-release-mk "$imageRef" "$githubUser" "$githubRepo" "$FRIENDLY_REV_ID" "$REV_ID"