Files
Francis X. Clampazzo cb4ed2f2bd 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
2026-07-28 08:15:44 -04:00

29 lines
894 B
Bash
Executable File

#!/usr/bin/env bash
# Build the container image and tag it for the registry.
# 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
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}"
# Update version.txt to match the tag we just pushed
echo "$TAG" > "$VERSION_FILE"
echo "Done. ${REGISTRY}/${IMAGE}:${TAG} pushed."