|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v*'] |
| 6 | + |
| 7 | +# Required to create the GitHub Release and upload assets via |
| 8 | +# softprops/action-gh-release. |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + phar: |
| 14 | + name: Build + publish PHAR |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup PHP 8.4 |
| 20 | + uses: shivammathur/setup-php@v2 |
| 21 | + with: |
| 22 | + php-version: '8.4' |
| 23 | + extensions: dom, json, mbstring, tokenizer, phar |
| 24 | + coverage: none |
| 25 | + tools: composer:v2 |
| 26 | + |
| 27 | + - name: Build PHAR |
| 28 | + # `make build/phar` strips dev dependencies, downloads |
| 29 | + # box.phar lazily into var/, compiles dist/xphp.phar, then |
| 30 | + # restores the dev install. See Makefile for the rationale. |
| 31 | + run: make build/phar |
| 32 | + |
| 33 | + - name: Smoke-test the PHAR |
| 34 | + # If the PHAR is broken (missing autoload, bad shebang, |
| 35 | + # excluded a runtime dep), `list` exits non-zero and the |
| 36 | + # release fails BEFORE the asset is uploaded. |
| 37 | + run: php dist/xphp.phar list |
| 38 | + |
| 39 | + - name: Compute SHA256 sum |
| 40 | + # `sha256sum` outputs `<hex> <filename>`; running it from |
| 41 | + # the dist/ directory keeps the filename relative so users |
| 42 | + # can `sha256sum -c xphp.phar.sha256sum` after downloading |
| 43 | + # both files into the same directory. |
| 44 | + working-directory: dist |
| 45 | + run: sha256sum xphp.phar > xphp.phar.sha256sum |
| 46 | + |
| 47 | + - name: Attach assets to GitHub Release |
| 48 | + # softprops/action-gh-release creates the release matched by |
| 49 | + # tag name if it doesn't already exist, then appends the |
| 50 | + # listed files as assets. Release body stays |
| 51 | + # auto-generated unless `body:` / `body_path:` is set later. |
| 52 | + uses: softprops/action-gh-release@v2 |
| 53 | + with: |
| 54 | + files: | |
| 55 | + dist/xphp.phar |
| 56 | + dist/xphp.phar.sha256sum |
| 57 | + fail_on_unmatched_files: true |
0 commit comments