#!/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 # 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."