From cb4ed2f2bd1f06a963daca881f5348b6270f1798 Mon Sep 17 00:00:00 2001 From: "Francis X. Clampazzo" Date: Tue, 28 Jul 2026 08:15:44 -0400 Subject: [PATCH] Add version.txt and auto-incrementing build script - version.txt tracks the current image tag - build-and-tag.sh now reads/increments version, builds, and pushes to the registry in one step (still accepts explicit tag as arg) - Starting at v6 to avoid ambiguity with the overwritten v5 --- build-and-tag.sh | 21 ++++++++++++++++++--- version.txt | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 version.txt diff --git a/build-and-tag.sh b/build-and-tag.sh index a7caad7..823fb3a 100755 --- a/build-and-tag.sh +++ b/build-and-tag.sh @@ -1,13 +1,28 @@ #!/usr/bin/env bash # Build the container image and tag it for the registry. -# Usage: ./build-and-tag.sh e.g. ./build-and-tag.sh v1 +# Usage: ./build-and-tag.sh # reads version.txt, increments, builds, pushes +# Usage: ./build-and-tag.sh # explicit tag (e.g. ./build-and-tag.sh v6) set -e IMAGE=hardings-service REGISTRY=registry.digitalsorcery.net -TAG="${1:?usage: $0 }" +VERSION_FILE="$(dirname "$0")/version.txt" +if [ -n "$1" ]; then + TAG="$1" +else + # Read current version, increment the numeric portion + CURRENT=$(cat "$VERSION_FILE" | tr -d '[:space:]') + NUM=$(echo "$CURRENT" | sed 's/v//') + TAG="v$((NUM + 1))" +fi + +echo "Building ${IMAGE}:${TAG} ..." podman build -t "${IMAGE}:${TAG}" -f Containerfile . podman tag "${IMAGE}:${TAG}" "${REGISTRY}/${IMAGE}:${TAG}" +podman push "${REGISTRY}/${IMAGE}:${TAG}" -echo "Push with: podman push ${REGISTRY}/${IMAGE}:${TAG}" +# Update version.txt to match the tag we just pushed +echo "$TAG" > "$VERSION_FILE" + +echo "Done. ${REGISTRY}/${IMAGE}:${TAG} pushed." diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..9c0be88 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +v6