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
This commit is contained in:
Francis X. Clampazzo
2026-07-28 08:15:44 -04:00
parent 320badafd5
commit cb4ed2f2bd
2 changed files with 19 additions and 3 deletions
+18 -3
View File
@@ -1,13 +1,28 @@
#!/usr/bin/env bash
# Build the container image and tag it for the registry.
# Usage: ./build-and-tag.sh <tag> e.g. ./build-and-tag.sh v1
# Usage: ./build-and-tag.sh # reads version.txt, increments, builds, pushes
# Usage: ./build-and-tag.sh <tag> # explicit tag (e.g. ./build-and-tag.sh v6)
set -e
IMAGE=hardings-service
REGISTRY=registry.digitalsorcery.net
TAG="${1:?usage: $0 <tag>}"
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."
+1
View File
@@ -0,0 +1 @@
v6