|
| 1 | +name: Build PHP Extension From PECL |
| 2 | +run-name: Build PHP Extension ${{ inputs.extension-url }}, ${{ inputs.extension-ref }} |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + extension-url: |
| 7 | + description: 'Extension URL' |
| 8 | + required: true |
| 9 | + extension-ref: |
| 10 | + description: 'Extension ref' |
| 11 | + required: true |
| 12 | + php-version-list: |
| 13 | + description: 'PHP versions to build' |
| 14 | + required: false |
| 15 | + arch-list: |
| 16 | + description: 'Architectures to build' |
| 17 | + required: false |
| 18 | + default: 'x64, x86' |
| 19 | + ts-list: |
| 20 | + description: 'Thread safety to build' |
| 21 | + required: false |
| 22 | + default: 'nts, ts' |
| 23 | + args: |
| 24 | + description: 'Configure arguments' |
| 25 | + required: false |
| 26 | + libs: |
| 27 | + description: 'Libraries' |
| 28 | + required: false |
| 29 | + run-tests: |
| 30 | + description: 'Run tests after building the extension' |
| 31 | + required: false |
| 32 | + default: 'false' |
| 33 | + test-runner: |
| 34 | + description: 'Test runner to use' |
| 35 | + required: false |
| 36 | + default: 'run-tests.php' |
| 37 | + build-directory: |
| 38 | + description: 'Directory to build the extension in' |
| 39 | + required: false |
| 40 | +jobs: |
| 41 | + get-extension-matrix: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + outputs: |
| 44 | + matrix: ${{ steps.extension-matrix.outputs.matrix }} |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + - name: Get the extension matrix |
| 49 | + id: extension-matrix |
| 50 | + uses: ./extension-matrix |
| 51 | + with: |
| 52 | + extension-url: ${{ inputs.extension-url }} |
| 53 | + extension-ref: ${{ inputs.extension-ref }} |
| 54 | + php-version-list: ${{ inputs.php-version-list }} |
| 55 | + arch-list: ${{ inputs.arch-list }} |
| 56 | + ts-list: ${{ inputs.ts-list }} |
| 57 | + |
| 58 | + extension: |
| 59 | + needs: get-extension-matrix |
| 60 | + runs-on: ${{ matrix.os }} |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}} |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + - name: Build the extension |
| 68 | + uses: ./extension |
| 69 | + with: |
| 70 | + artifact-naming-scheme: 'pecl' |
| 71 | + extension-url: ${{ inputs.extension-url }} |
| 72 | + extension-ref: ${{ inputs.extension-ref }} |
| 73 | + php-version: ${{ matrix.php-version }} |
| 74 | + arch: ${{ matrix.arch }} |
| 75 | + ts: ${{ matrix.ts }} |
| 76 | + args: ${{ inputs.args }} |
| 77 | + libs: ${{ inputs.libs }} |
| 78 | + build-directory: ${{ inputs.build-directory }} |
| 79 | + run-tests: ${{ inputs.run-tests }} |
| 80 | + test-runner: ${{ inputs.test-runner }} |
| 81 | + |
| 82 | + artifacts: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + needs: extension |
| 85 | + steps: |
| 86 | + - name: Upload artifacts |
| 87 | + uses: actions/upload-artifact/merge@v4 |
| 88 | + with: |
| 89 | + name: artifacts |
| 90 | + delete-merged: true |
| 91 | + |
| 92 | + pecl-release: |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: artifacts |
| 95 | + steps: |
| 96 | + - name: Get artifact |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: artifacts |
| 100 | + path: artifacts |
| 101 | + - name: Release |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + run: | |
| 105 | + ls -l artifacts |
| 106 | + extension=$(basename "${{ inputs.extension-url }}") |
| 107 | + mkdir -p /tmp/$extension/${{ inputs.extension-ref }}/ |
| 108 | + cp -a artifacts/* /tmp/$extension/${{ inputs.extension-ref }}/ |
| 109 | + cd /tmp || exit 1 |
| 110 | + zip -r $extension-${{ inputs.extension-ref }}.zip $extension |
| 111 | + if ! gh release view pecl -R ${{ github.repository }}; then |
| 112 | + gh release create pecl $extension-${{ inputs.extension-ref }}.zip -t pecl -n pecl -R ${{ github.repository }} |
| 113 | + else |
| 114 | + gh release upload pecl $extension-${{ inputs.extension-ref }}.zip -R ${{ github.repository }} --clobber |
| 115 | + fi |
0 commit comments