forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 43
509 lines (443 loc) · 18.4 KB
/
Copy pathelectron-desktop.yml
File metadata and controls
509 lines (443 loc) · 18.4 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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
name: Electron Desktop
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
publish:
description: "Publish to GitHub Releases"
required: false
default: false
type: boolean
# Only allow one release build at a time to avoid race conditions on GitHub Releases.
concurrency:
group: electron-desktop-${{ github.ref }}
cancel-in-progress: true
jobs:
build-macos:
runs-on: macos-14
timeout-minutes: 90
permissions:
contents: write
env:
# Provide a GitHub token to all steps so fetch-*-runtime scripts
# can authenticate and avoid GitHub API rate limits (60 req/h → 5000 req/h).
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Checkout submodules (retry)
run: |
set -euo pipefail
git submodule sync --recursive
for attempt in 1 2 3 4 5; do
if git -c protocol.version=2 submodule update --init --force --depth=1 --recursive; then
exit 0
fi
echo "Submodule update failed (attempt $attempt/5). Retrying…"
sleep $((attempt * 10))
done
exit 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
check-latest: true
- name: Setup pnpm (corepack retry)
run: |
set -euo pipefail
corepack enable
for attempt in 1 2 3; do
if corepack prepare pnpm@10.23.0 --activate; then
pnpm -v
exit 0
fi
echo "corepack prepare failed (attempt $attempt/3). Retrying..."
sleep $((attempt * 10))
done
exit 1
- name: Runtime versions
run: |
node -v
npm -v
pnpm -v
- name: Install root dependencies
run: pnpm install --frozen-lockfile
- name: Install electron-desktop dependencies
working-directory: apps/electron-desktop
run: npm ci
- name: Build main + renderer
working-directory: apps/electron-desktop
run: npm run build:all
env:
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
- name: Prepare OpenClaw bundle
working-directory: apps/electron-desktop
run: npm run prepare:openclaw:ci
- name: Prepare Node runtime
working-directory: apps/electron-desktop
run: npm run prepare:node
- name: Prepare jq runtime
working-directory: apps/electron-desktop
run: npm run prepare:jq:all
- name: Prepare gh runtime
working-directory: apps/electron-desktop
run: npm run prepare:gh:all
- name: Prepare GOG runtime
working-directory: apps/electron-desktop
run: npm run prepare:gog:all
- name: Prepare memo runtime
working-directory: apps/electron-desktop
run: npm run prepare:memo:all
- name: Prepare remindctl runtime
working-directory: apps/electron-desktop
run: npm run prepare:remindctl:all
- name: Prepare obsidian-cli runtime
working-directory: apps/electron-desktop
run: npm run prepare:obsidian-cli:all
- name: Prepare whisper-cli runtime
working-directory: apps/electron-desktop
run: npm run prepare:whisper-cli:all
# Determine if we should publish to GitHub Releases.
- name: Determine publish mode
id: publish-mode
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.publish }}" == "true" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "tag=v$(node -p "require('./apps/electron-desktop/package.json').version")" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi
# Write the App Store Connect API key to a temp file for notarytool.
# The NOTARYTOOL_KEY secret contains the .p8 key content; notarytool expects a file path.
- name: Write notary API key to file
if: env.NOTARYTOOL_KEY_CONTENT != ''
run: |
KEY_PATH="$RUNNER_TEMP/notary-key.p8"
echo "$NOTARYTOOL_KEY_CONTENT" > "$KEY_PATH"
chmod 600 "$KEY_PATH"
echo "NOTARYTOOL_KEY=$KEY_PATH" >> "$GITHUB_ENV"
env:
NOTARYTOOL_KEY_CONTENT: ${{ secrets.NOTARYTOOL_KEY }}
# Raise open file limit — electron-builder code signing opens every file in the
# .app bundle (including bundled node_modules) and the default macOS limit (256)
# is too low. Both launchctl and ulimit are needed on macOS runners.
- name: Raise file descriptor limit
run: |
echo "Before: soft=$(ulimit -Sn) hard=$(ulimit -Hn)"
sudo launchctl limit maxfiles 524288 524288
ulimit -n 524288
echo "After: soft=$(ulimit -Sn) hard=$(ulimit -Hn)"
# Build with --publish never. Uploads are handled separately via gh CLI
# to avoid electron-builder HTTP timeouts during long notarization waits.
- name: Build with electron-builder
working-directory: apps/electron-desktop
run: |
ulimit -n 524288
npx electron-builder --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: ${{ secrets.MACOS_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.MACOS_CSC_KEY_PASSWORD }}
CSC_IDENTITY_AUTO_DISCOVERY: ${{ secrets.MACOS_CSC_LINK != '' && 'true' || 'false' }}
NOTARIZE: ${{ secrets.NOTARYTOOL_KEY != '' && secrets.MACOS_CSC_LINK != '' && '1' || '' }}
NOTARYTOOL_KEY_ID: ${{ secrets.NOTARYTOOL_KEY_ID }}
NOTARYTOOL_ISSUER: ${{ secrets.NOTARYTOOL_ISSUER }}
# Generate latest-mac.yml for electron-updater (normally created by --publish always).
- name: Generate latest-mac.yml
working-directory: apps/electron-desktop/release
run: |
set -euo pipefail
VERSION=$(node -p "require('../package.json').version")
ZIP=$(ls -1 *-mac.zip | head -1)
SHA512=$(shasum -a 512 "$ZIP" | awk '{print $1}' | xxd -r -p | base64)
SIZE=$(stat -f%z "$ZIP")
RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
cat > latest-mac.yml <<EOF
version: ${VERSION}
files:
- url: ${ZIP}
sha512: ${SHA512}
size: ${SIZE}
path: ${ZIP}
sha512: ${SHA512}
releaseDate: '${RELEASE_DATE}'
EOF
# Remove leading whitespace from heredoc indentation.
sed -i '' 's/^ //' latest-mac.yml
echo "Generated latest-mac.yml:"
cat latest-mac.yml
# Create draft GitHub Release and upload all artifacts via gh CLI.
# gh CLI handles large files reliably without the timeout issues of electron-builder.
- name: Publish to GitHub Releases
if: steps.publish-mode.outputs.publish == 'true'
working-directory: apps/electron-desktop/release
run: |
set -euo pipefail
TAG="${{ steps.publish-mode.outputs.tag }}"
# Create draft release (or skip if it already exists).
gh release create "$TAG" --draft --title "$TAG" --generate-notes 2>/dev/null || true
# Upload all artifacts (zip, dmg, blockmap, latest-mac.yml).
for f in *.zip *.dmg *.blockmap latest-mac.yml; do
if [[ -f "$f" ]]; then
echo "Uploading: $f"
gh release upload "$TAG" "$f" --clobber
fi
done
echo "Draft release created: $TAG"
echo "Go to GitHub Releases to review and publish."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload artifacts for manual dispatch builds (when not publishing to Releases).
- name: Upload build artifacts
if: steps.publish-mode.outputs.publish == 'false'
uses: actions/upload-artifact@v4
with:
name: electron-desktop-macos-${{ runner.arch }}
path: |
apps/electron-desktop/release/*.zip
apps/electron-desktop/release/*.dmg
apps/electron-desktop/release/*.blockmap
apps/electron-desktop/release/latest-mac.yml
if-no-files-found: error
retention-days: 14
build-windows:
runs-on: windows-latest
timeout-minutes: 90
permissions:
contents: write
defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_PLATFORM: win32
TARGET_ARCH: x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Checkout submodules (retry)
run: |
set -euo pipefail
git submodule sync --recursive
for attempt in 1 2 3 4 5; do
if git -c protocol.version=2 submodule update --init --force --depth=1 --recursive; then
exit 0
fi
echo "Submodule update failed (attempt $attempt/5). Retrying…"
sleep $((attempt * 10))
done
exit 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
check-latest: true
- name: Setup pnpm (corepack retry)
run: |
set -euo pipefail
corepack enable
for attempt in 1 2 3; do
if corepack prepare pnpm@10.23.0 --activate; then
pnpm -v
exit 0
fi
echo "corepack prepare failed (attempt $attempt/3). Retrying..."
sleep $((attempt * 10))
done
exit 1
- name: Runtime versions
run: |
node -v
npm -v
pnpm -v
- name: Install root dependencies
run: pnpm install --frozen-lockfile
- name: Install electron-desktop dependencies
working-directory: apps/electron-desktop
run: npm ci
- name: Build main + renderer
working-directory: apps/electron-desktop
run: npm run build:all
env:
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
- name: Prepare OpenClaw bundle
working-directory: apps/electron-desktop
run: npm run prepare:openclaw:ci
- name: Prepare Node runtime
working-directory: apps/electron-desktop
run: npm run prepare:node
- name: Prepare jq runtime
working-directory: apps/electron-desktop
run: npm run prepare:jq:all
- name: Prepare gh runtime
working-directory: apps/electron-desktop
run: npm run prepare:gh:all
- name: Prepare GOG runtime
working-directory: apps/electron-desktop
run: npm run prepare:gog:all
# memo and remindctl are macOS-only — skipped for Windows.
- name: Prepare obsidian-cli runtime
working-directory: apps/electron-desktop
run: npm run prepare:obsidian-cli:all
- name: Prepare whisper-cli runtime
working-directory: apps/electron-desktop
run: npm run prepare:whisper-cli:all
- name: Determine publish mode
id: publish-mode
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.publish }}" == "true" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "tag=v$(node -p "require('./apps/electron-desktop/package.json').version")" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup DigiCert KeyLocker (Windows)
shell: pwsh
env:
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
run: |
$headers = @{
"x-api-key" = $env:SM_API_KEY
}
$smctlUrl = "https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download"
Invoke-WebRequest -Uri $smctlUrl -Headers $headers -OutFile smtools.msi
Start-Process msiexec.exe -ArgumentList "/i", "smtools.msi", "/quiet", "/norestart" -Wait
$smctlPath = "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools"
echo "$smctlPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$certBytes = [Convert]::FromBase64String($env:SM_CLIENT_CERT_FILE_B64)
$certPath = "$env:RUNNER_TEMP\digicert_client_cert.p12"
[IO.File]::WriteAllBytes($certPath, $certBytes)
echo "SM_CLIENT_CERT_FILE=$certPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Verify DigiCert KeyLocker Setup (Windows)
shell: pwsh
env:
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
SM_HOST: https://clientauth.one.digicert.com
run: smctl healthcheck
- name: Sync certificates to Windows Store (Windows)
shell: pwsh
env:
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
SM_HOST: https://clientauth.one.digicert.com
run: smctl windows certsync
- name: Setup Windows SDK signtool (Windows)
shell: pwsh
run: |
$signtoolPath = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits\10\bin" -Recurse -Filter "signtool.exe" -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -like "*\x64\*" } |
Sort-Object { [version]($_.FullName -replace '.*\\(\d+\.\d+\.\d+\.\d+)\\.*', '$1') } -Descending |
Select-Object -First 1
if ($signtoolPath) {
$signtoolDir = $signtoolPath.DirectoryName
Write-Host "Found signtool at: $signtoolDir"
echo "$signtoolDir" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
} else {
Write-Error "signtool.exe not found in Windows SDK"
exit 1
}
- name: Build with electron-builder (Windows)
working-directory: apps/electron-desktop
run: npx electron-builder --win --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sign Windows binaries with DigiCert KeyLocker
shell: pwsh
env:
SM_API_KEY: ${{ secrets.SM_API_KEY }}
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
SM_CODE_SIGNING_CERT_SHA1_HASH: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
SM_HOST: https://clientauth.one.digicert.com
run: |
$releasePath = "apps\electron-desktop\release"
$unpacked = "$releasePath\win-unpacked"
# Targeted collection: Electron core + bundled tools only.
# Native addons (openclaw node_modules), whisper-cli (already signed),
# and app.asar.unpacked (pre-signed earlier) are skipped.
$files = @()
$files += Get-ChildItem -Path $releasePath -File -Filter "*.exe" -ErrorAction SilentlyContinue
$files += Get-ChildItem -Path $unpacked -File -Filter "*.exe" -ErrorAction SilentlyContinue
$files += Get-ChildItem -Path $unpacked -File -Filter "*.dll" -ErrorAction SilentlyContinue
if (Test-Path "$unpacked\resources\elevate.exe") {
$files += Get-Item "$unpacked\resources\elevate.exe"
}
# Bundled tool exes: gh, gog, jq, node, obsidian-cli
$files += Get-ChildItem -Path "$unpacked\resources\*\win32-x64\*.exe" -File -ErrorAction SilentlyContinue
# node-pty spawned exes (winpty-agent.exe, OpenConsole.exe) - unsigned triggers Defender
$files += Get-ChildItem -Path "$unpacked\resources\app.asar.unpacked" -Recurse -File -Filter "*.exe" -ErrorAction SilentlyContinue
$files = $files | Sort-Object FullName -Unique
if (-not $files) {
Write-Error "No binaries found for signing under $releasePath"
exit 1
}
Write-Host "Signing $($files.Count) binaries (Electron core + bundled tools)"
foreach ($file in $files) {
Write-Host "Signing release binary: $($file.FullName)"
signtool sign /sha1 $env:SM_CODE_SIGNING_CERT_SHA1_HASH /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 "$($file.FullName)"
signtool verify /pa "$($file.FullName)"
}
- name: Generate latest.yml
working-directory: apps/electron-desktop/release
run: |
set -euo pipefail
VERSION=$(node -p "require('../package.json').version")
EXE=$(ls -1 *.exe | head -1)
SHA512=$(sha512sum "$EXE" | awk '{print $1}' | xxd -r -p | base64)
SIZE=$(stat -c%s "$EXE")
RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
cat > latest.yml <<EOF
version: ${VERSION}
files:
- url: ${EXE}
sha512: ${SHA512}
size: ${SIZE}
path: ${EXE}
sha512: ${SHA512}
releaseDate: '${RELEASE_DATE}'
EOF
sed -i 's/^ //' latest.yml
echo "Generated latest.yml:"
cat latest.yml
- name: Publish to GitHub Releases
if: steps.publish-mode.outputs.publish == 'true'
working-directory: apps/electron-desktop/release
run: |
set -euo pipefail
TAG="${{ steps.publish-mode.outputs.tag }}"
gh release create "$TAG" --draft --title "$TAG" --generate-notes 2>/dev/null || true
for f in *.exe *.blockmap latest.yml; do
if [[ -f "$f" ]]; then
echo "Uploading: $f"
gh release upload "$TAG" "$f" --clobber
fi
done
echo "Windows artifacts uploaded to draft release: $TAG"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
if: steps.publish-mode.outputs.publish == 'false'
uses: actions/upload-artifact@v4
with:
name: electron-desktop-windows-x64
path: |
apps/electron-desktop/release/*.exe
apps/electron-desktop/release/*.blockmap
apps/electron-desktop/release/latest.yml
if-no-files-found: error
retention-days: 14