name: Release erstellen on: push: tags: - 'v*' jobs: build-release: runs-on: ubuntu-latest steps: - name: Code herunterladen run: | VERSION="${{ github.ref_name }}" curl -sSL -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -o source.tar.gz \ "https://git.wende.it/marco/WitShop/archive/${VERSION}.tar.gz" tar xzf source.tar.gz # Gitea entpackt in einen Unterordner WitShop-{version}/ SRCDIR=$(tar tzf source.tar.gz 2>/dev/null | head -1 | cut -d/ -f1 || true) if [ -n "$SRCDIR" ] && [ -d "$SRCDIR" ]; then mv "$SRCDIR"/* . 2>/dev/null || true mv "$SRCDIR"/.[!.]* . 2>/dev/null || true rmdir "$SRCDIR" 2>/dev/null || true fi rm -f source.tar.gz - 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 run: | # Release erstellen (oder existierenden verwenden) RELEASE_ID=$(curl -sSL -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ "https://git.wende.it/api/v1/repos/marco/WitShop/releases/tags/${{ github.ref_name }}" \ | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || true) if [ -z "$RELEASE_ID" ]; then RELEASE_ID=$(curl -sSL -X POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/json" \ "https://git.wende.it/api/v1/repos/marco/WitShop/releases" \ -d "{ \"tag_name\": \"${{ github.ref_name }}\", \"name\": \"WITshop ${{ github.ref_name }}\", \"body\": \"## WITshop ${{ github.ref_name }}\n\n### Installation (Erstinstallation)\n1. ZIP herunterladen und auf den Server entpacken\n2. \`install.sh\` ausführen: \`bash install.sh\`\n3. Fertig\n\n### Update (bestehende Installation)\n1. ZIP herunterladen und auf den Server entpacken\n2. \`update.sh\` ausführen: \`bash update.sh\`\", \"draft\": false, \"prerelease\": false }" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") fi echo "Release ID: $RELEASE_ID" # ZIP anhängen curl -sSL -X POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -F "attachment=@${{ env.PACKAGE }}" \ "https://git.wende.it/api/v1/repos/marco/WitShop/releases/${RELEASE_ID}/assets?name=${{ env.PACKAGE }}" echo "ZIP erfolgreich hochgeladen: ${{ env.PACKAGE }}"