Skip to content

Commit

Permalink
support making release for OCI image reference
Browse files Browse the repository at this point in the history
  • Loading branch information
joonas-fi committed Aug 18, 2024
1 parent 7760033 commit 5ee9ffb
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions publish-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash -eu

githubUser=""
githubRepo=""
imageRefBase=""

# Usage function to display help
usage() {
echo "Usage: $0 --user <username> --repo <repository> --image-ref-base <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"

0 comments on commit 5ee9ffb

Please sign in to comment.