-
Notifications
You must be signed in to change notification settings - Fork 0
310 lines (275 loc) · 11.1 KB
/
Copy pathcli-release.yml
File metadata and controls
310 lines (275 loc) · 11.1 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# Cut a bootintel-cli release across 5 platforms.
#
# workflow_dispatch only — never triggered by push, so a stray tag
# or commit can't accidentally publish. Matches the Launch Guard
#
# What it does:
# 1. Matrix-builds the CLI on Linux (x86_64 + aarch64), macOS
# (x86_64 + aarch64), and Windows (x86_64).
# 2. Bundles each binary with LICENSE + README into a tarball
# (or zip on Windows).
# 3. Uploads all artifacts to a GH Release DRAFT — you review +
# publish the draft manually. Nothing is public until you hit
# the "Publish release" button.
# 4. Computes a combined SHA256SUMS file across all binaries so
# install.sh can verify.
# 5. Generates a signed build-provenance attestation for every
# released artifact (see "Provenance" below).
#
# What it does NOT do:
# - No auto-publish to Homebrew tap / winget / apt / Nix registry.
# - No auto-bump of version numbers. You bump Cargo.toml
# yourself before running this, then paste the version below.
# - No auto-tag. You tag from the released commit manually after
# the draft is published.
#
# Cost note: uses github-hosted runners (2000 min/mo free for
# public repos). Full matrix is ~15-20 minutes per invocation.
name: cli-release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g. 0.1.0 — no leading v)'
required: true
type: string
dry_run:
description: 'Build binaries but do NOT create a release draft'
required: false
type: boolean
default: false
publish_docker:
description: 'Also build + push the Docker image to ghcr.io/bootintel/cli'
required: false
type: boolean
default: false
# Provenance
# ----------
# Every released artifact gets a signed build-provenance attestation
# via actions/attest-build-provenance. That is a Sigstore signature
# over the artifact digest plus a SLSA statement recording which
# workflow, at which commit, on which runner produced it — so a user
# can verify an artifact really came from this repository's release
# workflow and not from someone's laptop:
#
# gh attestation verify bootintel-v0.3.2-x86_64-linux.tar.gz \
# --repo BootIntel/cli
#
# It is free for public repositories, needs no key material of our own
# (keyless: the runner's OIDC identity is what gets signed, and the
# certificate lives in the public Rekor transparency log), and gives a
# stronger guarantee than a paid code-signing certificate would for
# this audience — it binds the artifact to a *build*, not merely to an
# organisation that paid a CA.
#
# SHA256SUMS stays exactly as it was: it answers "did this download
# arrive intact", which is a different question and still the one
# install.sh asks.
permissions:
contents: write # needed to create the release draft
id-token: write # OIDC identity for keyless attestation signing
attestations: write # write the attestation to the repo's store
jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
asset_name: bootintel-v${{ inputs.version }}-x86_64-linux.tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
asset_name: bootintel-v${{ inputs.version }}-aarch64-linux.tar.gz
cross: true
# x86_64-apple-darwin cross-compiles from an Apple Silicon
# runner (macos-latest = macos-15 as of 2026). The macos-13
# (Intel) runner pool is effectively unavailable on public
# repos — a v0.2.0 dispatch on 2026-08-26 sat queued for 1h47m
# before we gave up. Rust cross-compiles Intel-macos from
# arm64-macos cleanly (single-arch dylib, same Xcode SDK).
- target: x86_64-apple-darwin
os: macos-latest
asset_name: bootintel-v${{ inputs.version }}-x86_64-macos.tar.gz
- target: aarch64-apple-darwin
os: macos-14
asset_name: bootintel-v${{ inputs.version }}-aarch64-macos.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
asset_name: bootintel-v${{ inputs.version }}-x86_64-windows.zip
windows: true
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# Linux serialport backend needs libudev headers.
- name: Install libudev (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
# For cross-compiling to aarch64-linux on an x86_64 GH runner.
- name: Install cross-linker (Linux aarch64)
if: matrix.cross
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu
mkdir -p .cargo
cat >> .cargo/config.toml <<'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cli-release-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
- name: Build release
run: |
cargo build --release --target ${{ matrix.target }} --features tui
- name: Package (Unix)
if: '!matrix.windows'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/bootintel dist/
cp README.md dist/
cp ../LICENSE dist/ 2>/dev/null || echo "LICENSE not found at repo root; skipping"
tar -czf ${{ matrix.asset_name }} -C dist .
- name: Package (Windows)
if: matrix.windows
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item "target\${{ matrix.target }}\release\bootintel.exe" -Destination "dist\"
Copy-Item README.md -Destination "dist\"
if (Test-Path "..\LICENSE") { Copy-Item "..\LICENSE" -Destination "dist\" }
Compress-Archive -Path "dist\*" -DestinationPath ${{ matrix.asset_name }}
- name: Compute SHA256
shell: bash
run: |
if command -v sha256sum >/dev/null; then
sha256sum ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
else
shasum -a 256 ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
fi
cat ${{ matrix.asset_name }}.sha256
# Attest the archive we are about to ship. Runs per-matrix-leg so
# each platform's artifact is attested on the runner that built
# it, which is what makes the provenance meaningful.
#
# Skipped on dry runs: a dry run produces nothing anyone will
# download, and attesting it would put a misleading entry in the
# public transparency log.
- name: Attest build provenance
if: '!inputs.dry_run'
uses: actions/attest-build-provenance@v2
with:
subject-path: ${{ matrix.asset_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: |
${{ matrix.asset_name }}
${{ matrix.asset_name }}.sha256
retention-days: 7
release:
name: create release draft
needs: build
if: '!inputs.dry_run'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Assemble SHA256SUMS
run: |
mkdir release-assets
# NB: parenthesize the -o expression so -type f binds to
# BOTH branches. Without parens, -type f only applies to
# the tar.gz branch, and the zip branch matches the parent
# directory that actions/download-artifact@v4 creates
# (named after the artifact — see
# https://github.com/actions/download-artifact#outputs).
# cp then fails on the directory and the whole job exits 1.
# v0.2.0 dispatch (run 32958967197) hit this. Keep the parens.
find artifacts -type f \( -name 'bootintel-*.tar.gz' -o -name 'bootintel-*.zip' \) | while read f; do
cp "$f" release-assets/
done
find artifacts -type f -name '*.sha256' -exec cat {} \; | sort > release-assets/SHA256SUMS
echo "─────────────────────────────────────"
ls -la release-assets/
echo "─────────────────────────────────────"
cat release-assets/SHA256SUMS
- name: Write release notes
run: |
cat > RELEASE_NOTES.md <<'NOTES'
Release notes: see CHANGELOG.md.
This is a DRAFT — publish manually after verifying artifacts.
## Verify what you downloaded
Checksums are in `SHA256SUMS`:
sha256sum -c SHA256SUMS --ignore-missing
Every archive also carries a signed build-provenance attestation,
so you can confirm it was produced by this repository's release
workflow rather than by someone's laptop:
gh attestation verify <archive> --repo BootIntel/cli
NOTES
# Strip the leading indentation the YAML block required.
sed -i 's/^ //' RELEASE_NOTES.md
cat RELEASE_NOTES.md
- name: Create GH Release DRAFT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "cli-v${{ inputs.version }}" \
--draft \
--title "bootintel-cli v${{ inputs.version }}" \
--notes-file RELEASE_NOTES.md \
release-assets/*
docker:
name: build + push docker image
needs: build
if: inputs.publish_docker && !inputs.dry_run
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build + push (linux/amd64, linux/arm64)
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/bootintel/cli:v${{ inputs.version }}
ghcr.io/bootintel/cli:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Attest image provenance
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/bootintel/cli
subject-digest: ${{ steps.docker_build.outputs.digest }}
push-to-registry: true