|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: {} |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: release-${{ github.ref }} |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +jobs: |
| 15 | + release-please: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 5 |
| 18 | + permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write |
| 21 | + outputs: |
| 22 | + release_created: ${{ steps.rp.outputs.release_created }} |
| 23 | + tag_name: ${{ steps.rp.outputs.tag_name }} |
| 24 | + version: ${{ steps.rp.outputs.version }} |
| 25 | + steps: |
| 26 | + - id: rp |
| 27 | + uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 |
| 28 | + |
| 29 | + build: |
| 30 | + needs: release-please |
| 31 | + if: needs.release-please.outputs.release_created == 'true' |
| 32 | + runs-on: ubuntu-latest |
| 33 | + timeout-minutes: 15 |
| 34 | + permissions: |
| 35 | + contents: write |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v6 |
| 38 | + |
| 39 | + - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0 |
| 40 | + with: |
| 41 | + php-version: '8.2' |
| 42 | + coverage: none |
| 43 | + |
| 44 | + - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 |
| 45 | + with: |
| 46 | + composer-options: '--no-dev --optimize-autoloader --classmap-authoritative' |
| 47 | + |
| 48 | + - name: Build release zip |
| 49 | + env: |
| 50 | + VERSION: ${{ needs.release-please.outputs.version }} |
| 51 | + run: | |
| 52 | + mkdir -p dist |
| 53 | + # Tracked files only, with .gitattributes export-ignore filtering applied. |
| 54 | + git archive --prefix=page-for-custom-post-type/ HEAD | tar -x -C dist |
| 55 | + # vendor/ is gitignored, so git archive doesn't include it. Copy it in. |
| 56 | + cp -r vendor dist/page-for-custom-post-type/vendor |
| 57 | + # Inject the bundled-only autoload require. |
| 58 | + sed -i "s|// @bundle-autoload|require_once __DIR__ . '/vendor/autoload.php';|" dist/page-for-custom-post-type/plugin.php |
| 59 | + grep -q "require_once __DIR__ . '/vendor/autoload.php';" dist/page-for-custom-post-type/plugin.php \ |
| 60 | + || { echo "::error::bundle autoload marker replacement failed"; exit 1; } |
| 61 | + php -l dist/page-for-custom-post-type/plugin.php |
| 62 | + (cd dist && zip -rq "../page-for-custom-post-type-${VERSION}.zip" page-for-custom-post-type) |
| 63 | +
|
| 64 | + - name: Upload zip to release |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ github.token }} |
| 67 | + TAG: ${{ needs.release-please.outputs.tag_name }} |
| 68 | + VERSION: ${{ needs.release-please.outputs.version }} |
| 69 | + run: gh release upload "$TAG" "page-for-custom-post-type-${VERSION}.zip" --clobber |
0 commit comments