From e09d3e924fcd0b32b4898353b8b5b630c1faf4fc Mon Sep 17 00:00:00 2001 From: Marco Wende Date: Sun, 21 Jun 2026 11:35:10 +0200 Subject: [PATCH] Add release workflow, install.sh and update.sh for customer deployment - release.yml: triggered by git tag v*, builds assets, creates ZIP, attaches to Gitea release - install.sh: interactive first-time setup (DB config, key:generate, migrate, seed, cache) - update.sh: update existing installation (clear caches, migrate, rebuild) Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/release.yml | 69 +++++++++++++++++++++ install.sh | 112 +++++++++++++++++++++++++++++++++++ update.sh | 51 ++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 .gitea/workflows/release.yml create mode 100644 install.sh create mode 100644 update.sh diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..b7b3d02 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,69 @@ +name: Release erstellen + +on: + push: + tags: + - 'v*' + +jobs: + build-release: + runs-on: ubuntu-latest + + steps: + - name: Code auschecken + uses: actions/checkout@v4 + + - name: Node.js einrichten + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: PHP einrichten + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + + - name: Composer Dependencies installieren + run: composer install --no-dev --optimize-autoloader --no-interaction + + - name: NPM Dependencies installieren & Assets bauen + run: | + npm ci + npm run build + + - name: Release-Paket erstellen + run: | + VERSION="${{ github.ref_name }}" + PACKAGE="witshop-${VERSION}.zip" + + zip -r "$PACKAGE" . \ + --exclude "*.git*" \ + --exclude "node_modules/*" \ + --exclude "tests/*" \ + --exclude ".env*" \ + --exclude "*.zip" \ + --exclude "storage/logs/*" \ + --exclude "storage/framework/cache/*" \ + --exclude "storage/framework/sessions/*" \ + --exclude "storage/framework/views/*" + + echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Release in Gitea veröffentlichen + uses: https://gitea.com/actions/release-action@main + with: + files: ${{ env.PACKAGE }} + api_key: ${{ secrets.RELEASE_TOKEN }} + title: "WITshop ${{ env.VERSION }}" + body: | + ## WITshop ${{ env.VERSION }} + + ### Installation (Erstinstallation) + 1. ZIP herunterladen und auf den Server entpacken + 2. `install.sh` ausführen: `bash install.sh` + 3. Fertig + + ### Update (bestehende Installation) + 1. ZIP herunterladen und auf den Server entpacken + 2. `update.sh` ausführen: `bash update.sh` diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..3664ae7 --- /dev/null +++ b/install.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# WITshop Erstinstallation +# Ausführen mit: bash install.sh + +set -e +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' + +echo "" +echo "==================================" +echo " WITshop Erstinstallation" +echo "==================================" +echo "" + +# PHP-Pfad ermitteln +PHP=$(which php 2>/dev/null || echo "/opt/plesk/php/8.4/bin/php") +COMPOSER=$(which composer 2>/dev/null || echo "/usr/local/psa/var/modules/composer/composer.phar") + +echo -e "${YELLOW}Verwendetes PHP:${NC} $PHP" +echo -e "${YELLOW}Composer:${NC} $COMPOSER" +echo "" + +# .env erstellen +if [ -f ".env" ]; then + echo -e "${YELLOW}HINWEIS: .env existiert bereits. Wird nicht überschrieben.${NC}" +else + echo "--- Datenbank & Shop konfigurieren ---" + echo "" + + read -p "Shop-Name: " SHOP_NAME + read -p "Shop-URL (z.B. https://shop.kunde.de): " APP_URL + read -p "Datenbank-Host [127.0.0.1]: " DB_HOST; DB_HOST=${DB_HOST:-127.0.0.1} + read -p "Datenbank-Name: " DB_DATABASE + read -p "Datenbank-Benutzer: " DB_USERNAME + read -s -p "Datenbank-Passwort: " DB_PASSWORD; echo "" + read -p "Shop-E-Mail (Absender): " MAIL_FROM + read -p "SMTP-Host: " SMTP_HOST + read -p "SMTP-Port [587]: " SMTP_PORT; SMTP_PORT=${SMTP_PORT:-587} + read -p "SMTP-Benutzer: " SMTP_USER + read -s -p "SMTP-Passwort: " SMTP_PASS; echo "" + + cat > .env << EOF +APP_NAME="${SHOP_NAME}" +APP_ENV=production +APP_KEY= +APP_DEBUG=false +APP_URL=${APP_URL} + +LOG_CHANNEL=stack +LOG_LEVEL=error + +DB_CONNECTION=mysql +DB_HOST=${DB_HOST} +DB_PORT=3306 +DB_DATABASE=${DB_DATABASE} +DB_USERNAME=${DB_USERNAME} +DB_PASSWORD=${DB_PASSWORD} + +CACHE_DRIVER=file +SESSION_DRIVER=file +QUEUE_CONNECTION=sync + +MAIL_MAILER=smtp +MAIL_HOST=${SMTP_HOST} +MAIL_PORT=${SMTP_PORT} +MAIL_USERNAME=${SMTP_USER} +MAIL_PASSWORD=${SMTP_PASS} +MAIL_ENCRYPTION=tls +MAIL_FROM_ADDRESS=${MAIL_FROM} +MAIL_FROM_NAME="${SHOP_NAME}" +EOF + echo -e "${GREEN}✓ .env erstellt${NC}" +fi + +echo "" +echo "--- Abhängigkeiten installieren ---" +$PHP -d open_basedir="" $COMPOSER install --no-dev --optimize-autoloader --no-interaction +echo -e "${GREEN}✓ Composer${NC}" + +echo "" +echo "--- App-Key generieren ---" +$PHP -d open_basedir="" artisan key:generate --force +echo -e "${GREEN}✓ APP_KEY gesetzt${NC}" + +echo "" +echo "--- Storage-Links & Berechtigungen ---" +$PHP -d open_basedir="" artisan storage:link 2>/dev/null || true +chmod -R 775 storage bootstrap/cache +echo -e "${GREEN}✓ Berechtigungen gesetzt${NC}" + +echo "" +echo "--- Datenbank einrichten ---" +$PHP -d open_basedir="" artisan migrate --force +$PHP -d open_basedir="" artisan db:seed --force +echo -e "${GREEN}✓ Datenbank eingerichtet${NC}" + +echo "" +echo "--- Cache aufbauen ---" +$PHP -d open_basedir="" artisan config:cache +$PHP -d open_basedir="" artisan route:cache +$PHP -d open_basedir="" artisan view:cache +echo -e "${GREEN}✓ Cache erstellt${NC}" + +echo "" +echo "==================================" +echo -e "${GREEN} Installation abgeschlossen!${NC}" +echo "==================================" +echo "" +echo "Nächste Schritte:" +echo " 1. In Plesk: Dokumenten-Stammverzeichnis auf 'public' setzen" +echo " 2. Admin-Login: ${APP_URL}/admin" +echo " Standard-Zugangsdaten aus dem Seeder (bitte sofort ändern!)" +echo "" diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..f82e40c --- /dev/null +++ b/update.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# WITshop Update +# Ausführen mit: bash update.sh + +set -e +GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' + +echo "" +echo "==================================" +echo " WITshop Update" +echo "==================================" +echo "" + +PHP=$(which php 2>/dev/null || echo "/opt/plesk/php/8.4/bin/php") +COMPOSER=$(which composer 2>/dev/null || echo "/usr/local/psa/var/modules/composer/composer.phar") + +if [ ! -f ".env" ]; then + echo "FEHLER: Keine .env gefunden. Bitte zuerst install.sh ausführen." + exit 1 +fi + +echo "--- Cache leeren ---" +$PHP -d open_basedir="" artisan config:clear +$PHP -d open_basedir="" artisan route:clear +$PHP -d open_basedir="" artisan view:clear +$PHP -d open_basedir="" artisan cache:clear +echo -e "${GREEN}✓ Cache geleert${NC}" + +echo "" +echo "--- Abhängigkeiten aktualisieren ---" +$PHP -d open_basedir="" $COMPOSER install --no-dev --optimize-autoloader --no-interaction +echo -e "${GREEN}✓ Composer${NC}" + +echo "" +echo "--- Migrationen ausführen ---" +$PHP -d open_basedir="" artisan migrate --force +$PHP -d open_basedir="" artisan db:seed --class=EmailTemplateSeeder --force +echo -e "${GREEN}✓ Datenbank aktualisiert${NC}" + +echo "" +echo "--- Cache aufbauen ---" +$PHP -d open_basedir="" artisan config:cache +$PHP -d open_basedir="" artisan route:cache +$PHP -d open_basedir="" artisan view:cache +echo -e "${GREEN}✓ Cache erstellt${NC}" + +echo "" +echo "==================================" +echo -e "${GREEN} Update abgeschlossen!${NC}" +echo "==================================" +echo ""