n8n_node_librebooking/create-release.sh

90 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# create-release.sh - Erstellt neue Archive und Git Tag
# ============================================================================
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
# Version aus package.json lesen
VERSION=$(grep '"version"' "$SCRIPT_DIR/package.json" | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
echo -e "${GREEN}=== Release erstellen v$VERSION ===${NC}\n"
cd "$SCRIPT_DIR"
# 1. Prüfe, ob alles committet ist
if [ -n "$(git status --porcelain)" ]; then
echo -e "${YELLOW}Warnung: Es gibt uncommittete Änderungen!${NC}"
git status --short
echo ""
read -p "Trotzdem fortfahren? (j/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Jj]$ ]]; then
exit 1
fi
fi
# 2. Alte Archive löschen
echo "[1/4] Lösche alte Archive..."
./git-cleanup.sh 2>/dev/null || true
# 3. Build prüfen
echo ""
echo "[2/4] Prüfe Build..."
if [ ! -d "dist" ] || [ -z "$(find dist -name '*.node.js' 2>/dev/null)" ]; then
echo "Baue Node..."
npm install --silent
npm run build --silent
fi
echo " ✓ Build OK"
# 4. Archive erstellen
echo ""
echo "[3/4] Erstelle Archive..."
TAR_FILE="$PARENT_DIR/n8n-nodes-librebooking-v${VERSION}.tar.gz"
ZIP_FILE="$PARENT_DIR/n8n-nodes-librebooking-v${VERSION}.zip"
git archive --format=tar.gz --prefix=n8n-nodes-librebooking/ --output="$TAR_FILE" HEAD
echo "$TAR_FILE"
git archive --format=zip --prefix=n8n-nodes-librebooking/ --output="$ZIP_FILE" HEAD
echo "$ZIP_FILE"
# 5. Git Tag (optional)
echo ""
echo "[4/4] Git Tag..."
if git tag | grep -q "v$VERSION"; then
echo -e " ${YELLOW}Tag v$VERSION existiert bereits${NC}"
else
read -p "Git Tag v$VERSION erstellen? (j/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Jj]$ ]]; then
git tag -a "v$VERSION" -m "Version $VERSION - Vereinfachte Installation"
echo " ✓ Tag v$VERSION erstellt"
fi
fi
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN} Release v$VERSION erstellt!${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo "Archive:"
echo " $TAR_FILE"
echo " $ZIP_FILE"
echo ""
echo "Zum Pushen:"
echo " git push origin main"
echo " git push origin v$VERSION"
echo ""