Skip to content

Commit 147696d

Browse files
committed
Use GH attestation and organise workflows better
1 parent 3abe8f5 commit 147696d

File tree

6 files changed

+60
-57
lines changed

6 files changed

+60
-57
lines changed

Diff for: .github/workflows/release-unsigned-phar.yml renamed to .github/workflows/build-phar.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
name: "Release unsigned PHAR"
1+
# Invoking this pipeline requires additional permissions, so must be invoked
2+
# in a way to pass those permissions on, e.g.:
3+
#
4+
# build-phar:
5+
# permissions:
6+
# contents: read
7+
# id-token: write
8+
# attestations: write
9+
# uses: ./.github/workflows/build-phar.yml
10+
11+
name: "Build the PIE PHAR"
212

313
on:
414
workflow_call:
@@ -15,6 +25,11 @@ jobs:
1525
- ubuntu-latest
1626
php-versions:
1727
- '8.1'
28+
permissions:
29+
# id-token:write is required for build provenance attestation.
30+
id-token: write
31+
# attestations:write is required for build provenance attestation.
32+
attestations: write
1833
steps:
1934
- name: Setup PHP
2035
uses: shivammathur/setup-php@v2
@@ -32,6 +47,10 @@ jobs:
3247
run: box compile
3348
- name: Check the PHAR executes
3449
run: php pie.phar --version
50+
- name: Generate build provenance attestation
51+
uses: actions/attest-build-provenance@v1
52+
with:
53+
subject-path: '${{ github.workspace }}/pie.phar'
3554
- uses: actions/upload-artifact@v4
3655
with:
3756
name: pie-${{ github.sha }}.phar

Diff for: .github/workflows/continuous-integration.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,9 @@ jobs:
109109
- unit-tests
110110
- coding-standards
111111
- static-analysis
112-
uses: ./.github/workflows/release-unsigned-phar.yml
112+
# See build-phar.yml for a list of the permissions and why they are needed
113+
permissions:
114+
contents: read
115+
id-token: write
116+
attestations: write
117+
uses: ./.github/workflows/build-phar.yml

Diff for: .github/workflows/docs.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ concurrency:
1919

2020
jobs:
2121
build-phar:
22-
uses: ./.github/workflows/release-unsigned-phar.yml
22+
# See build-phar.yml for a list of the permissions and why they are needed
23+
permissions:
24+
contents: read
25+
id-token: write
26+
attestations: write
27+
uses: ./.github/workflows/build-phar.yml
2328

24-
# Build job
25-
build:
29+
build-docs-package:
2630
runs-on: ubuntu-latest
2731
needs:
2832
- build-phar
@@ -35,20 +39,23 @@ jobs:
3539
uses: actions/download-artifact@v4
3640
with:
3741
name: pie-${{ github.sha }}.phar
42+
- name: Verify the PHAR
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: gh attestation verify pie.phar --repo ${{ github.repository }}
3846
- name: Copy PHAR into docs
3947
run: cp pie.phar docs-package/pie-nightly.phar
4048
- name: Upload artifact
4149
uses: actions/upload-pages-artifact@v3
4250
with:
4351
path: docs-package
4452

45-
# Deployment job
4653
deploy:
4754
environment:
4855
name: github-pages
4956
url: ${{ steps.deployment.outputs.page_url }}
5057
runs-on: ubuntu-latest
51-
needs: build
58+
needs: build-docs-package
5259
permissions:
5360
contents: read
5461
# pages:write is required to deploy to GitHub pages.

Diff for: .github/workflows/release.yml

+20-46
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Release"
1+
name: "Publish the PHAR for Releases"
22

33
on:
44
release:
@@ -9,58 +9,32 @@ permissions:
99
contents: read
1010

1111
jobs:
12+
build-phar:
13+
# See build-phar.yml for a list of the permissions and why they are needed
14+
permissions:
15+
contents: read
16+
id-token: write
17+
attestations: write
18+
uses: ./.github/workflows/build-phar.yml
19+
1220
release-phar:
13-
runs-on: ${{ matrix.operating-system }}
14-
strategy:
15-
matrix:
16-
operating-system:
17-
- ubuntu-latest
18-
php-versions:
19-
- '8.1'
21+
runs-on: ubuntu-latest
22+
needs:
23+
- build-phar
2024
permissions:
2125
# contents:write is required to upload the binaries to the release.
2226
contents: write
23-
# id-token:write is required for build provenance attestation.
24-
id-token: write
25-
# attestations:write is required for build provenance attestation.
26-
attestations: write
2727
steps:
28-
- name: Setup PHP
29-
uses: shivammathur/setup-php@v2
30-
with:
31-
coverage: none
32-
tools: composer, box
33-
php-version: "${{ matrix.php-version }}"
34-
- uses: actions/checkout@v4
35-
with:
36-
fetch-depth: 0
37-
- uses: ramsey/composer-install@v3
38-
- name: Build PHAR
39-
run: box compile
40-
- name: Check the PHAR executes
41-
run: php pie.phar --version
42-
- name: Import GPG key
43-
uses: crazy-max/ghaction-import-gpg@v6
44-
with:
45-
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }}
46-
passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}
47-
- name: Sign the PHAR
48-
run: |
49-
gpg --local-user [email protected] \
50-
--batch \
51-
--yes \
52-
--passphrase="${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}" \
53-
--detach-sign \
54-
--output pie.phar.asc \
55-
pie.phar
56-
- name: Generate build provenance attestation
57-
uses: actions/attest-build-provenance@v1
28+
- name: Fetch built PHAR from artifacts
29+
uses: actions/download-artifact@v4
5830
with:
59-
subject-path: '${{ github.workspace }}/pie.phar'
31+
name: pie-${{ github.sha }}.phar
32+
- name: Verify the PHAR
33+
env:
34+
GH_TOKEN: ${{ github.token }}
35+
run: gh attestation verify pie.phar --repo ${{ github.repository }}
6036
- name: Upload binaries to release
6137
uses: softprops/action-gh-release@v2
6238
if: ${{startsWith(github.ref, 'refs/tags/') }}
6339
with:
64-
files: |
65-
pie.phar
66-
pie.phar.asc
40+
files: pie.phar

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ please read [extension-maintainers](./docs/extension-maintainers.md).
1313
- Download `pie.phar` either:
1414
- [latest stable release](https://github.com/php/pie/releases)
1515
- [latest unstable nightly](https://php.github.io/pie/pie-nightly.phar)
16-
- Validate the signature in `pie.phar.asc`
16+
- Verify the PHAR's source with `gh attestation verify pie.phar --repo php/pie`
1717
- You may then invoke PIE with `php pie.phar <command>`
1818

1919
Further installation details can be found in the [usage](./docs/usage.md) docs.

Diff for: docs/usage.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ order: 2
99
### Manual installation
1010

1111
- Download `pie.phar` from the [latest releases](https://github.com/php/pie/releases)
12-
- Validate the signature in `pie.phar.asc`
13-
- You can fetch the public key with `gpg --recv-key 343F8427AD6B48FF`
14-
- Then you can verify the release with `gpg --verify pie.phar.asc pie.phar`
12+
- Verify the PHAR's source with `gh attestation verify pie.phar --repo php/pie`
1513
- You may then invoke PIE with `php pie.phar <command>`
1614
- Optionally, copy `pie.phar` into your `$PATH`, e.g. `cp pie.phar /usr/local/bin/pie`
1715
- If you copy PIE into your `$PATH`, you may then invoke PIE with `pie <command>`

0 commit comments

Comments
 (0)