|
| 1 | +# GitHub Action: whenever creating a new release of the source code, |
| 2 | +# also create a release of the installable plugin. |
| 3 | +# Steps to execute: |
| 4 | +# - Checkout the source code |
| 5 | +# - Run "composer install" to download all dependencies under vendor/ |
| 6 | +# - Create a .zip file, excluding: |
| 7 | +# - All hidden files (.git, .gitignore, etc) |
| 8 | +# - All development files, ending in .dist |
| 9 | +# - All composer files <= after installing dependencies, no need for them anymore |
| 10 | +# - Markdown files concerning development |
| 11 | +# - Folder build/ <= created only to store the .zip file |
| 12 | +# - Folder dev-helpers/ <= not needed for the plugin |
| 13 | +# - Upload the .zip file as an artifact to the action (this step is possibly optional) |
| 14 | +# - Upload the .zip file as a release, for download |
| 15 | +name: Generate Installable Plugin, and Upload as Release Asset |
| 16 | +on: |
| 17 | + release: |
| 18 | + types: [published] |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Upload Release Asset |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Build project |
| 28 | + run: | |
| 29 | + mkdir build |
| 30 | +
|
| 31 | + - name: Create artifact |
| 32 | + uses: montudor/action-zip@v1 |
| 33 | + with: |
| 34 | + args: zip -X -r build/${{ github.event.repository.name }}.zip . -x *.git* node_modules/\* .* "*/\.*" "*/.git*" "*/.DS_Store" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml *.neon composer.* package.json package-lock.json "dev-helpers/*" "build/*" "wporg-assets/*" "docs/*" "phpunit/*" phpstan-bootstrap.php build-assets.js |
| 35 | + |
| 36 | + - name: Upload artifact |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: ${{ github.event.repository.name }} |
| 40 | + path: build/${{ github.event.repository.name }}.zip |
| 41 | + - name: Upload to release |
| 42 | + uses: JasonEtco/upload-to-release@master |
| 43 | + with: |
| 44 | + args: build/${{ github.event.repository.name }}.zip application/zip |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments