chore: Version auf 1.4.3 erhöht (Workflow-Test) #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.1' | ||
| - name: Extract version from tag | ||
| id: tag_version | ||
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | ||
| - name: Check if this is a plugin repository | ||
| id: is_plugin | ||
| run: | | ||
| # Prüfe ob package.xml im ROOT existiert (nicht in Unterverzeichnissen) | ||
| if [ -f "package.xml" ]; then | ||
| echo "IS_PLUGIN=true" >> $GITHUB_OUTPUT | ||
| echo "✅ Plugin-Repository erkannt (package.xml im Root gefunden)" | ||
| else | ||
| echo "IS_PLUGIN=false" >> $GITHUB_OUTPUT | ||
| echo "ℹ️ Toolkit-Repository erkannt (kein package.xml im Root)" | ||
| fi | ||
| - name: Extract package name from package.xml | ||
| id: package_name | ||
| if: steps.is_plugin.outputs.IS_PLUGIN == 'true' | ||
| run: | | ||
| PACKAGE_NAME=$(grep -oP 'name="\K[^"]+' "package.xml" | head -1) | ||
| if [ -z "$PACKAGE_NAME" ]; then | ||
| echo "❌ Konnte Package-Name nicht aus package.xml extrahieren" | ||
| exit 1 | ||
| fi | ||
| echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT | ||
| - name: Find plugin directory | ||
| id: plugin_dir | ||
| if: steps.is_plugin.outputs.IS_PLUGIN == 'true' | ||
| run: | | ||
| PLUGIN_DIR="." | ||
| echo "PLUGIN_DIR=$PLUGIN_DIR" >> $GITHUB_OUTPUT | ||
| echo "Plugin-Verzeichnis: $PLUGIN_DIR" | ||
| - name: Parse package.xml dynamically | ||
| id: parse_package | ||
| if: steps.is_plugin.outputs.IS_PLUGIN == 'true' | ||
| working-directory: ${{ steps.plugin_dir.outputs.PLUGIN_DIR }} | ||
| run: | | ||
| # Lade die Parser-Scripts aus dem Repository-Root | ||
| REPO_ROOT="${{ github.workspace }}" | ||
| mkdir -p /tmp/scripts | ||
| cp "$REPO_ROOT/scripts/parse-package-xml.sh" /tmp/scripts/ | ||
| cp "$REPO_ROOT/scripts/pip-defaults.sh" /tmp/scripts/ | ||
| chmod +x /tmp/scripts/*.sh | ||
| # Setze SCRIPT_DIR für die Scripts | ||
| export SCRIPT_DIR="/tmp/scripts" | ||
| # Source die Scripts | ||
| source /tmp/scripts/pip-defaults.sh | ||
| source /tmp/scripts/parse-package-xml.sh | ||
| # Parse package.xml und hole alle benötigten Dateien | ||
| FILES_TO_PACKAGE=() | ||
| while IFS= read -r file; do | ||
| if [ -n "$file" ]; then | ||
| FILES_TO_PACKAGE+=("$file") | ||
| fi | ||
| done < <(get_required_files "package.xml" ".") | ||
| # Erstelle komma-separierte Liste für GitHub Actions | ||
| FILES_LIST=$(IFS=','; echo "${FILES_TO_PACKAGE[*]}") | ||
| echo "FILES_LIST=$FILES_LIST" >> $GITHUB_OUTPUT | ||
| # Zeige gefundene Dateien | ||
| echo "Gefundene Dateien:" | ||
| for file in "${FILES_TO_PACKAGE[@]}"; do | ||
| echo " - $file" | ||
| done | ||
| - name: Create package | ||
| if: steps.is_plugin.outputs.IS_PLUGIN == 'true' | ||
| working-directory: ${{ steps.plugin_dir.outputs.PLUGIN_DIR }} | ||
| run: | | ||
| PACKAGE_NAME="${{ steps.package_name.outputs.PACKAGE_NAME }}" | ||
| VERSION="${{ steps.tag_version.outputs.VERSION }}" | ||
| PACKAGE_FILE="${PACKAGE_NAME}-${VERSION}.tar.gz" | ||
| # Konvertiere komma-separierte Liste zurück zu Array | ||
| IFS=',' read -ra FILES_TO_PACKAGE <<< "${{ steps.parse_package.outputs.FILES_LIST }}" | ||
| # Erstelle temporäres Verzeichnis | ||
| TMP_DIR=$(mktemp -d) | ||
| # Kopiere alle benötigten Dateien | ||
| for file in "${FILES_TO_PACKAGE[@]}"; do | ||
| if [ -f "$file" ]; then | ||
| cp "$file" "$TMP_DIR/" | ||
| echo "✅ Kopiert: $file" | ||
| elif [ -d "$file" ]; then | ||
| cp -r "$file" "$TMP_DIR/" | ||
| echo "✅ Kopiert: $file/ (Verzeichnis)" | ||
| else | ||
| echo "⚠️ Warnung: $file nicht gefunden, überspringe..." | ||
| fi | ||
| done | ||
| # Erstelle TAR.GZ | ||
| cd "$TMP_DIR" || exit 1 | ||
| tar -czf "/tmp/$PACKAGE_FILE" * | ||
| # Stelle sicher dass Zielverzeichnis existiert | ||
| mkdir -p "${{ steps.plugin_dir.outputs.PLUGIN_DIR }}" | ||
| mv "/tmp/$PACKAGE_FILE" "${{ steps.plugin_dir.outputs.PLUGIN_DIR }}/" | ||
| echo "PACKAGE_FILE=$PACKAGE_FILE" >> $GITHUB_ENV | ||
| echo "PACKAGE_PATH=${{ steps.plugin_dir.outputs.PLUGIN_DIR }}/$PACKAGE_FILE" >> $GITHUB_ENV | ||
| - name: Prepare release body | ||
| id: release_body | ||
| run: | | ||
| if [ "${{ steps.is_plugin.outputs.IS_PLUGIN }}" == "true" ]; then | ||
| RELEASE_BODY="## Version ${{ steps.tag_version.outputs.VERSION }} | ||
| Automatisch erstellt mit dynamischem package.xml Parsing. | ||
| **Package:** ${{ steps.package_name.outputs.PACKAGE_NAME }} | ||
| Siehe CHANGELOG.md für Details falls vorhanden." | ||
| else | ||
| RELEASE_BODY="## Version ${{ steps.tag_version.outputs.VERSION }} | ||
| **Simple WoltLab Plugin Manager Toolkit** | ||
| Toolkit für die WoltLab Suite Plugin-Entwicklung. | ||
| Siehe README.md für Details." | ||
| fi | ||
| echo "$RELEASE_BODY" > /tmp/release_body.txt | ||
| echo "RELEASE_BODY_FILE=/tmp/release_body.txt" >> $GITHUB_ENV | ||
| - name: Create Release (Plugin) | ||
| if: steps.is_plugin.outputs.IS_PLUGIN == 'true' | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| files: ${{ env.PACKAGE_PATH }} | ||
| name: Version ${{ steps.tag_version.outputs.VERSION }} | ||
| body_path: ${{ env.RELEASE_BODY_FILE }} | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Create Release (Toolkit) | ||
| if: steps.is_plugin.outputs.IS_PLUGIN != 'true' | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| name: Version ${{ steps.tag_version.outputs.VERSION }} | ||
| body_path: ${{ env.RELEASE_BODY_FILE }} | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||