Files
pdf_to_ics/release.sh

92 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
IMAGE_REPO="git.file-archive.de/webfarben/pdf_to_ics"
SET_ENV=false
RUN_DEPLOY=false
usage() {
echo "Usage: ./release.sh <version-tag> [--set-env] [--deploy]"
echo ""
echo "Examples:"
echo " ./release.sh v1.2.3"
echo " ./release.sh v1.2.3 --set-env"
echo " ./release.sh v1.2.3 --set-env --deploy"
}
if [ $# -eq 1 ] && [[ "$1" == "-h" || "$1" == "--help" ]]; then
usage
exit 0
fi
if [ $# -lt 1 ]; then
usage
exit 1
fi
TAG="$1"
shift
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Fehler: Tag muss im Format vX.Y.Z sein (z. B. v1.2.3)."
exit 1
fi
while [ $# -gt 0 ]; do
case "$1" in
--set-env)
SET_ENV=true
;;
--deploy)
RUN_DEPLOY=true
;;
-h|--help)
usage
exit 0
;;
*)
echo "❌ Unbekannte Option: $1"
usage
exit 1
;;
esac
shift
done
if ! command -v docker >/dev/null 2>&1; then
echo "❌ Fehler: docker ist nicht installiert oder nicht im PATH."
exit 1
fi
IMAGE_REF="${IMAGE_REPO}:${TAG}"
echo "🏗️ Baue Image: $IMAGE_REF"
docker build -t "$IMAGE_REF" .
echo "⬆️ Pushe Image: $IMAGE_REF"
docker push "$IMAGE_REF"
if [ "$SET_ENV" = true ]; then
if [ -f ".env" ]; then
sed -i "s|^PDF_TO_ICS_IMAGE=.*|PDF_TO_ICS_IMAGE=$IMAGE_REF|" .env
echo "✅ .env auf $IMAGE_REF gesetzt."
else
echo " .env nicht gefunden übersprungen."
fi
fi
if [ "$RUN_DEPLOY" = true ]; then
if [ -x "./deploy.sh" ]; then
echo "🚀 Starte Deploy mit neuem Tag..."
./deploy.sh
else
echo "❌ Fehler: deploy.sh nicht gefunden oder nicht ausführbar."
exit 1
fi
fi
echo "✅ Release abgeschlossen: $IMAGE_REF"