Repository navigation
335 lines (327 loc) · 17 KB
/
Copy pathdesktop-signing.yml
File metadata and controls
335 lines (327 loc) · 17 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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
name: Desktop Windows signing
on:
workflow_dispatch:
inputs:
signing-mode:
description: Opt in to signing with the protected Azure Key Vault certificate
type: choice
options: [none, keyvault]
default: none
required: true
release-tag:
description: Attach the signed installer to this existing release. Run from that tag.
type: string
default: ""
required: false
# publish-release.yml says whether the release becomes Latest. A stable release becomes
# Latest once both this and Desktop macOS signing have attached their signed installers,
# in whichever finishes second. Signing a release again by hand leaves Latest alone unless
# this is set.
make-latest:
description: Mark the release Latest once every signed installer is attached, unless a newer release already is
type: boolean
default: false
required: false
# A label permits validation before this workflow exists on main. New pushes
# run only the checks: remove/reapply the label to request signing a new head.
pull_request:
types: [opened, synchronize, reopened, labeled]
paths:
- desktop/**
- package.json
- .github/workflows/desktop-signing.yml
- .github/workflows/publish-release.yml
- scripts/release-*
- docs/windows-signing.md
permissions:
contents: read
concurrency:
group: desktop-windows-signing-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false
# Match the source publisher's exact repository/distribution identity in official and fork builds.
env:
OPENBOT_DISTRIBUTION_ID: ${{ vars.OPENBOT_DISTRIBUTION_ID || github.repository }}
OPENBOT_RELEASE_REPOSITORY: ${{ github.repository }}
OPENBOT_RELEASE_CHANNEL: ${{ vars.OPENBOT_RELEASE_CHANNEL || 'stable' }}
jobs:
checks:
name: Signing regressions (no Azure access)
runs-on: windows-2025
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: PowerShell signing regressions
shell: pwsh
run: ./desktop/scripts/test-windows-signing.ps1
# A stable release becomes Latest only once this workflow's signed installer is on it too, so
# the Windows download link never serves the unsigned one. The scripts behind it run in
# Updater regressions (no Apple access) and the main test suite; this checks the wiring here.
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
- name: Latest waits for the signed Windows installer
run: bun test scripts/signing-workflows.test.ts
working-directory: desktop
sign:
name: Sign and verify app and NSIS installer
needs: checks
outputs:
# The artifact of the attempt that signed, so a re-run of `publish` alone attaches the
# installer that attempt verified, not one from an earlier attempt.
artifact: openbot-windows-signed-${{ github.run_id }}-${{ github.run_attempt }}
# Whether the build carries the updater: every build but a pinned candidate or beta.
updater: ${{ steps.build.outputs.updater }}
if: >-
(github.event_name == 'workflow_dispatch' && inputs.signing-mode == 'keyvault') ||
(github.event_name == 'pull_request' && github.event.action == 'labeled' &&
github.event.label.name == 'windows-signing' &&
github.event.pull_request.head.repo.full_name == github.repository)
environment: windows-signing
permissions:
contents: read
id-token: write
runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'windows-2025' || 'openbot-windows-16core' }}
timeout-minutes: 60
defaults:
run:
shell: pwsh
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_KEY_VAULT_URL: ${{ vars.AZURE_KEY_VAULT_URL }}
CODE_SIGNING_CERT_NAME: ${{ vars.CODE_SIGNING_CERT_NAME }}
SIGNING_SOURCE_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
AZURE_CORE_OUTPUT: none
steps:
# The whole history: an internal build is numbered by its commit count (desktop-version.ts).
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Check signing configuration
run: |
foreach ($name in @('AZURE_CLIENT_ID', 'AZURE_TENANT_ID', 'AZURE_SUBSCRIPTION_ID', 'AZURE_KEY_VAULT_URL', 'CODE_SIGNING_CERT_NAME')) {
if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) {
throw "Missing windows-signing environment variable: $name"
}
}
if ((git rev-parse HEAD) -ne $env:SIGNING_SOURCE_SHA) { throw 'Checkout does not match requested source SHA.' }
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Check certificate access
run: |
az keyvault certificate show --id "$env:AZURE_KEY_VAULT_URL/certificates/$env:CODE_SIGNING_CERT_NAME" --query id --output tsv --only-show-errors
if ($LASTEXITCODE -ne 0) { throw 'Could not read signing certificate.' }
# No caches in this job, Rust or Bun: a release attaches what it builds, and a signed
# installer must come from the tree and the lockfiles, not from anything an earlier run left
# behind. The same rule as Desktop macOS signing.
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: stable
- name: Install pinned AzureSignTool
run: |
$toolDirectory = Join-Path $env:RUNNER_TEMP 'azuresigntool-7.0.1'
New-Item -ItemType Directory -Path $toolDirectory -Force | Out-Null
$tool = Join-Path $toolDirectory 'AzureSignTool.exe'
Invoke-WebRequest 'https://github.com/vcsjones/AzureSignTool/releases/download/v7.0.1/AzureSignTool-x64.exe' -OutFile $tool
if ((Get-FileHash -LiteralPath $tool -Algorithm SHA256).Hash -ne 'DC85A3F24BCD5978C63FCFD167A9B41313AF9116722B99B831400F05F387FCBA') {
throw 'AzureSignTool download hash mismatch.'
}
$toolDirectory | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
- run: bun install --frozen-lockfile
working-directory: desktop
- run: bun run typecheck
working-directory: desktop
# A tag is a release, and its installer carries the release version, as the unsigned one
# it replaces does. Anything else is an internal build named after its commit.
- name: Prepare the build version
run: |
if ($env:GITHUB_REF_TYPE -eq 'tag') {
bun scripts/desktop-version.ts release
} else {
bun scripts/desktop-version.ts internal
}
if ($LASTEXITCODE -ne 0) { throw 'Could not prepare the build version.' }
Get-Content build-version.json
working-directory: desktop
# signed-build.ts builds what desktop-build.yml built for the same release: a candidate or
# beta pinned to its release's images, and the CLI whenever the tree can bundle one. On a
# release this signed installer replaces the unsigned one, so it must be the same product.
# Anything else (a pull request, a branch) is an ordinary internal build, as before.
# The overlay also carries the updater, `plugins.updater` with the same public key and
# endpoints as the Mac's, so a signed Windows app is offered and installs updates the way a
# Mac does. Not `createUpdaterArtifacts`: the updater key is not in this environment, and the
# file the Windows updater installs is this installer itself, signed for it by `sign-update`.
# Tauri downloads NSIS from GitHub the first time it bundles, once and with no retry, and a 504
# there fails the release. This puts the same pinned, checksummed toolset desktop-build.yml
# fetches where Tauri looks first, so the build below downloads nothing. Not a cache: the
# files come from their releases on every run and are checked against pins in the tree.
- name: Fetch Tauri's bundling tools
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: desktop/scripts/prefetch-tauri-tools.sh windows
- name: Build and sign
id: build
env:
WINDOWS_SIGNING: keyvault
# To read the release's container-images.json when this build is a candidate.
GH_TOKEN: ${{ github.token }}
OPENBOT_GOOGLE_MODEL_OAUTH_CLIENT_ID: ${{ vars.OPENBOT_GOOGLE_MODEL_OAUTH_CLIENT_ID }}
OPENBOT_GOOGLE_MODEL_OAUTH_CLIENT_SECRET: ${{ secrets.OPENBOT_GOOGLE_MODEL_OAUTH_CLIENT_SECRET }}
OPENBOT_GOOGLE_MODEL_OAUTH_QUOTA_PROJECT: ${{ vars.OPENBOT_GOOGLE_MODEL_OAUTH_QUOTA_PROJECT }}
run: bun scripts/signed-build.ts win32 x64 src-tauri/tauri.windows-signing.conf.json --bundles nsis
working-directory: desktop
# Tauri restores the unsigned build output after bundling. Verify the app
# employees receive by extracting its signed payload from the installer.
- name: Extract signed app from NSIS installer
run: |
$installers = @(Get-ChildItem 'desktop/src-tauri/target/release/bundle/nsis/*-setup.exe' -File)
if ($installers.Count -ne 1) { throw 'Expected exactly one NSIS installer.' }
& 7z e $installers[0].FullName '-odesktop/signed-app' '-r' '-y' 'openbot-desktop.exe'
if ($LASTEXITCODE -ne 0) { throw 'Could not extract signed app from NSIS installer.' }
# The CLI is in what people install, not only in the build folder.
- name: Verify the installer carries the Intelligence CLI
run: |
$installers = @(Get-ChildItem 'desktop/src-tauri/target/release/bundle/nsis/*-setup.exe' -File)
$listing = & 7z l $installers[0].FullName
if ($LASTEXITCODE -ne 0) { throw 'Could not list the NSIS installer.' }
foreach ($file in @('cli-bundle\runtime\node.exe', 'cli-bundle\cli\index.js')) {
if (-not ($listing | Select-String -SimpleMatch $file)) { throw "The installer has no $file." }
}
- name: Verify publisher, trust, and timestamp on both executables
run: |
$build = Get-Content desktop/build-version.json -Raw | ConvertFrom-Json
./desktop/scripts/verify-windows-signatures.ps1 -ExpectedVersion $build.version
- name: Retain verified binaries
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: openbot-windows-signed-${{ github.run_id }}-${{ github.run_attempt }}
path: |
desktop/signed-app/openbot-desktop.exe
desktop/src-tauri/target/release/bundle/nsis/*-setup.exe
desktop/build-version.json
if-no-files-found: error
retention-days: 14
- name: Retain verification evidence
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: openbot-windows-signatures-${{ github.run_id }}-${{ github.run_attempt }}
path: desktop/signing-evidence/
if-no-files-found: warn
retention-days: 14
# The updater's signature over the installer. On Windows the updater installs the NSIS installer
# itself, so it is signed here, after Authenticode signing, over exactly the bytes the signing job
# verified and people download. The updater key is the one Desktop macOS signing signs with, and
# it lives in the `macos-signing` environment only, so this job runs there: its reviewers approve
# it as they approve the Mac build, and the key is never in `windows-signing`. It needs no
# repository write access and no Azure access. Only a run that attaches to a release signs for
# the updater; a pinned candidate or beta has no updater.
sign-update:
name: Sign the installer for the updater
needs: sign
if: >-
github.event_name == 'workflow_dispatch' && inputs.release-tag != '' &&
needs.sign.outputs.updater == 'true'
environment: macos-signing
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
outputs:
artifact: openbot-windows-updater-signature-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
# The Tauri CLI the build used, from the lockfile, to sign as `tauri build` signs.
- run: bun install --frozen-lockfile
working-directory: desktop
- name: Install minisign
run: sudo apt-get install -y --no-install-recommends minisign
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.sign.outputs.artifact }}
path: artifacts
- name: Sign and verify against the app's public key
env:
ARTIFACTS: artifacts
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: desktop/scripts/sign-windows-update.sh
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: openbot-windows-updater-signature-${{ github.run_id }}-${{ github.run_attempt }}
path: artifacts/src-tauri/target/release/bundle/nsis/*-setup.exe.sig
if-no-files-found: error
retention-days: 14
# The signed installer onto the release, from a job of its own so the signing job never holds a
# token that can write to the repository. It replaces the unsigned installer the release was
# published with, under the name Tauri gave it and under the fixed name a web page links to
# (scripts/release-download-names.sh). Both, or the stable link keeps serving the unsigned build.
# For a build with the updater it attaches the updater signature too, and lists the installer in
# latest.json as `windows-x86_64`, beside the Mac archives. `--clobber` makes a re-run replace
# them again. The details are in desktop/scripts/publish-signed-windows.sh.
publish:
name: Attach to the release
needs: [sign, sign-update]
# One attach job at a time per release, across Desktop macOS signing and Desktop Windows
# signing: each ends by asking whether every signed installer is on the release, and the one
# that runs second must see what the first attached, or neither would make it Latest. Same
# group in both workflows; an attach that is running is never cancelled.
concurrency:
group: release-attach-${{ inputs.release-tag || github.ref_name }}
cancel-in-progress: false
# After sign-update, or without it for a pinned build, which it skips.
if: >-
!cancelled() && needs.sign.result == 'success' &&
(needs.sign-update.result == 'success' || needs.sign-update.result == 'skipped') &&
github.event_name == 'workflow_dispatch' && inputs.release-tag != ''
runs-on: ubuntu-latest
timeout-minutes: 15
# `actions: write` to start Downloads sync when this run makes the release Latest
# (scripts/release-make-latest.sh).
permissions:
contents: write
actions: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ inputs.release-tag }}
MAKE_LATEST: ${{ inputs.make-latest }}
# Tags kept from Latest for a staged rollout (scripts/release-make-latest.sh).
HOLD_LATEST: ${{ vars.RELEASE_HOLD_LATEST }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.sign.outputs.artifact }}
path: artifacts
- if: needs.sign-update.result == 'success'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ needs.sign-update.outputs.artifact }}
path: artifacts/updater-signature
- name: Attach to the release
env:
ARTIFACTS: artifacts
run: desktop/scripts/publish-signed-windows.sh