-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from asgrim/consolidate-release-pipelines
Use GH attestation and organise workflows better
- Loading branch information
Showing
7 changed files
with
103 additions
and
94 deletions.
There are no files selected for viewing
This file contains 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,63 @@ | ||
# Invoking this pipeline requires additional permissions, so must be invoked | ||
# in a way to pass those permissions on, e.g.: | ||
# | ||
# build-phar: | ||
# permissions: | ||
# contents: read | ||
# id-token: write | ||
# attestations: write | ||
# uses: ./.github/workflows/build-phar.yml | ||
|
||
name: "Build the PIE PHAR" | ||
|
||
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@v4 | ||
with: | ||
fetch-depth: 0 | ||
# 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@v1 | ||
with: | ||
subject-path: '${{ github.workspace }}/pie.phar' | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: pie-${{ github.sha }}.phar | ||
path: pie.phar |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "Release" | ||
name: "Publish the PHAR for Releases" | ||
|
||
on: | ||
release: | ||
|
@@ -9,58 +9,32 @@ permissions: | |
contents: read | ||
|
||
jobs: | ||
build-phar: | ||
# See build-phar.yml for a list of the permissions and why they are needed | ||
permissions: | ||
contents: read | ||
id-token: write | ||
attestations: write | ||
uses: ./.github/workflows/build-phar.yml | ||
|
||
release-phar: | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
operating-system: | ||
- ubuntu-latest | ||
php-versions: | ||
- '8.1' | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build-phar | ||
permissions: | ||
# contents:write is required to upload the binaries to the release. | ||
contents: write | ||
# 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@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ramsey/composer-install@v3 | ||
- name: Build PHAR | ||
run: box compile | ||
- name: Check the PHAR executes | ||
run: php pie.phar --version | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} | ||
passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }} | ||
- name: Sign the PHAR | ||
run: | | ||
gpg --local-user [email protected] \ | ||
--batch \ | ||
--yes \ | ||
--passphrase="${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}" \ | ||
--detach-sign \ | ||
--output pie.phar.asc \ | ||
pie.phar | ||
- name: Generate build provenance attestation | ||
uses: actions/attest-build-provenance@v1 | ||
- name: Fetch built PHAR from artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
subject-path: '${{ github.workspace }}/pie.phar' | ||
name: pie-${{ github.sha }}.phar | ||
- name: Verify the PHAR | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: gh attestation verify pie.phar --repo ${{ github.repository }} | ||
- name: Upload binaries to release | ||
uses: softprops/action-gh-release@v2 | ||
if: ${{startsWith(github.ref, 'refs/tags/') }} | ||
with: | ||
files: | | ||
pie.phar | ||
pie.phar.asc | ||
files: pie.phar |
This file contains 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 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