Repository navigation
434 lines (388 loc) · 15.2 KB
/
Copy pathrelease-windows.yml
File metadata and controls
434 lines (388 loc) · 15.2 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
name: Release Windows
on:
workflow_call:
inputs:
version:
description: Canonical release version without a v prefix
required: true
type: string
env:
CARGO_TERM_COLOR: always
CI: true
jobs:
build-windows-binaries:
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
target: x86_64-pc-windows-msvc
runner: windows-2025
- arch: arm64
target: aarch64-pc-windows-msvc
runner: windows-11-arm
env:
AGENTDESKTOP_VERSION: ${{ inputs.version }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: frontend/.nvmrc
- name: Install Rust target
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
with:
toolchain: "1.98"
targets: ${{ matrix.target }}
- name: Install frontend dependencies
working-directory: frontend
shell: bash
run: |
npm install --global pnpm@11.25.0
pnpm install --frozen-lockfile
- name: Build Windows binaries
working-directory: frontend
shell: bash
run: pnpm --filter @agentdesktop/desktop-web dist:win -- --build-only --target "${{ matrix.target }}"
- name: Verify embedded release version
shell: pwsh
env:
TARGET: ${{ matrix.target }}
run: |
$binaries = @(
"target/$env:TARGET/release/agentdesktop.exe"
"target/$env:TARGET/release/agentdesktop-service.exe"
)
& .github/scripts/verify-windows-version.ps1 -Path $binaries -Version $env:AGENTDESKTOP_VERSION
- name: Stage unsigned Windows binaries
shell: pwsh
env:
TARGET: ${{ matrix.target }}
run: |
$releaseDirectory = "target/$env:TARGET/release"
$binaries = @("agentdesktop.exe", "agentdesktop-service.exe")
New-Item -ItemType Directory -Force unsigned | Out-Null
foreach ($binary in $binaries) {
$source = Join-Path $releaseDirectory $binary
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) {
throw "Windows binary not found: $source"
}
Copy-Item -LiteralPath $source -Destination unsigned
}
- name: Upload unsigned Windows binaries
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: unsigned-windows-binaries-${{ matrix.arch }}
path: unsigned/*.exe
if-no-files-found: error
retention-days: 1
sign-windows-binaries:
needs: build-windows-binaries
runs-on: windows-2025
environment: production-signing
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
env:
AZURE_CORE_OUTPUT: none
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download unsigned Windows binaries
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: unsigned-windows-binaries-${{ matrix.arch }}
path: signing
- name: Log in to Azure with OIDC
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: Sign Windows binaries
uses: azure/artifact-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0
with:
endpoint: ${{ vars.AZURE_ARTIFACT_SIGNING_ENDPOINT }}
signing-account-name: ${{ vars.AZURE_ARTIFACT_SIGNING_ACCOUNT }}
certificate-profile-name: ${{ vars.AZURE_ARTIFACT_SIGNING_CERTIFICATE_PROFILE }}
files: |
${{ github.workspace }}\signing\agentdesktop.exe
${{ github.workspace }}\signing\agentdesktop-service.exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Verify Windows binary signatures
shell: pwsh
run: |
$binaries = @(
"signing/agentdesktop.exe"
"signing/agentdesktop-service.exe"
)
& .github/scripts/verify-windows-signature.ps1 -Path $binaries
- name: Stage signed standalone binary and checksum
shell: pwsh
env:
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.exe
run: |
New-Item -ItemType Directory -Force release | Out-Null
Copy-Item -LiteralPath signing/agentdesktop.exe -Destination "release/$env:OUTPUT_NAME"
$hash = (Get-FileHash "release/$env:OUTPUT_NAME" -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash $env:OUTPUT_NAME" | Set-Content "release/$env:OUTPUT_NAME.sha256" -Encoding ascii
- name: Upload signed Windows payload
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: signed-windows-payload-${{ matrix.arch }}
path: signing/*.exe
if-no-files-found: error
retention-days: 1
- name: Upload signed standalone Windows binary
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-binary-windows-${{ matrix.arch }}
path: release/agentdesktop-windows-*
if-no-files-found: error
build-windows-installers:
needs: sign-windows-binaries
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
target: x86_64-pc-windows-msvc
runner: windows-2025
- arch: arm64
target: aarch64-pc-windows-msvc
runner: windows-11-arm
env:
AGENTDESKTOP_VERSION: ${{ inputs.version }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: frontend/.nvmrc
- name: Install Rust target
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
with:
toolchain: "1.98"
targets: ${{ matrix.target }}
- name: Install frontend dependencies
working-directory: frontend
shell: bash
run: |
npm install --global pnpm@11.25.0
pnpm install --frozen-lockfile
- name: Download signed Windows payload
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: signed-windows-payload-${{ matrix.arch }}
path: target/${{ matrix.target }}/release
- name: Verify packaged Windows payload signatures
shell: pwsh
env:
TARGET: ${{ matrix.target }}
run: |
$binaries = @(
"target/$env:TARGET/release/agentdesktop.exe"
"target/$env:TARGET/release/agentdesktop-service.exe"
)
& .github/scripts/verify-windows-signature.ps1 -Path $binaries
- name: Build MSI from signed Windows payload
working-directory: frontend
shell: bash
run: pnpm --filter @agentdesktop/desktop-web dist:win -- --bundle-only --target "${{ matrix.target }}"
- name: Stage MSI
shell: pwsh
env:
TARGET: ${{ matrix.target }}
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.msi
run: |
$installers = @(Get-ChildItem "target/$env:TARGET/release/bundle/msi" -Filter *.msi)
if ($installers.Count -ne 1) {
throw "Expected one MSI, found $($installers.Count)"
}
New-Item -ItemType Directory -Force release | Out-Null
Copy-Item $installers[0].FullName "release/$env:OUTPUT_NAME"
- name: Upload unsigned MSI
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: unsigned-windows-installer-${{ matrix.arch }}
path: release/*.msi
if-no-files-found: error
retention-days: 1
sign-windows-installers:
needs: build-windows-installers
runs-on: windows-2025
environment: production-signing
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
env:
AZURE_CORE_OUTPUT: none
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download unsigned MSI
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: unsigned-windows-installer-${{ matrix.arch }}
path: release
- name: Log in to Azure with OIDC
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: Sign MSI
uses: azure/artifact-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0
with:
endpoint: ${{ vars.AZURE_ARTIFACT_SIGNING_ENDPOINT }}
signing-account-name: ${{ vars.AZURE_ARTIFACT_SIGNING_ACCOUNT }}
certificate-profile-name: ${{ vars.AZURE_ARTIFACT_SIGNING_CERTIFICATE_PROFILE }}
files: ${{ github.workspace }}\release\agentdesktop-windows-${{ matrix.arch }}.msi
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Verify MSI signature
shell: pwsh
env:
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.msi
run: |
& .github/scripts/verify-windows-signature.ps1 -Path "release/$env:OUTPUT_NAME"
- name: Checksum signed MSI
shell: pwsh
env:
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.msi
run: |
$hash = (Get-FileHash "release/$env:OUTPUT_NAME" -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash $env:OUTPUT_NAME" | Set-Content "release/$env:OUTPUT_NAME.sha256" -Encoding ascii
- name: Upload signed MSI
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: signed-windows-installer-${{ matrix.arch }}
path: release/agentdesktop-windows-*
if-no-files-found: error
test-windows-installers:
needs: sign-windows-installers
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: windows-2025
- arch: arm64
runner: windows-11-arm
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download signed MSI
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: signed-windows-installer-${{ matrix.arch }}
path: release
- name: Verify signed MSI
shell: pwsh
env:
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.msi
run: |
& .github/scripts/verify-windows-signature.ps1 -Path "release/$env:OUTPUT_NAME"
- name: Smoke test MSI install, replacement, and uninstall
shell: pwsh
env:
OUTPUT_NAME: agentdesktop-windows-${{ matrix.arch }}.msi
run: |
function Assert-MsiSuccess($process, $operation) {
if ($process.ExitCode -notin @(0, 3010)) {
throw "MSI $operation failed with exit code $($process.ExitCode)"
}
}
function Wait-ForAgentDesktopService {
$service = Get-Service AgentDesktop
$service.WaitForStatus("Running", [TimeSpan]::FromSeconds(30))
$deadline = (Get-Date).AddSeconds(30)
do {
& "$env:ProgramFiles\Agent Desktop\agentdesktop.exe" status
if ($LASTEXITCODE -eq 0) {
return
}
Start-Sleep -Seconds 1
} while ((Get-Date) -lt $deadline)
throw "Installed CLI could not reach the Agent Desktop service"
}
$installer = (Resolve-Path "release/$env:OUTPUT_NAME").Path
$install = Start-Process msiexec.exe -ArgumentList @("/i", "`"$installer`"", "/qn", "/norestart") -Wait -PassThru
Assert-MsiSuccess $install "installation"
Wait-ForAgentDesktopService
$installedBinaries = @(
"$env:ProgramFiles\Agent Desktop\agentdesktop.exe"
"$env:ProgramFiles\Agent Desktop\agentdesktop-service.exe"
)
& .github/scripts/verify-windows-signature.ps1 -Path $installedBinaries
$configPath = "$env:ProgramData\AgentDesktop\config.yaml"
$stateMarker = "$env:ProgramData\AgentDesktop\state\upgrade-smoke-marker"
$configHash = (Get-FileHash $configPath -Algorithm SHA256).Hash
New-Item -ItemType Directory -Force (Split-Path $stateMarker) | Out-Null
New-Item -ItemType File -Force $stateMarker | Out-Null
$tray = Start-Process "$env:ProgramFiles\Agent Desktop\agentdesktop.exe" -PassThru
Start-Sleep -Seconds 3
if ($tray.HasExited) {
throw "Agent Desktop tray process exited before replacement"
}
$replace = Start-Process msiexec.exe -ArgumentList @(
"/i",
"`"$installer`"",
"/qn",
"/norestart",
"REINSTALL=ALL",
"REINSTALLMODE=vomus"
) -Wait -PassThru
Assert-MsiSuccess $replace "replacement"
$tray.Refresh()
if (-not $tray.HasExited) {
throw "Agent Desktop tray process remains after replacement"
}
Wait-ForAgentDesktopService
if ((Get-FileHash $configPath -Algorithm SHA256).Hash -ne $configHash) {
throw "Agent Desktop configuration changed during replacement"
}
if (-not (Test-Path $stateMarker)) {
throw "Agent Desktop state was removed during replacement"
}
$uninstall = Start-Process msiexec.exe -ArgumentList @("/x", "`"$installer`"", "/qn", "/norestart") -Wait -PassThru
Assert-MsiSuccess $uninstall "uninstall"
if (Get-Service AgentDesktop -ErrorAction SilentlyContinue) {
throw "Agent Desktop service remains after uninstall"
}