diff --git a/.github/workflows/package-and-attach-to-release.yml b/.github/workflows/package-and-attach-to-release.yml new file mode 100644 index 00000000..41c28a80 --- /dev/null +++ b/.github/workflows/package-and-attach-to-release.yml @@ -0,0 +1,42 @@ +name: Package and attach to release + +on: + release: + types: [published] +env: + MOODLE_INSTALL_DIR: "local" + PACKAGE_NAME: "lbplanner" + TARGET_FOLDER: "lbplanner" + +jobs: + package-and-attach-to-release: + name: Package and attach to release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + + - name: Extract version + id: version + run: | + version=$(grep -oP '\$plugin->version\s*=\s*\K[0-9]+' "$TARGET_FOLDER/version.php") + + echo "version=$version" >> $GITHUB_OUTPUT + + - name: Create ZIP file + run: | + ZIP_NAME="${MOODLE_INSTALL_DIR}_${PACKAGE_NAME}_${VERSION}.zip" + zip -qq -r "$ZIP_NAME" "$TARGET_FOLDER" + ls + env: + VERSION: ${{steps.version.outputs.version}} + + + - name: Attach to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: "${{ env.MOODLE_INSTALL_DIR }}_${{ env.PACKAGE_NAME }}_${{ steps.version.outputs.version }}.zip" + asset_name: "${{ env.MOODLE_INSTALL_DIR }}_${{ env.PACKAGE_NAME }}_${{ steps.version.outputs.version }}.zip"