conductor/scripts/release-image.sh
Victor Wiebe 498003f83d
Some checks failed
Release production image / production-image (push) Has been cancelled
Prepare Conductor v1.0.0 release
2026-08-08 14:21:40 -04:00

33 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IMAGE="${IMAGE:-gitea.skeletonworks.online/vwiebe/conductor}"
VERSION="${VERSION:-}"
PUSH=false
PLATFORMS="${PLATFORMS:-linux/amd64}"
while [[ $# -gt 0 ]]; do
case "$1" in
--image) IMAGE="$2"; shift 2 ;;
--version) VERSION="$2"; shift 2 ;;
--platforms) PLATFORMS="$2"; shift 2 ;;
--push) PUSH=true; shift ;;
-h|--help) echo "Usage: $0 --version vX.Y.Z [--image REGISTRY/OWNER/NAME] [--platforms LIST] [--push]"; exit 0 ;;
*) echo "Unknown option: $1" >&2; exit 1 ;;
esac
done
[[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.-]+)?$ ]] || { echo "--version must be a vX.Y.Z release tag." >&2; exit 1; }
revision="$(git rev-parse HEAD)"
short_revision="$(git rev-parse --short=12 HEAD)"
created="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
output=(--load)
$PUSH && output=(--push)
if ! $PUSH && [[ "$PLATFORMS" == *,* ]]; then
echo "Local --load supports one platform; use --push for a multi-platform release." >&2
exit 1
fi
docker buildx build --platform "$PLATFORMS" -f Dockerfile.production \
--build-arg "VERSION=$VERSION" --build-arg "REVISION=$revision" --build-arg "CREATED=$created" \
-t "${IMAGE}:${VERSION}" -t "${IMAGE}:git-${short_revision}" "${output[@]}" .
printf '{"image":"%s","version":"%s","revision":"%s","platforms":"%s","pushed":%s}\n' "$IMAGE" "$VERSION" "$revision" "$PLATFORMS" "$PUSH"