Skip to content

Commit 7f43d2a

Browse files
committed
Merge remote-tracking branch 'tstellar/refactor-attestations-pr-2' into HEAD
2 parents bbfb34e + 5f858fd commit 7f43d2a

File tree

2 files changed

+70
-30
lines changed

2 files changed

+70
-30
lines changed

.github/workflows/release-sources.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ jobs:
6464
name: Package Release Sources
6565
if: github.repository_owner == 'llvm'
6666
runs-on: ubuntu-24.04
67+
outputs:
68+
digest: ${{ steps.digest.outputs.digest }}
69+
artifact-id: ${{ steps.artifact-upload.outputs.artifact-id }}
6770
needs:
6871
- inputs
69-
permissions:
70-
id-token: write
71-
attestations: write
7272
steps:
7373
- name: Checkout LLVM
7474
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -83,14 +83,43 @@ jobs:
8383
run: |
8484
./llvm/utils/release/export.sh ${{ needs.inputs.outputs.export-args }}
8585
86-
- name: Store Tarball Names
87-
id: filenames
86+
- name: Generate sha256 digest for sources
87+
id: digest
8888
run: |
89-
echo "filenames=*.xz" >> $GITHUB_OUTPUT
89+
echo "digest=$(cat *.xz | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
90+
91+
- name: Release Sources Artifact
92+
id: artifact-upload
93+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
94+
with:
95+
name: ${{ needs.inputs.outputs.ref }}-sources
96+
path: |
97+
*.xz
98+
99+
attest-release-sources:
100+
name: Attest Release Sources
101+
runs-on: ubuntu-24.04
102+
if: github.event_name != 'pull_request'
103+
needs:
104+
- inputs
105+
- release-sources
106+
permissions:
107+
id-token: write
108+
attestations: write
109+
steps:
110+
- name: Checkout Release Scripts
111+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
112+
with:
113+
sparse-checkout: |
114+
.github/workflows/upload-release-artifact
115+
llvm/utils/release/github-upload-release.py
116+
llvm/utils/git/requirements.txt
117+
sparse-checkout-cone-mode: false
90118

91119
- name: Upload Artifacts
92120
uses: ./.github/workflows/upload-release-artifact
93121
with:
94-
files: ${{ steps.filenames.outputs.filenames }}
95-
attestation-name: ${{ needs.inputs.outputs.ref }}-sources
122+
artifact-id: ${{ needs.release-sources.outputs.artifact-id }}
123+
attestation-name: ${{ needs.inputs.outputs.ref }}-sources-attestation
124+
digest: ${{ needs.release-sources.outputs.digest }}
96125
upload: false

.github/workflows/upload-release-artifact/action.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ description: >-
33
Upload release artifact along with an attestation. The action assumes that
44
the llvm-project repository has already been checked out.
55
inputs:
6-
files:
7-
description: >-
8-
Files to be uploaded. This can contain bash wildcards.
9-
required: true
106
release-version:
117
description: >-
128
The release where the artifact will be attached.
@@ -31,43 +27,58 @@ inputs:
3127
$attestation-name.jsonl. If this is not set, it will default
3228
to the falue of `files`.
3329
required: false
30+
artifact-id:
31+
description: >-
32+
Artifact id of the artifact with the files to upload.
33+
required: true
34+
digest:
35+
description: >-
36+
sha256 digest to verify the authenticity of the files being uploaded.
37+
required: true
3438

3539
runs:
3640
using: "composite"
3741
steps:
38-
- name: Collect Variables
39-
id: vars
42+
- name: Download Artifact
43+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
44+
id: download-artifact
45+
with:
46+
artifact-ids: ${{ inputs.artifact-id }}
47+
path: downloads
48+
49+
# In theory github artifacts are immutable so we could just rely on using
50+
# the artifact-id to download it, but just to be extra safe we want to
51+
# generated a digest for the files we are uploading so we can verify it
52+
# when downloading.
53+
# See also: https://irsl.medium.com/github-artifact-immutability-is-a-lie-9b6244095694
54+
- name: Verify Files
4055
shell: bash
4156
env:
42-
INPUTS_ATTESTATION_NAME: ${{ inputs.attestation-name }}
43-
INPUTS_FILES: ${{ inputs.files }}
57+
INPUTS_DIGEST: ${{ inputs.digest }}
4458
run: |
45-
if [ -z "$INPUTS_ATTESTATION_NAME" ]; then
46-
name="$INPUTS_FILES"
47-
else
48-
name="$INPUTS_ATTESTATION_NAME"
49-
fi
50-
echo "attestation-name=$name" >> $GITHUB_OUTPUT
59+
digest_file="sha256"
60+
echo "$INPUTS_DIGEST -" > $digest_file
61+
cat ${{ steps.download-artifact.outputs.download-path }}/* | sha256sum -c $digest_file
62+
5163
- name: Attest Build Provenance
52-
if: inputs.upload == 'true'
5364
id: provenance
5465
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
5566
with:
56-
subject-path: ${{ inputs.files }}
67+
subject-path: ${{ steps.download-artifact.outputs.download-path }}/*
5768

5869
- name: Rename attestation file
59-
if: inputs.upload == 'true'
6070
shell: bash
71+
env:
72+
INPUTS_ATTESTATION_NAME: ${{ inputs.attestation-name }}
6173
run: |
62-
mv ${{ steps.provenance.outputs.bundle-path }} ${{ steps.vars.outputs.attestation-name }}.jsonl
74+
mv ${{ steps.provenance.outputs.bundle-path }} "$INPUTS_ATTESTATION_NAME".jsonl
6375
6476
- name: Upload Build Provenance
6577
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
6678
with:
67-
name: ${{ steps.vars.outputs.attestation-name }}
79+
name: ${{ inputs.attestation-name }}
6880
path: |
69-
${{ inputs.files }}
70-
${{(inputs.upload == 'true' && format('{0}.jsonl', steps.vars.outputs.attestation-name)) || '' }}
81+
${{ inputs.attestation-name }}.jsonl
7182
7283
- name: Install Python Requirements
7384
if: inputs.upload == 'true'
@@ -91,4 +102,4 @@ runs:
91102
--token ${{ github.token }} \
92103
--release ${{ inputs.release-version }} \
93104
upload \
94-
--files ${{ inputs.files }} ${{ steps.vars.outputs.attestation-name}}.jsonl
105+
--files ${{ steps.download-artifact.outputs.download-path }}/* ${{ steps.vars.outputs.attestation-name}}.jsonl

0 commit comments

Comments
 (0)