Skip to content

Commit a25856a

Browse files
ci: add tag-based workflows and provenance attestation for GitHub-built binaries
backport of #9135 and #9136.
1 parent 7acb023 commit a25856a

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ name: CI
55
on:
66
push:
77
branches: [ 1.4-maint ]
8+
tags:
9+
- '1.*'
810
paths:
911
- '**.py'
1012
- '**.pyx'
@@ -40,9 +42,14 @@ jobs:
4042
- uses: actions/checkout@v4
4143
- uses: chartboost/ruff-action@v1
4244

43-
pytest:
4445

45-
needs: lint
46+
posix_tests:
47+
48+
needs: [lint]
49+
permissions:
50+
contents: read
51+
id-token: write
52+
attestations: write
4653
strategy:
4754
fail-fast: false
4855
# noinspection YAMLSchemaValidation
@@ -80,25 +87,6 @@ jobs:
8087
fetch-depth: 0
8188
fetch-tags: true
8289

83-
- name: Detect if commit is tagged
84-
id: detect_tag
85-
run: |
86-
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
87-
# If HEAD is a merge commit, the PR head is usually the second parent (HEAD^2).
88-
if [ -z "$tag" ] && git rev-parse -q --verify HEAD^2 >/dev/null 2>&1; then
89-
tag="$(git describe --exact-match --tags HEAD^2 2>/dev/null || true)"
90-
fi
91-
echo "Found tag: ${tag}"
92-
echo "tagged=$tag" >> "$GITHUB_OUTPUT"
93-
94-
- name: Check out exact tag
95-
if: ${{ steps.detect_tag.outputs.tagged }}
96-
uses: actions/checkout@v4
97-
with:
98-
ref: ${{ steps.detect_tag.outputs.tagged }}
99-
fetch-depth: 0
100-
fetch-tags: true
101-
10290
- name: Set up Python ${{ matrix.python-version }}
10391
uses: actions/setup-python@v5
10492
with:
@@ -151,14 +139,14 @@ jobs:
151139
env_vars: OS, python
152140

153141
- name: Build Borg fat binaries (${{ matrix.binary }})
154-
if: ${{ matrix.binary && steps.detect_tag.outputs.tagged }}
142+
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
155143
run: |
156144
pip install 'pyinstaller==6.14.2'
157145
mkdir -p dist/binary
158146
pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
159147
160148
- name: Smoke-test the built binary (${{ matrix.binary }})
161-
if: ${{ matrix.binary && steps.detect_tag.outputs.tagged }}
149+
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
162150
run: |
163151
pushd dist/binary
164152
echo "single-file binary"
@@ -171,7 +159,7 @@ jobs:
171159
popd
172160
173161
- name: Prepare binaries (${{ matrix.binary }})
174-
if: ${{ matrix.binary && steps.detect_tag.outputs.tagged }}
162+
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
175163
run: |
176164
mkdir -p artifacts
177165
if [ -f dist/binary/borg.exe ]; then
@@ -183,8 +171,14 @@ jobs:
183171
echo "binary files"
184172
ls -l artifacts/
185173
174+
- name: Attest binaries provenance (${{ matrix.binary }})
175+
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
176+
uses: actions/attest-build-provenance@v3
177+
with:
178+
subject-path: 'artifacts/*'
179+
186180
- name: Upload binaries (${{ matrix.binary }})
187-
if: ${{ matrix.binary && steps.detect_tag.outputs.tagged }}
181+
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
188182
uses: actions/upload-artifact@v4
189183
with:
190184
name: ${{ matrix.binary }}

docs/binaries/00_README.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ GPG key fingerprint: 6D5B EF9A DD20 7580 5747 B70F 9F88 FB52 FAF7 B393
7070
My fingerprint is also in the footer of all my BorgBackup mailing list posts.
7171

7272

73+
Provenance attestations for GitHub-built binaries
74+
-------------------------------------------------
75+
76+
For binaries built on GitHub (files with a "-gh" suffix in the name), we publish
77+
an artifact provenance attestation that proves the binary was built by our
78+
GitHub Actions workflow from a specific commit or tag. You can verify this using
79+
the GitHub CLI (gh). Install it from https://cli.github.com/ and make sure you
80+
use a recent version that supports "gh attestation".
81+
82+
Practical example (Linux, 1.4.3 tag):
83+
84+
curl -LO https://github.com/borgbackup/borg/releases/download/1.4.3/borg-linux-glibc235-x86_64-gh
85+
gh attestation verify --repo borgbackup/borg --source-ref refs/tags/1.4.3 borg-linux-glibc235-x86_64-gh
86+
87+
If verification succeeds, gh prints a summary stating the subject (your file),
88+
that it was attested by GitHub Actions, and the job/workflow reference.
89+
90+
7391
Installing
7492
----------
7593

0 commit comments

Comments
 (0)