[tasks.tags] description = "Show the Docker Hub tags for the current image version" run = ''' #!/usr/bin/env bash set -euo pipefail arg_value() { local name=$1 local values values=$(sed -n "s/^ARG ${name}=//p" Containerfile | sort -u) if [[ -z $values || $values == *$'\n'* ]]; then echo "Containerfile must define one consistent value for ARG ${name}" >&2 exit 1 fi printf '%s' "$values" } repository=${CGIT_IMAGE_REPOSITORY:-docker.io/pablu/cgit} cgit_version=$(arg_value CGIT_VERSION) image_revision=$(arg_value IMAGE_REVISION) if [[ ! $cgit_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "CGIT_VERSION must be a three-part version, got: ${cgit_version}" >&2 exit 1 fi if [[ ! $image_revision =~ ^[0-9]+$ ]]; then echo "IMAGE_REVISION must be a non-negative integer, got: ${image_revision}" >&2 exit 1 fi minor_version=${cgit_version%.*} major_version=${cgit_version%%.*} printf '%s\n' \ "${repository}:${cgit_version}-r${image_revision}" \ "${repository}:${cgit_version}" \ "${repository}:${minor_version}" \ "${repository}:${major_version}" ''' [tasks.build] description = "Build the current cgit image with Podman" run = ''' #!/usr/bin/env bash set -euo pipefail arg_value() { local name=$1 local values values=$(sed -n "s/^ARG ${name}=//p" Containerfile | sort -u) if [[ -z $values || $values == *$'\n'* ]]; then echo "Containerfile must define one consistent value for ARG ${name}" >&2 exit 1 fi printf '%s' "$values" } repository=${CGIT_IMAGE_REPOSITORY:-docker.io/pablu/cgit} cgit_version=$(arg_value CGIT_VERSION) image_revision=$(arg_value IMAGE_REVISION) image=${repository}:${cgit_version}-r${image_revision} podman build --tag "$image" --file Containerfile . ''' [tasks.push] description = "Build and push the versioned and rolling Docker Hub tags" depends = ["build"] run = ''' #!/usr/bin/env bash set -euo pipefail mapfile -t images < <(mise run tags) source_image=${images[0]} for image in "${images[@]}"; do if [[ $image != "$source_image" ]]; then podman tag "$source_image" "$image" fi podman push "$image" done '''