Skip to content

Commit 3cb8e52

Browse files
committed
add attestation system to protect binaries (#4012)
this allows to prove that binaries were produced by GitHub actions.
1 parent 7a7c9c4 commit 3cb8e52

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

.github/workflows/nightly_binaries.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: nightly_binaries
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
id-token: write
8+
attestations: write
9+
610
jobs:
711
nightly_binaries:
812
runs-on: ubuntu-22.04
@@ -14,7 +18,11 @@ jobs:
1418

1519
- run: make binaries
1620

17-
- run: cd binaries; for f in *; do sha256sum $f > $f.sha256sum; done
21+
- run: cd binaries && sha256sum -b * > checksums.sha256
22+
23+
- uses: actions/attest-build-provenance@v2
24+
with:
25+
subject-path: '${{ github.workspace }}/binaries/*'
1826

1927
- uses: actions/upload-artifact@v4
2028
with:

.github/workflows/release.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- 'v*'
77

8+
permissions:
9+
id-token: write
10+
attestations: write
11+
812
jobs:
913
binaries:
1014
runs-on: ubuntu-22.04
@@ -14,7 +18,11 @@ jobs:
1418

1519
- run: make binaries
1620

17-
- run: cd binaries; for f in *; do sha256sum $f > $f.sha256sum; done
21+
- run: cd binaries && sha256sum -b * > checksums.sha256
22+
23+
- uses: actions/attest-build-provenance@v2
24+
with:
25+
subject-path: '${{ github.workspace }}/binaries/*'
1826

1927
- uses: actions/upload-artifact@v4
2028
with:
@@ -40,21 +48,31 @@ jobs:
4048
4149
const currentRelease = context.ref.split('/')[2];
4250
43-
let body = `## New major features\n\n`
44-
+ `TODO\n\n`
45-
+ `## Fixes and improvements\n\n`
46-
+ `TODO\n\n`
47-
+ `## Security\n\n`
51+
let body = `## New major features\n`
52+
+ `\n`
53+
+ `TODO\n`
54+
+ `\n`
55+
+ `## Fixes and improvements\n`
56+
+ `\n`
57+
+ `TODO\n`
58+
+ `\n`
59+
+ `## Security\n`
60+
+ `\n`
4861
+ `Binaries have been produced by the [Release workflow](https://github.com/${owner}/${repo}/actions/workflows/release.yml)`
49-
+ ` without human intervention.\n\n`
50-
+ `SHA256 checksums:\n\n`;
51-
52-
for (const name of await fs.readdir('./binaries/')) {
53-
if (name.endsWith('.sha256sum')) {
54-
const parts = (await fs.readFile(`./binaries/${name}`, 'utf-8')).slice(0, -1).split(' ');
55-
body += `* ${parts[2]} ${parts[0]}\n`;
56-
}
57-
}
62+
+ ` without human intervention.\n`
63+
+ `\n`
64+
+ 'You can verify that binaries have been produced by the workflow by using [GitHub Attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds):\n'
65+
+ `\n`
66+
+ '```\n'
67+
+ `TODO\n`
68+
+ '```\n'
69+
+ `\n`
70+
+ 'You can verify the binaries checksum by downloading `checksums.sha256` and running:\n'
71+
+ `\n`
72+
+ '```\n'
73+
+ `cat checksums.sha256 | grep $(ls -1 mediamtx*) | sha256sum --check\n`
74+
+ '```\n'
75+
+ `\n`;
5876
5977
const res = await github.rest.repos.createRelease({
6078
owner,

0 commit comments

Comments
 (0)