Skip to content

Commit 51e7828

Browse files
committed
GH Actions: provide attestations for release PHAR files
GitHub has released a new feature called Artifact Attestations, which allows for verifying the integrity of artifacts build via GitHub Actions. This is an additional security and compliance feature, which allows for checking which workflow build the artifact and ensuring the artifact has not been tampered with after the generation via the workflow. To me, this sounds like a good addition to the build process for release phars, so this commit implements attesting PHARS for releases. To verify the phar files (after the next release, which will be the first to use this feature): * Download the PHAR file(s), either from "Releases", from the tag "Test" workflow run or via PHIVE. * If downloaded as a zipped artifact, unzip to get to the actual PHAR files. * Using the GitHub CLI tool, run the below command to verify: ```bash gh attestation verify phpcs.phar -o PHPCSStandards gh attestation verify phpcbf.phar -o PHPCSStandards ``` References: * https://github.blog/changelog/2024-06-25-artifact-attestations-is-generally-available/ * https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds * https://github.com/actions/attest-build-provenance * https://cli.github.com/ * https://github.com/cli/cli
1 parent e5c46d3 commit 51e7828

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
runs-on: ubuntu-latest
2626
name: "Build Phar on PHP: 8.0"
2727

28+
permissions:
29+
id-token: write
30+
contents: read
31+
attestations: write
32+
2833
steps:
2934
- name: Checkout code
3035
uses: actions/checkout@v4
@@ -39,6 +44,17 @@ jobs:
3944
- name: Build the phar
4045
run: php scripts/build-phar.php
4146

47+
# Provide provenance for generated binaries.
48+
# Only attests the build artifacts which will be used in the published releases as per the guidelines in "what to attest".
49+
# https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds
50+
- name: Generate artifact attestations
51+
if: ${{ github.ref_type == 'tag' }}
52+
uses: actions/attest-build-provenance@v1
53+
with:
54+
subject-path: |
55+
${{ github.workspace }}/phpcs.phar
56+
${{ github.workspace }}/phpcbf.phar
57+
4258
- name: Upload the PHPCS phar
4359
uses: actions/upload-artifact@v4
4460
with:

0 commit comments

Comments
 (0)