-
Notifications
You must be signed in to change notification settings - Fork 50
Experimentally provide executable version of PIE #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d98e5b9
Added barebones structure of building with Static PHP
asgrim 2f28386
Use PHP 8.5 and PHP_BUILD_PROVIDER to identify if we are running unde…
asgrim ab2a90b
Add self contained PIE executable CI step
asgrim 1dc43c3
Add Windows into SPC build matrix
asgrim b1b3557
Tidying up PIE binary build pipeline a bit
asgrim 17c33e8
Add all the binaries to the PIE release too
asgrim 51929b0
Rename various jobs and steps for the addition of static binaries
asgrim 43ba15d
Extract static PHP check
asgrim a284b63
Disable self-update for staic PHP build
asgrim 866fdc4
Added to usage docs about executable PIE version
asgrim f7f8c57
Added nightly executables
asgrim d8d008f
Use PHP 8.4 for build
asgrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| # Invoking this pipeline requires additional permissions, so must be invoked | ||
| # in a way to pass those permissions on, e.g.: | ||
| # | ||
| # build-assets: | ||
| # permissions: | ||
| # contents: read | ||
| # id-token: write | ||
| # attestations: write | ||
| # uses: ./.github/workflows/build-assets.yml | ||
|
|
||
| name: "Build the PIE assets" | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-phar: | ||
| runs-on: ${{ matrix.operating-system }} | ||
| strategy: | ||
| matrix: | ||
| operating-system: | ||
| - ubuntu-latest | ||
| php-versions: | ||
| - '8.1' | ||
| permissions: | ||
| # id-token:write is required for build provenance attestation. | ||
| id-token: write | ||
| # attestations:write is required for build provenance attestation. | ||
| attestations: write | ||
| steps: | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| coverage: none | ||
| tools: composer, box | ||
| php-version: "${{ matrix.php-version }}" | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| # Fixes `git describe` picking the wrong tag - see https://github.com/php/pie/issues/307 | ||
| - run: git fetch --tags --force | ||
| # Ensure some kind of previous tag exists, otherwise box fails | ||
| - run: git describe --tags HEAD || git tag 0.0.0 | ||
| - uses: ramsey/composer-install@v3 | ||
| - name: Build PHAR | ||
| run: box compile | ||
| - name: Check the PHAR executes | ||
| run: php pie.phar --version | ||
| - name: Generate build provenance attestation | ||
| # It does not make sense to do this for PR builds, nor do contributors | ||
| # have permission to do. We can't write attestations to `php/pie` in an | ||
| # unprivileged context, otherwise anyone could send a PR with malicious | ||
| # code, which would store attestation that `php/pie` built the PHAR, and | ||
| # it would look genuine. So this should NOT run for PR builds. | ||
| if: github.event_name != 'pull_request' | ||
| uses: actions/attest-build-provenance@v3 | ||
| with: | ||
| subject-path: '${{ github.workspace }}/pie.phar' | ||
| - uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: pie-${{ github.sha }}.phar | ||
| path: pie.phar | ||
|
|
||
| build-executable: | ||
| needs: | ||
| - build-phar | ||
| runs-on: ${{ matrix.operating-system }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| operating-system: | ||
| - ubuntu-24.04 | ||
| - ubuntu-24.04-arm | ||
| - macos-15-intel | ||
| - macos-26 | ||
| - windows-2025 | ||
asgrim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| permissions: | ||
| # id-token:write is required for build provenance attestation. | ||
| id-token: write | ||
| # attestations:write is required for build provenance attestation. | ||
| attestations: write | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Download SPC (non-Windows) | ||
| if: runner.os != 'Windows' | ||
| run: | | ||
| # @todo find a better way to do this :/ | ||
| # Source URL: https://static-php.dev/en/guide/manual-build.html#build-locally-using-spc-binary-recommended | ||
| case "${{ matrix.operating-system }}" in | ||
| ubuntu-24.04) | ||
| curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64 | ||
| ;; | ||
|
|
||
| ubuntu-24.04-arm) | ||
| curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64 | ||
| ;; | ||
|
|
||
| macos-15-intel) | ||
| curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64 | ||
| ;; | ||
|
|
||
| macos-26) | ||
| curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 | ||
| ;; | ||
|
|
||
| *) | ||
| echo "unsupported operating system: ${{ matrix.operating-system }}" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| chmod +x spc | ||
| echo "SPC_BINARY=./spc" >> $GITHUB_ENV | ||
| echo "PIE_BINARY_OUTPUT=pie-${{ runner.os }}-${{ runner.arch }}" >> $GITHUB_ENV | ||
| - name: Download SPC (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: | | ||
| curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe | ||
| chmod +x spc.exe | ||
| echo "SPC_BINARY=.\spc.exe" >> $env:GITHUB_ENV | ||
| echo "PIE_BINARY_OUTPUT=pie-${{ runner.os }}-${{ runner.arch }}.exe" >> $env:GITHUB_ENV | ||
|
|
||
| - name: Grab the pie.phar from artifacts | ||
| uses: actions/download-artifact@v5 | ||
| with: | ||
| name: pie-${{ github.sha }}.phar | ||
|
|
||
| - name: Build for ${{ runner.os }} ${{ runner.arch }} on ${{ matrix.operating-system }} | ||
| run: ${{ env.SPC_BINARY }} craft resources/spc/craft.yml | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Bundle pie.phar into executable PIE binary | ||
| run: ${{ env.SPC_BINARY }} micro:combine pie.phar --output=${{ env.PIE_BINARY_OUTPUT }} | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| coverage: none | ||
| tools: composer | ||
| php-version: "7.4" | ||
| - name: Quick validation that the binary runs | ||
| run: ./${{ env.PIE_BINARY_OUTPUT }} show --all | ||
|
|
||
| - name: Generate build provenance attestation | ||
| # It does not make sense to do this for PR builds, nor do contributors | ||
| # have permission to do. We can't write attestations to `php/pie` in an | ||
| # unprivileged context, otherwise anyone could send a PR with malicious | ||
| # code, which would store attestation that `php/pie` built the binaries, | ||
| # and it would look genuine. So this should NOT run for PR builds. | ||
| if: github.event_name != 'pull_request' | ||
| uses: actions/attest-build-provenance@v3 | ||
| with: | ||
| subject-path: '${{ github.workspace }}/${{ env.PIE_BINARY_OUTPUT }}' | ||
|
|
||
| - uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: pie-${{ github.sha }}-${{ runner.os }}-${{ runner.arch }}.bin | ||
| path: ${{ env.PIE_BINARY_OUTPUT }} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.