Repository navigation
221 lines (209 loc) · 9.04 KB
/
Copy pathrelease.yml
File metadata and controls
221 lines (209 loc) · 9.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Release
# Pushing a tag v<version> builds every package, signs everything, publishes a
# GitHub Release, and then publishes the crate to crates.io.
#
# v0.1.0 a release: all of the above
# v0.1.0-rc.1 a rehearsal: a GitHub pre-release, never marked "latest",
# and nothing is published to crates.io
#
# Packages built: .deb (Debian, Ubuntu), .rpm (Fedora, RHEL), .pkg.tar.zst
# (Arch), .flatpak (a bundle for any distribution), the bare binary, and the
# .crate. The tag's base version must equal the version in Cargo.toml.
on:
push:
tags:
- 'v*'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
version:
name: Check the tag against Cargo.toml
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: check
env:
TAG: ${{ github.ref_name }}
run: |
version=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
base="${TAG#v}"; base="${base%%-*}"
if [ "$base" != "$version" ]; then
echo "::error::tag $TAG does not match Cargo.toml version $version"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
# Native packages and the bare binary are checked below; this job builds the crate.
native:
name: .crate
needs: version
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# gettext: msgfmt compiles the translations the packages install.
- name: Install GTK development packages and gettext
run: scripts/ci-apt-update.sh && sudo apt-get install -y --no-install-recommends libgtk-4-dev libadwaita-1-dev gettext
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
with:
toolchain: stable
- name: Build the binary and the .crate
run: make build
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: native
# Binary and packages come exclusively from the verified job below.
path: dist/*.crate
if-no-files-found: error
reproducible:
name: Verify and stage the reproducible GUI binary and all package formats
needs: version
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
CONTAINER_ENGINE: docker
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install manifest parser for unit tests
run: scripts/ci-apt-update.sh && sudo apt-get install -y --no-install-recommends python3-yaml
- name: Verify two clean offline builds
run: make test-reproducible reproducible
- name: Stage the verified binary and its reproduction inputs
run: |
mkdir -p dist
cp target/reproducible/first/usbguard-gui dist/usbguard-gui
cp target/reproducible/first/*.rpm target/reproducible/first/*.deb target/reproducible/first/*.pkg.tar.zst target/reproducible/first/*.flatpak dist/
cp target/reproducible/report.json dist/reproducible-build.json
cp target/reproducible/inputs/source.tar dist/reproducible-source.tar
cp target/reproducible/inputs/recipe.tar dist/reproducible-recipe.tar
cp target/reproducible/packages.txt dist/reproducible-packages.txt
cp target/reproducible/toolchain.txt dist/reproducible-toolchain.txt
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: reproducible
path: dist/*
if-no-files-found: error
# Exercise the verified bundle in a sandbox; compilation/export happen above.
flatpak:
name: Verify the installed Flatpak bundle
needs: [version, reproducible]
runs-on: ubuntu-latest
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-50@sha256:1de59efef01a946d9f28f1ec3458bf6f61dcee3507d7fecdd473f8134da4ec77
options: --privileged
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: reproducible
path: dist
- name: Install and exercise the verified bundle with the pinned runtime
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
if ! dbus-run-session -- python3 scripts/verify-flatpak-runtime.py "dist/usbguard-gui-${VERSION}.flatpak" --output target/flatpak-runtime; then
cat target/flatpak-runtime/commands.log
exit 1
fi
cp target/flatpak-runtime/report.json dist/reproducible-flatpak-runtime.json
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: flatpak-runtime
path: dist/reproducible-flatpak-runtime.json
if-no-files-found: error
release:
name: Sign and publish the GitHub Release
needs: [native, flatpak, reproducible]
runs-on: ubuntu-latest
permissions:
contents: write # create the GitHub Release and upload assets
id-token: write # Sigstore keyless signing via OIDC
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Collect the packages
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: dist
merge-multiple: true
- name: Generate SBOM
run: |
npm install -g @cyclonedx/cdxgen
cdxgen -o dist/sbom.json
- name: Generate checksums
run: make checksums
# Keyless signing: the certificate binds each artifact to this workflow and
# tag, so there is no long-lived private key to compromise.
# Verification instructions live in docs/verification.md.
- name: Sign artifacts with Sigstore
uses: sigstore/gh-action-sigstore-python@790bc6befb9d733738f18d8f895854b453640ec9 # v3.5.0
with:
# Every line is expanded as a glob and must match at least one file:
# a "!pattern" is not an exclusion but a literal path, and fails the
# step. No .sigstore bundle exists yet at this point anyway.
inputs: dist/*
- name: Create GitHub Release
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
files: |
dist/*
generate_release_notes: true
fail_on_unmatched_files: true
# A tag with a suffix (v0.1.0-rc.1) is a pre-release: GitHub never
# marks it "latest", so the README's download links stay on the last
# real release.
prerelease: ${{ contains(github.ref_name, '-') }}
# After the GitHub Release, so the packages exist even if crates.io is down;
# the job can be re-run on its own. Never for a pre-release.
#
# Authentication, in order of preference:
# 1. Trusted Publishing: set the repository variable
# CRATES_IO_TRUSTED_PUBLISHING=true once crates.io is configured to
# trust this workflow. A 30-minute token is minted per run.
# 2. The CARGO_REGISTRY_TOKEN secret of the crates-io environment —
# required for the very first publish, which crates.io does not allow
# through Trusted Publishing.
crates-io:
name: Publish to crates.io
needs: release
if: ${{ !contains(github.ref_name, '-') }}
runs-on: ubuntu-24.04
environment: crates-io
permissions:
contents: read
id-token: write # Trusted Publishing via OIDC
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# cargo publish builds the packaged crate once more to verify it.
- name: Install GTK development packages and gettext
run: scripts/ci-apt-update.sh && sudo apt-get install -y --no-install-recommends libgtk-4-dev libadwaita-1-dev gettext
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
with:
toolchain: stable
- name: Authenticate with Trusted Publishing
id: auth
if: ${{ vars.CRATES_IO_TRUSTED_PUBLISHING == 'true' }}
uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
- name: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token || secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "::error::no crates.io credentials: set the CARGO_REGISTRY_TOKEN secret of the crates-io environment, or configure Trusted Publishing"
exit 1
fi
cargo publish --locked