Takes a version (e.g. 2.1), validates its format, runs docker build once with both tags to skip a second build pass, then pushes both. Warns on uncommitted changes but doesn't block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
947 B
Bash
Executable File
40 lines
947 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
docker login docker-repo.hacker-net.de
|
|
IMAGE="docker-repo.hacker-net.de/imap-mailfilter"
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
echo "Usage: $0 <version>" >&2
|
|
echo "Beispiel: $0 2.1" >&2
|
|
exit 1
|
|
fi
|
|
|
|
VERSION="$1"
|
|
|
|
if [[ ! "$VERSION" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
|
|
echo "Fehler: Version '$VERSION' hat kein gültiges Format (z.B. 2.1 oder 2.1.0)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Warnung bei uncommitteten Änderungen (kein Abbruch)
|
|
if [[ -d .git ]] && ! git diff-index --quiet HEAD -- 2>/dev/null; then
|
|
echo "Warnung: uncommittete Änderungen im Repo. Baue trotzdem." >&2
|
|
git status --short >&2
|
|
echo >&2
|
|
fi
|
|
|
|
echo "==> Baue $IMAGE:$VERSION und :latest"
|
|
docker build \
|
|
-t "$IMAGE:$VERSION" \
|
|
-t "$IMAGE:latest" \
|
|
.
|
|
|
|
echo "==> Pushe $IMAGE:$VERSION"
|
|
docker push "$IMAGE:$VERSION"
|
|
|
|
echo "==> Pushe $IMAGE:latest"
|
|
docker push "$IMAGE:latest"
|
|
|
|
echo
|
|
echo "Release fertig: $IMAGE:$VERSION (und :latest)"
|