summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpablu <me@pablu.de>2026-09-19 14:47:00 +0200
committerpablu <me@pablu.de>2026-09-19 14:53:20 +0200
commit1ff95d6dd3cbb9e75b0eb71a7341c278fda9f645 (patch)
treee6ab7c360bd9e87faed1843ea4bc63954b0bcf7f
parenta3b5366573d9d6ba2299cd021842ab516856327c (diff)
feat: add mise.toml for tasks
-rw-r--r--mise.toml86
1 files changed, 86 insertions, 0 deletions
diff --git a/mise.toml b/mise.toml
new file mode 100644
index 0000000..574e3b3
--- /dev/null
+++ b/mise.toml
@@ -0,0 +1,86 @@
+[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
+'''