Repository navigation
1273 lines (1246 loc) · 63.2 KB
/
Copy pathrelease.yml
File metadata and controls
1273 lines (1246 loc) · 63.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
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Release desktop installers
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
mode:
description: 操作(development 开发包 / signed 测试包 / prerelease 预发布 / publish 继续正式发布 / resign 重签)
required: true
default: development
type: choice
options:
- development
- signed
- prerelease
- publish
- resign
target:
description: 平台(继续正式发布选 all,重签选 windows)
required: true
default: all
type: choice
options:
- all
- windows
- macos
version:
description: 版本(开发包留空;测试包如 0.13.0-test.4;继续正式发布如 v0.13.0)
required: false
type: string
source_run_id:
description: 来源任务 ID(仅继续正式发布或重签需要)
required: false
type: string
checks:
description: 验证级别(standard 常规 / extended 增加 Windows 全量测试、恢复界面、启动与归档检查)
required: true
default: standard
type: choice
options:
- standard
- extended
permissions:
contents: write
env:
RELEASE_NOTES_MODEL: gpt-6-luna
concurrency:
# Platform-only retries have independent artifacts and never publish.
group: desktop-release-${{ github.ref }}-${{ inputs.target || 'all' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
validate-dispatch:
name: Validate dispatch inputs
runs-on: ubuntu-24.04
steps:
- name: Validate workflow_dispatch inputs
if: github.event_name == 'workflow_dispatch'
env:
MODE: ${{ inputs.mode }}
TARGET: ${{ inputs.target }}
VERSION: ${{ inputs.version }}
SOURCE_RUN_ID: ${{ inputs.source_run_id }}
CHECKS: ${{ inputs.checks }}
run: |
set -euo pipefail
semver_re='^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$'
if ! [[ "$TARGET" =~ ^(all|windows|macos)$ ]] || ! [[ "$CHECKS" =~ ^(standard|extended)$ ]]; then
echo "::error::Choose a valid platform and validation level"
exit 1
fi
case "$MODE" in
publish)
if [ "$TARGET" != 'all' ] || ! [[ "$VERSION" =~ ^v[0-9]+[.][0-9]+[.][0-9]+$ ]] || ! [[ "$SOURCE_RUN_ID" =~ ^[1-9][0-9]*$ ]]; then
echo "::error::publish requires target=all, version=vX.Y.Z and a positive source_run_id"
exit 1
fi
;;
signed|prerelease|resign)
if ! [[ "$VERSION" =~ $semver_re ]]; then
echo "::error::$MODE requires a non-v semver version (e.g. 0.13.0-test.4)"
exit 1
fi
if [ "$MODE" = 'resign' ]; then
if [ "$TARGET" != 'windows' ] || ! [[ "$SOURCE_RUN_ID" =~ ^[1-9][0-9]*$ ]]; then
echo "::error::resign requires target=windows and a positive source_run_id"
exit 1
fi
elif [ -n "$SOURCE_RUN_ID" ]; then
echo "::error::source_run_id is only used by publish or resign"
exit 1
fi
if [ "$MODE" = 'prerelease' ] && [ "$TARGET" != 'all' ]; then
echo "::notice::target=$TARGET with prerelease mode will sign only and skip GitHub/ModelScope publish"
fi
;;
development)
if [ -n "$VERSION$SOURCE_RUN_ID" ]; then
echo "::error::development uses the checked-out version; leave version and source_run_id empty"
exit 1
fi
;;
*)
echo "::error::Unknown mode: $MODE"
exit 1
;;
esac
- name: Skip validation for tag and pull_request
if: github.event_name != 'workflow_dispatch'
run: echo "No dispatch inputs to validate."
- name: Validate signed test upload and notification secrets
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'signed'
env:
MODELSCOPE_TOKEN: ${{ secrets.MODELSCOPE_TOKEN }}
FEISHU_RELEASE_WEBHOOK: ${{ secrets.FEISHU_RELEASE_WEBHOOK }}
run: |
test -n "$MODELSCOPE_TOKEN" || { echo "::error::Missing secret MODELSCOPE_TOKEN"; exit 1; }
test -n "$FEISHU_RELEASE_WEBHOOK" || { echo "::error::Missing secret FEISHU_RELEASE_WEBHOOK"; exit 1; }
macos:
name: macOS ${{ matrix.label }}
needs: validate-dispatch
if: >-
inputs.mode != 'publish' && (startsWith(github.ref, 'refs/tags/v') ||
(github.event_name == 'workflow_dispatch' && (inputs.target == 'all' || inputs.target == 'macos')))
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
label: Apple Silicon
runner: macos-15
app-directory: mac-arm64
artifact: macos-apple-silicon
- arch: x64
label: Intel
runner: macos-15-intel
app-directory: mac
artifact: macos-intel
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '24.15.0'
cache: npm
- name: Fetch reviewed upstream baseline
shell: bash
run: |
git remote add upstream https://github.com/dataelement/dsh-desktop.git
baseline_commit=$(node -e "const b=require('./ops/ci/upstream-baseline.json');if(!/^[a-f0-9]{40}$/.test(b.commit))process.exit(1);process.stdout.write(b.commit)")
git fetch --no-tags upstream "$baseline_commit"
git update-ref refs/remotes/upstream/V0.14.1 "$baseline_commit"
git rev-parse --verify upstream/V0.14.1
- name: Verify downstream boundary before release preparation
run: npm run verify:boundary
env:
UPSTREAM_BASE: upstream/V0.14.1
- name: Set app version from release tag
if: startsWith(github.ref, 'refs/tags/v')
run: npm version --no-git-tag-version --allow-same-version "${{ github.ref_name }}"
- name: Set app version from pre-release tag
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'prerelease' && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Set app version from signed version
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'signed' && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Configure native download caches before dependency installation
shell: bash
run: |
# Electron 43 install.js reads the lowercase setting; builder uses uppercase.
echo "electron_config_cache=$RUNNER_TEMP/electron-cache" >> "$GITHUB_ENV"
echo "ELECTRON_CACHE=$RUNNER_TEMP/electron-cache" >> "$GITHUB_ENV"
echo "ELECTRON_BUILDER_CACHE=$RUNNER_TEMP/electron-builder-cache" >> "$GITHUB_ENV"
- name: Cache Electron downloads before dependency installation
uses: actions/cache@v4
with:
path: ${{ env.ELECTRON_CACHE }}
key: electron-downloads-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
restore-keys: electron-downloads-v1-${{ runner.os }}-${{ runner.arch }}-
- name: Install dependencies with timings
run: node ops/ci/npm-ci.mjs --prefer-offline --no-audit --no-fund --timing --logs-dir "${{ runner.temp }}/npm-timings"
- name: Upload dependency installation timings
if: always()
uses: actions/upload-artifact@v4
with:
name: npm-timings-${{ github.job }}-${{ runner.arch }}
path: ${{ runner.temp }}/npm-timings/*-timing.json
if-no-files-found: ignore
retention-days: 7
- name: Cache Office runtime downloads
uses: actions/cache@v4
with:
path: |
.build/office-downloads
key: office-runtime-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/office-runtime/**', 'packages/office-runtime/**', 'package-lock.json') }}
restore-keys: |
office-runtime-${{ runner.os }}-${{ matrix.arch }}-
- name: Cache generated Office and PPT assets
uses: actions/cache@v4
with:
enableCrossOsArchive: true
path: |
.build/office-template-cache
.build/ppt-runtime
key: desktop-generated-assets-v1-${{ hashFiles('scripts/office-runtime/**', 'packages/dsh-desktop-office/**', 'scripts/*ppt*.mjs', 'scripts/ppt/**', 'packages/ppt-runtime/**', 'package-lock.json') }}
restore-keys: desktop-generated-assets-v1-
- run: npm run build
- name: Typecheck shared code on macOS
if: matrix.arch == 'arm64'
run: npm run typecheck
- name: Run shared tests on macOS
if: matrix.arch == 'arm64'
run: npx --no-install vitest run --exclude '**/test/docx-template-fidelity*' --exclude '**/test/ppt-personal-templates*' --exclude '**/test/ppt-import-memory*' --exclude '**/test/ppt-personal-template-ui*' --exclude '**/test/ppt-windows-font-layout*'
- name: Verify PPT generation leaves tracked sources clean
run: git diff --exit-code -- packages/ppt-runtime scripts/ppt
- name: Validate Apple release secrets
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
env:
CSC_LINK: ${{ secrets.DESKTOP_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.DESKTOP_CSC_KEY_PASSWORD }}
APPLE_API_KEY_CONTENT: ${{ secrets.DESKTOP_APPLE_API_KEY }}
APPLE_API_KEY_ID: ${{ secrets.DESKTOP_APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.DESKTOP_APPLE_API_ISSUER }}
APPLE_TEAM_ID: ${{ secrets.DESKTOP_APPLE_TEAM_ID }}
run: |
required=(CSC_LINK CSC_KEY_PASSWORD APPLE_API_KEY_CONTENT APPLE_API_KEY_ID APPLE_API_ISSUER APPLE_TEAM_ID)
for name in "${required[@]}"; do
test -n "${!name}" || { echo "::error::Missing required secret: $name"; exit 1; }
done
- name: Prepare Apple notarization key
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
env:
APPLE_API_KEY_CONTENT: ${{ secrets.DESKTOP_APPLE_API_KEY }}
APPLE_API_KEY_ID: ${{ secrets.DESKTOP_APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.DESKTOP_APPLE_API_ISSUER }}
APPLE_TEAM_ID: ${{ secrets.DESKTOP_APPLE_TEAM_ID }}
run: |
key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
printf '%s' "$APPLE_API_KEY_CONTENT" > "$key_path"
chmod 600 "$key_path"
echo "APPLE_API_KEY=$key_path" >> "$GITHUB_ENV"
echo "APPLE_API_KEY_ID=$APPLE_API_KEY_ID" >> "$GITHUB_ENV"
echo "APPLE_API_ISSUER=$APPLE_API_ISSUER" >> "$GITHUB_ENV"
echo "APPLE_TEAM_ID=$APPLE_TEAM_ID" >> "$GITHUB_ENV"
- name: Prepare macOS signing keychain
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
id: signing_keychain
env:
CSC_LINK: ${{ secrets.DESKTOP_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.DESKTOP_CSC_KEY_PASSWORD }}
run: node scripts/release/prepare-macos-signing-keychain.mjs
- name: Build signed ${{ matrix.label }} package
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
env:
DSH_OFFICE_SMOKE_DIAGNOSTICS_DIR: ${{ runner.temp }}/office-smoke-diagnostics
CSC_KEYCHAIN: ${{ steps.signing_keychain.outputs.keychain }}
run: node scripts/verify/verify-target.mjs darwin ${{ matrix.arch }} && npx --no-install electron-builder --mac --${{ matrix.arch }} --publish never
- name: Build isolated ${{ matrix.label }} development package
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name != 'workflow_dispatch' || inputs.mode == 'development') }}
env:
DSH_OFFICE_SMOKE_DIAGNOSTICS_DIR: ${{ runner.temp }}/office-smoke-diagnostics
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
run: node scripts/verify/verify-target.mjs darwin ${{ matrix.arch }} && npx --no-install electron-builder --mac --${{ matrix.arch }} --publish never --config electron-builder.dev.cjs
- name: Preserve failed Office smoke diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: office-smoke-diagnostics-${{ matrix.arch }}
path: ${{ runner.temp }}/office-smoke-diagnostics/
if-no-files-found: ignore
retention-days: 7
- name: Preserve ${{ matrix.label }} update metadata
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
run: mv dist/latest-mac.yml dist/latest-mac-${{ matrix.arch }}.yml
- name: Sign, notarize, and staple ${{ matrix.label }} DMG
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
env:
CSC_KEYCHAIN: ${{ steps.signing_keychain.outputs.keychain }}
run: |
dmg_path="dist/bisheng-mac-${{ matrix.arch }}.dmg"
identity="$(security find-identity -v -p codesigning "$CSC_KEYCHAIN" | awk '/Developer ID Application/ { print $2; exit }')"
test -n "$identity" || { echo "::error::Developer ID Application identity not found"; exit 1; }
codesign --keychain "$CSC_KEYCHAIN" --sign "$identity" --timestamp --force "$dmg_path"
xcrun notarytool submit "$dmg_path" \
--key "$APPLE_API_KEY" \
--key-id "$APPLE_API_KEY_ID" \
--issuer "$APPLE_API_ISSUER" \
--wait
for attempt in 1 2 3 4 5 6; do
if xcrun stapler staple "$dmg_path"; then break; fi
if [ "$attempt" -eq 6 ]; then exit 1; fi
echo "stapler staple failed, waiting for Apple ticket propagation in $((attempt * 15))s (attempt $attempt/6)..."
sleep $((attempt * 15))
done
- name: Remove temporary signing keychain
if: always() && (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease')))
env:
SIGNING_KEYCHAIN: ${{ steps.signing_keychain.outputs.keychain }}
SIGNING_CERTIFICATE: ${{ steps.signing_keychain.outputs.certificate }}
SIGNING_KEYCHAIN_LIST: ${{ steps.signing_keychain.outputs.keychain_list }}
run: |
if [ -n "$SIGNING_KEYCHAIN_LIST" ] && [ -f "$SIGNING_KEYCHAIN_LIST" ]; then
keychains=()
while IFS= read -r keychain; do
test -z "$keychain" || keychains+=("$keychain")
done < "$SIGNING_KEYCHAIN_LIST"
security list-keychains -d user -s "${keychains[@]}"
rm -f "$SIGNING_KEYCHAIN_LIST"
fi
test -z "$SIGNING_KEYCHAIN" || security delete-keychain "$SIGNING_KEYCHAIN" || rm -f "$SIGNING_KEYCHAIN"
test -z "$SIGNING_CERTIFICATE" || rm -f "$SIGNING_CERTIFICATE"
test -z "$APPLE_API_KEY" || rm -f "$APPLE_API_KEY"
- name: Verify signed and notarized ${{ matrix.label }} app
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
run: |
app_path="dist/${{ matrix.app-directory }}/BISHENG.app"
codesign --verify --deep --strict --verbose=2 "$app_path"
spctl --assess --type execute --verbose=4 "$app_path"
for attempt in 1 2 3 4 5 6; do
if xcrun stapler validate "$app_path"; then break; fi
if [ "$attempt" -eq 6 ]; then exit 1; fi
echo "stapler validate failed on app_path, retrying in $((attempt * 10))s (attempt $attempt/6)..."
sleep $((attempt * 10))
done
codesign --verify --verbose=2 dist/bisheng-mac-${{ matrix.arch }}.dmg
spctl --assess --type open --context context:primary-signature --verbose=4 dist/bisheng-mac-${{ matrix.arch }}.dmg
for attempt in 1 2 3 4 5 6; do
if xcrun stapler validate dist/bisheng-mac-${{ matrix.arch }}.dmg; then break; fi
if [ "$attempt" -eq 6 ]; then exit 1; fi
echo "stapler validate failed on dmg, retrying in $((attempt * 10))s (attempt $attempt/6)..."
sleep $((attempt * 10))
done
- name: Verify all desktop build outputs
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name != 'workflow_dispatch' || inputs.mode == 'development' || inputs.mode == 'signed' || inputs.mode == 'prerelease')
env:
BUILD_CHANNEL: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || (inputs.mode == 'signed' || inputs.mode == 'prerelease') && 'release' || 'development' }}
run: node ops/ci/desktop-artifacts.mjs "$BUILD_CHANNEL" mac ${{ matrix.arch }}
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
with:
name: ${{ matrix.artifact }}
retention-days: 7
path: |
dist/bisheng-mac-${{ matrix.arch }}.dmg
dist/bisheng-mac-${{ matrix.arch }}.zip
dist/bisheng-mac-${{ matrix.arch }}.zip.blockmap
dist/latest-mac-${{ matrix.arch }}.yml
compression-level: 0
if-no-files-found: error
- uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name != 'workflow_dispatch' || inputs.mode == 'development') }}
with:
name: ${{ matrix.artifact }}-dev
retention-days: 3
path: |
dist-dev/bisheng-dev-mac-${{ matrix.arch }}.dmg
dist-dev/bisheng-dev-mac-${{ matrix.arch }}.zip
dist-dev/bisheng-dev-mac-${{ matrix.arch }}.zip.blockmap
compression-level: 0
if-no-files-found: error
windows-x64:
name: Windows x64
needs: validate-dispatch
if: >-
inputs.mode != 'publish' && (startsWith(github.ref, 'refs/tags/v') ||
github.event_name == 'pull_request' ||
(github.event_name == 'workflow_dispatch' &&
inputs.mode != 'resign' &&
(inputs.target == 'all' || inputs.target == 'windows')))
runs-on: windows-2022
steps:
- name: Preserve shared asset fingerprints during checkout
shell: bash
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '24.15.0'
cache: npm
- name: Fetch reviewed upstream baseline
shell: bash
run: |
git remote add upstream https://github.com/dataelement/dsh-desktop.git
baseline_commit=$(node -e "const b=require('./ops/ci/upstream-baseline.json');if(!/^[a-f0-9]{40}$/.test(b.commit))process.exit(1);process.stdout.write(b.commit)")
git fetch --no-tags upstream "$baseline_commit"
git update-ref refs/remotes/upstream/V0.14.1 "$baseline_commit"
git rev-parse --verify upstream/V0.14.1
- name: Verify downstream boundary before release preparation
run: npm run verify:boundary
env:
UPSTREAM_BASE: upstream/V0.14.1
- name: Set app version from release tag
if: startsWith(github.ref, 'refs/tags/v')
run: npm version --no-git-tag-version --allow-same-version "${{ github.ref_name }}"
- name: Set app version from pre-release tag
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'prerelease' && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Set app version from signed version
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'signed' && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Configure native download caches before dependency installation
shell: bash
run: |
# Electron 43 install.js reads the lowercase setting; builder uses uppercase.
echo "electron_config_cache=$RUNNER_TEMP/electron-cache" >> "$GITHUB_ENV"
echo "ELECTRON_CACHE=$RUNNER_TEMP/electron-cache" >> "$GITHUB_ENV"
echo "ELECTRON_BUILDER_CACHE=$RUNNER_TEMP/electron-builder-cache" >> "$GITHUB_ENV"
- name: Cache Office runtime downloads and packaging tools
uses: actions/cache@v4
with:
path: |
.build/office-downloads
${{ env.ELECTRON_CACHE }}
${{ env.ELECTRON_BUILDER_CACHE }}
key: windows-packaging-v1-${{ hashFiles('scripts/office-runtime/**', 'packages/office-runtime/**', 'package-lock.json') }}
restore-keys: |
windows-packaging-v1-
- name: Install dependencies with timings
run: node ops/ci/npm-ci.mjs --prefer-offline --no-audit --no-fund --timing --logs-dir "${{ runner.temp }}/npm-timings"
- name: Upload dependency installation timings
if: always()
uses: actions/upload-artifact@v4
with:
name: npm-timings-${{ github.job }}-${{ runner.arch }}
path: ${{ runner.temp }}/npm-timings/*-timing.json
if-no-files-found: ignore
retention-days: 7
- name: Cache generated Office and PPT assets
uses: actions/cache@v4
with:
enableCrossOsArchive: true
path: |
.build/office-template-cache
.build/ppt-runtime
key: desktop-generated-assets-v1-${{ hashFiles('scripts/office-runtime/**', 'packages/dsh-desktop-office/**', 'scripts/*ppt*.mjs', 'scripts/ppt/**', 'packages/ppt-runtime/**', 'package-lock.json') }}
restore-keys: desktop-generated-assets-v1-
- run: npm run build
- name: Typecheck shared code on Windows
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.target == 'windows')
run: npm run typecheck
- name: Run focused Windows regressions
if: inputs.checks != 'extended' && github.event_name != 'pull_request' && !(github.event_name == 'workflow_dispatch' && inputs.target == 'windows')
run: npx --no-install vitest run --config vitest.windows.config.ts
timeout-minutes: 15
- name: Run complete Windows test suite
if: inputs.checks == 'extended' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.target == 'windows')
run: |
npx --no-install vitest run --mode windows-parallel --reporter=verbose
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
npx --no-install vitest run --mode windows-serial --reporter=verbose
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
timeout-minutes: 15
- name: Verify PPT generation leaves tracked sources clean
run: git diff --exit-code -- packages/ppt-runtime scripts/ppt
- name: Check recovery UI on native Windows at three display scales
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.checks == 'extended')
run: node scripts/verify/check-recovery-ui.mjs
- uses: actions/upload-artifact@v4
if: always() && (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.checks == 'extended'))
with:
name: windows-recovery-ui
retention-days: 7
path: |
artifacts/recovery-ui/scale-*/*.png
artifacts/recovery-ui/scale-*/results.json
if-no-files-found: warn
- name: Build Windows release package
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
run: node scripts/verify/verify-target.mjs win32 x64 && node scripts/release/electron-builder-windows.mjs --win --x64 --publish never
- name: Build isolated Windows development package
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name != 'workflow_dispatch' || inputs.mode == 'development') }}
run: node scripts/verify/verify-target.mjs win32 x64 && node scripts/release/electron-builder-windows.mjs --win --x64 --publish never --config electron-builder.dev.cjs
- name: Test installer failure cancellation on Windows
env:
DSH_TEST_NSIS: '1'
run: npx --no-install vitest run test/windows-installer-errors.test.ts
- name: Smoke test packaged Windows Harness
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.checks == 'extended')
shell: pwsh
env:
SMOKE_EXE: ${{ (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))) && 'dist\win-unpacked\BISHENG.exe' || 'dist-dev\win-unpacked\BISHENG Dev.exe' }}
SMOKE_USERDATA: ${{ (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))) && 'bisheng' || 'bisheng-dev' }}
run: |
# Run outside the checkout: otherwise Node can silently resolve a
# missing packaged dependency from the repository's node_modules.
$sourceExecutable = Get-Item $env:SMOKE_EXE
$isolatedApp = Join-Path $env:RUNNER_TEMP ('DSH packaged smoke ' + [guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $isolatedApp | Out-Null
Copy-Item -Path (Join-Path $sourceExecutable.Directory.FullName '*') -Destination $isolatedApp -Recurse
$executable = Join-Path $isolatedApp $sourceExecutable.Name
$packagedNode = Join-Path $isolatedApp 'resources\app.asar.unpacked\node_modules\node\bin\node.exe'
if (Test-Path $packagedNode) { throw 'Standalone Windows node.exe must not be packaged.' }
# Exercise the actual native binding too; the best-effort fallback
# must not hide a missing or broken packaged koffi dependency.
# A Windows GUI-subsystem executable makes PowerShell's '&' return
# before the Node-mode child exits, leaving $LASTEXITCODE unset.
function Invoke-ElectronNode([string[]]$nodeArguments) {
$start = [System.Diagnostics.ProcessStartInfo]::new($executable)
$start.WorkingDirectory = $isolatedApp
$start.UseShellExecute = $false
$start.RedirectStandardOutput = $true
$start.RedirectStandardError = $true
$start.Environment['ELECTRON_RUN_AS_NODE'] = '1'
foreach ($argument in $nodeArguments) { [void]$start.ArgumentList.Add($argument) }
$child = [System.Diagnostics.Process]::Start($start)
$stdout = $child.StandardOutput.ReadToEnd()
$stderr = $child.StandardError.ReadToEnd()
$child.WaitForExit()
if ($stdout) { Write-Host $stdout }
if ($stderr) { Write-Host $stderr }
return $child.ExitCode
}
$koffiProbe = "import { createRequire } from 'node:module'; import { pathToFileURL } from 'node:url'; const require = createRequire(pathToFileURL(process.argv[1])); const resolved = require.resolve('koffi'); if (!resolved.startsWith(process.argv[2])) throw new Error('koffi resolved outside packaged app: ' + resolved); const koffi = require('koffi'); const getCurrentProcessId = koffi.load('kernel32.dll').func('GetCurrentProcessId', 'uint32', []); if (getCurrentProcessId() !== process.pid) throw new Error('Native koffi smoke failed'); console.log('Packaged koffi native binding passed'); process.exit(0);"
$koffiExitCode = Invoke-ElectronNode @('--input-type=module', '-e', $koffiProbe, (Join-Path $isolatedApp 'resources\app.asar\node_modules\koffi\package.json'), (Join-Path $isolatedApp 'resources\app.asar\node_modules'))
if ($koffiExitCode -ne 0) { throw "Packaged koffi native binding failed (exit code $koffiExitCode)." }
# Packages load through app.asar (native files are unpacked beside it).
$pnpmEntry = Join-Path $isolatedApp 'resources\app.asar\node_modules\pnpm\bin\pnpm.cjs'
$pnpmExitCode = Invoke-ElectronNode @($pnpmEntry, '--version')
if ($pnpmExitCode -ne 0) { throw "Packaged pnpm failed under Electron Node mode (exit code $pnpmExitCode)." }
try {
node scripts/verify/check-workbench-install.mjs "$executable" "artifacts/workbench-install"
if ($LASTEXITCODE -ne 0) { throw 'Packaged Windows workbench installation acceptance failed.' }
} finally {
# The driver owns a unique Profile and closes its desktop process.
# Also clean descendants from this isolated executable if it failed.
$smokeRoot = [System.IO.Path]::GetFullPath($isolatedApp).TrimEnd('\') + '\'
$cleanupDeadline = (Get-Date).AddSeconds(10)
do {
$remaining = @(Get-CimInstance Win32_Process | Where-Object {
$_.ExecutablePath -and $_.ExecutablePath.StartsWith($smokeRoot, [System.StringComparison]::OrdinalIgnoreCase)
})
foreach ($entry in $remaining) {
$process = Get-Process -Id $entry.ProcessId -ErrorAction SilentlyContinue
if ($process -and -not $process.HasExited) {
try { $process.Kill($true) } catch {
if (-not $process.HasExited) { throw }
}
}
}
if ($remaining.Count -eq 0) { break }
Start-Sleep -Milliseconds 200
} while ((Get-Date) -lt $cleanupDeadline)
if ($remaining.Count -gt 0) { throw 'Processes from the isolated packaged smoke did not exit.' }
}
- name: Upload Windows workbench installation evidence
if: always() && (github.event_name == 'pull_request' || inputs.checks == 'extended')
uses: actions/upload-artifact@v4
with:
name: windows-workbench-installation
retention-days: 7
if-no-files-found: warn
path: |
artifacts/workbench-install/*.png
artifacts/workbench-install/results.json
- name: Archive and verify unpacked Windows payload
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease' || inputs.checks == 'extended'))
shell: pwsh
env:
ARCHIVE_DIST: ${{ (startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))) && 'dist' || 'dist-dev' }}
run: |
node scripts/release/archive-windows-release.mjs "$env:ARCHIVE_DIST"
- name: Verify all desktop build outputs
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name != 'workflow_dispatch' || inputs.mode == 'development' || inputs.mode == 'signed' || inputs.mode == 'prerelease')
env:
BUILD_CHANNEL: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || (inputs.mode == 'signed' || inputs.mode == 'prerelease') && 'release' || 'development' }}
shell: pwsh
run: node ops/ci/desktop-artifacts.mjs "$env:BUILD_CHANNEL" win x64
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))
with:
name: windows-x64-unsigned
path: |
dist/bisheng-windows-x64-setup.exe
dist/win-unpacked.tar.gz
dist/bisheng-windows-x64-setup.exe.blockmap
dist/latest.yml
compression-level: 0
if-no-files-found: error
retention-days: 1
- uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name != 'workflow_dispatch' || inputs.mode == 'development') }}
with:
name: windows-x64-dev
retention-days: 3
path: |
dist-dev/bisheng-dev-windows-x64-setup.exe
dist-dev/bisheng-dev-windows-x64-setup.exe.blockmap
compression-level: 0
if-no-files-found: error
- uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'pull_request' || inputs.checks == 'extended') }}
with:
name: windows-x64-dev-unpacked
retention-days: 3
path: dist-dev/win-unpacked.tar.gz
compression-level: 0
if-no-files-found: error
sign-windows:
name: Sign Windows package locally with UKey
needs: [validate-dispatch, windows-x64]
permissions:
actions: read
contents: read
if: >-
always() &&
needs.validate-dispatch.result == 'success' && inputs.mode != 'publish' &&
((startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'prerelease'))) && needs.windows-x64.result == 'success' ||
(github.event_name == 'workflow_dispatch' && inputs.mode == 'resign' && needs.windows-x64.result == 'skipped'))
runs-on: [self-hosted, macOS, ARM64]
env:
CI: 'true'
JSIGN_VERSION: '7.5'
JSIGN_SHA256: '602a51c3545a6dc4fb99bd2ea7152b26d1345916d0c93ddfbd5936cb735af91c'
steps:
- uses: actions/checkout@v4
# Persistent runners retain npm downloads locally; restoring the remote
# cache duplicates disk usage and can stall release setup for minutes.
- uses: actions/setup-node@v4
timeout-minutes: 5
with:
node-version: '24.15.0'
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Install release tooling
run: npm ci --ignore-scripts
- name: Set app version from release tag
if: startsWith(github.ref, 'refs/tags/v')
run: npm version --no-git-tag-version --allow-same-version "${{ github.ref_name }}"
- name: Set app version from pre-release tag
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'prerelease' && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Set app version from signed version
if: github.event_name == 'workflow_dispatch' && (inputs.mode == 'signed' || inputs.mode == 'resign') && inputs.version != ''
run: npm version --no-git-tag-version --allow-same-version "${{ inputs.version }}"
- name: Prepare unsigned Windows package
run: |
work_dir="$RUNNER_TEMP/dsh-windows-${{ github.run_id }}"
mkdir -p "$work_dir/release"
echo "WINDOWS_SIGNING_WORK_DIR=$work_dir" >> "$GITHUB_ENV"
- name: Bypass runner proxy for artifact transfer
run: |
# The runner exports lowercase proxy variables separately on macOS.
# A step env map cannot specify both cases in GitHub workflow YAML.
printf 'http_proxy=\nhttps_proxy=\nall_proxy=\nno_proxy=*\n' >> "$GITHUB_ENV"
- name: Download verified Windows signing inputs in parallel
env:
GH_TOKEN: ${{ github.token }}
SOURCE_RUN_ID: ${{ inputs.mode == 'resign' && inputs.source_run_id || github.run_id }}
HTTP_PROXY: ''
HTTPS_PROXY: ''
ALL_PROXY: ''
run: |
node scripts/release/download-artifact-ranges.mjs "$GITHUB_REPOSITORY" "$SOURCE_RUN_ID" \
windows-x64-unsigned "$WINDOWS_SIGNING_WORK_DIR/unsigned.zip"
unzip -q "$WINDOWS_SIGNING_WORK_DIR/unsigned.zip" -d "$WINDOWS_SIGNING_WORK_DIR/release"
rm "$WINDOWS_SIGNING_WORK_DIR/unsigned.zip"
- name: Check reused unsigned package version
if: github.event_name == 'workflow_dispatch' && inputs.mode == 'resign'
run: |
actual_version="$(node -e 'const fs = require("node:fs"); const yaml = require("js-yaml"); console.log(yaml.load(fs.readFileSync(process.argv[1], "utf8")).version)' "$WINDOWS_SIGNING_WORK_DIR/release/latest.yml")"
test "$actual_version" = "${{ inputs.version }}" || {
echo "::error::Unsigned artifact version $actual_version does not match signed_version"
exit 1
}
- name: Download and verify Jsign
timeout-minutes: 5
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
jsign_jar="$WINDOWS_SIGNING_WORK_DIR/jsign-${JSIGN_VERSION}.jar"
gh release download "$JSIGN_VERSION" --repo ebourg/jsign \
--pattern "jsign-${JSIGN_VERSION}.jar" --dir "$WINDOWS_SIGNING_WORK_DIR" --clobber
test -s "$jsign_jar"
printf '%s %s\n' "$JSIGN_SHA256" "$jsign_jar" | shasum -a 256 --check
java -jar "$jsign_jar" --version
echo "JSIGN_JAR=$jsign_jar" >> "$GITHUB_ENV"
- name: Sign Windows installer with SafeNet UKey
env:
WINDOWS_SIGNING_PIN: ${{ secrets.DESKTOP_WINDOWS_SIGNING_PIN }}
run: |
set -euo pipefail
test -r /usr/local/lib/libeTPkcs11.dylib
test -n "$WINDOWS_SIGNING_PIN" || { echo "::error::Missing required secret: DESKTOP_WINDOWS_SIGNING_PIN"; exit 1; }
pin_file="$(mktemp "$WINDOWS_SIGNING_WORK_DIR/jsign-pin.XXXXXX")"
trap 'rm -f "$pin_file"' EXIT
chmod 600 "$pin_file"
printf '%s' "$WINDOWS_SIGNING_PIN" > "$pin_file"
unset WINDOWS_SIGNING_PIN
# A missing archive or any failed signing/repackaging step blocks publication.
test -s "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked.tar.gz"
tar -xzf "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked.tar.gz" -C "$WINDOWS_SIGNING_WORK_DIR/release"
JSIGN_JAR="$JSIGN_JAR" JSIGN_PIN_FILE="$pin_file" \
node scripts/release/sign-windows-unpacked.mjs "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked"
rm -f "$WINDOWS_SIGNING_WORK_DIR/release"/*.exe "$WINDOWS_SIGNING_WORK_DIR/release"/*.blockmap
JSIGN_JAR="$JSIGN_JAR" JSIGN_PIN_FILE="$pin_file" \
node scripts/release/electron-builder-windows.mjs --win --x64 --publish never \
--prepackaged "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked" \
--config.directories.output="$WINDOWS_SIGNING_WORK_DIR/release"
rm -rf "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked" "$WINDOWS_SIGNING_WORK_DIR/release/win-unpacked.tar.gz"
installer_count="$(find "$WINDOWS_SIGNING_WORK_DIR/release" -maxdepth 1 -type f -name '*.exe' | wc -l | tr -d ' ')"
test "$installer_count" = '1'
installer="$(find "$WINDOWS_SIGNING_WORK_DIR/release" -maxdepth 1 -type f -name '*.exe' -print -quit)"
for attempt in 1 2 3 4 5 6; do
if java -jar "$JSIGN_JAR" \
--storetype ETOKEN \
--storepass "file:$pin_file" \
--alg SHA-256 \
--tsaurl http://timestamp.digicert.com \
--tsmode RFC3161 \
--tsretries 3 \
--tsretrywait 10 \
--name 'BISHENG' \
--url https://www.dshdesktop.com \
--verbose \
"$installer"; then
break
fi
if [ "$attempt" -eq 6 ]; then
echo "::error::Signing final installer failed after 6 attempts"
exit 1
fi
echo "Signing final installer failed, retrying in $((attempt * 10))s (attempt $attempt/6)..."
sleep $((attempt * 10))
done
java -jar "$JSIGN_JAR" extract --format DER "$installer"
test -s "$installer.sig"
rm -f "$installer.sig"
- name: Rebuild Windows update metadata
env:
PRERELEASE_TAG: ${{ inputs.version }}
SIGNED_VERSION: ${{ inputs.version }}
DISPATCH_MODE: ${{ inputs.mode }}
run: |
# Tag pushes use the git tag. Dispatch must not fall back to the
# branch name, because finalize-windows-release.mjs requires semver.
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
version="${GITHUB_REF_NAME#v}"
elif [ "$DISPATCH_MODE" = "prerelease" ]; then
version="${PRERELEASE_TAG#v}"
else
version="${SIGNED_VERSION#v}"
fi
node scripts/release/finalize-windows-release.mjs \
"$WINDOWS_SIGNING_WORK_DIR/release" \
"$version"
test -f "$WINDOWS_SIGNING_WORK_DIR/release/latest.yml"
test -f "$WINDOWS_SIGNING_WORK_DIR"/release/*.exe.blockmap
- uses: actions/upload-artifact@v4
with:
name: windows-x64
retention-days: 7
path: |
${{ runner.temp }}/dsh-windows-${{ github.run_id }}/release/bisheng-windows-x64-setup.exe
${{ runner.temp }}/dsh-windows-${{ github.run_id }}/release/bisheng-windows-x64-setup.exe.blockmap
${{ runner.temp }}/dsh-windows-${{ github.run_id }}/release/latest.yml
compression-level: 0
if-no-files-found: error
- name: Remove local signing files
if: always()
run: |
case "$WINDOWS_SIGNING_WORK_DIR" in
"$RUNNER_TEMP"/dsh-windows-*) rm -rf "$WINDOWS_SIGNING_WORK_DIR" ;;
'') ;;
*) echo "Refusing to remove unexpected signing path: $WINDOWS_SIGNING_WORK_DIR"; exit 1 ;;
esac
publish-signed-test:
name: Upload signed test installers and notify
needs: [macos, sign-windows]
if: >-
always() && github.event_name == 'workflow_dispatch' && inputs.mode == 'signed' &&
(inputs.target == 'windows' || needs.macos.result == 'success') &&
(inputs.target == 'macos' || needs.sign-windows.result == 'success')
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
if: inputs.target == 'all' || inputs.target == 'macos'
with:
pattern: macos-*
path: test-assets
merge-multiple: true
- uses: actions/download-artifact@v4
if: inputs.target == 'all' || inputs.target == 'windows'
with:
name: windows-x64
path: test-assets
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/setup-node@v4
with:
node-version: '24.15.0'
- name: Install release summary CLI
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.MODELS_TOKEN }}
run: |
if [ -n "${COPILOT_GITHUB_TOKEN:-}" ]; then
npm install -g @github/copilot@latest || echo "::warning::Copilot installation failed; test notification will use a short fallback."
fi
- name: Upload test installers, verify downloads, and send Feishu notification
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.MODELS_TOKEN }}
MODELSCOPE_TOKEN: ${{ secrets.MODELSCOPE_TOKEN }}
MODELSCOPE_REPO_ID: alexyaojin/bisheng-work
FEISHU_RELEASE_WEBHOOK: ${{ secrets.FEISHU_RELEASE_WEBHOOK }}
SIGNED_VERSION: ${{ inputs.version }}
TEST_TARGET: ${{ inputs.target }}
run: |
python3 -m venv "$RUNNER_TEMP/test-upload-env"
"$RUNNER_TEMP/test-upload-env/bin/pip" install -q modelscope
"$RUNNER_TEMP/test-upload-env/bin/python3" .github/scripts/signed_test_build.py \
--directory test-assets --target "$TEST_TARGET" \
--version "$SIGNED_VERSION" --run-id "$GITHUB_RUN_ID" \
--artifact-prefix bisheng --product-name BISHENG
publish:
name: Publish GitHub Release
concurrency:
group: desktop-modelscope-release-history
cancel-in-progress: false
if: >-
always() && needs.validate-dispatch.result == 'success' &&
((github.event_name == 'workflow_dispatch' && inputs.mode == 'publish') ||
(inputs.mode != 'publish' && startsWith(github.ref, 'refs/tags/v') &&
inputs.version == '' && needs.macos.result == 'success' &&
needs.sign-windows.result == 'success'))
needs:
- validate-dispatch
- macos
- sign-windows
permissions:
actions: read
contents: write
runs-on: ubuntu-24.04
env:
RELEASE_TAG: ${{ inputs.mode == 'publish' && inputs.version || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate original signed release source
if: inputs.mode == 'publish'
id: source
env:
GH_TOKEN: ${{ github.token }}
SOURCE_RUN_ID: ${{ inputs.source_run_id }}
run: python3 .github/scripts/validate_publish_source.py
- name: Bind release identity
env:
SOURCE_SHA: ${{ steps.source.outputs.sha || github.sha }}
run: |
set -euo pipefail
test "$(git rev-parse "refs/tags/$RELEASE_TAG^{commit}")" = "$SOURCE_SHA"
echo "RELEASE_SOURCE_SHA=$SOURCE_SHA" >> "$GITHUB_ENV"
- uses: actions/setup-node@v4
with:
node-version: '24.15.0'
cache: npm
- run: npm ci --ignore-scripts
- uses: actions/download-artifact@v4
if: inputs.mode != 'publish'
with:
pattern: macos-*
path: release-assets
merge-multiple: true
- uses: actions/download-artifact@v4
if: inputs.mode != 'publish'
with:
name: windows-x64
path: release-assets
- name: Download verified signed artifacts from original run
if: inputs.mode == 'publish'
uses: actions/download-artifact@v4
with:
github-token: ${{ github.token }}
run-id: ${{ inputs.source_run_id }}
artifact-ids: ${{ steps.source.outputs.artifact_ids }}
path: release-assets
merge-multiple: true
- name: Merge macOS update metadata
run: |
set -euo pipefail
node scripts/release/merge-mac-update-metadata.mjs \
release-assets/latest-mac-arm64.yml \
release-assets/latest-mac-x64.yml \
release-assets/latest-mac.yml
find release-assets -maxdepth 1 \
\( -name latest-mac-arm64.yml -o -name latest-mac-x64.yml \) \
-delete
- name: Verify release assets before publication
run: |
set -euo pipefail
node scripts/verify/verify-release-assets.mjs release-assets "${RELEASE_TAG#v}" --artifact-prefix bisheng
- name: Build GitHub release note prompt
run: |
set -euo pipefail
mkdir -p .github/release-artifacts
git fetch --force --tags
python3 .github/scripts/github_release_notes.py build-prompt \
--tag "$RELEASE_TAG" \
--output .github/release-artifacts/github-release-prompt.txt
- name: Generate GitHub release note
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.MODELS_TOKEN }}
run: |
set -euo pipefail
out=.github/release-artifacts/github-release-notes.md
if [ -n "${COPILOT_GITHUB_TOKEN:-}" ]; then
echo "Generating GitHub release note via Copilot CLI with $RELEASE_NOTES_MODEL..."
npm install -g @github/copilot@latest || true
prompt="$(cat .github/release-artifacts/github-release-prompt.txt)"
error_log="$(mktemp)"
if copilot -p "$prompt" -s --model "$RELEASE_NOTES_MODEL" --no-ask-user > "$out" 2>"$error_log"; then
if python3 .github/scripts/github_release_notes.py validate --tag "$RELEASE_TAG" --input "$out"; then
echo "✅ AI GitHub release note generated and validated with $RELEASE_NOTES_MODEL."
else
echo "::warning::Copilot generated a GitHub release note that failed validation; using the deterministic fallback."
python3 .github/scripts/github_release_notes.py generate-fallback --tag "$RELEASE_TAG" --output "$out"
fi
else
echo "::warning::Copilot failed to generate the GitHub release note with $RELEASE_NOTES_MODEL; using the deterministic fallback."
sed -n '1,20{s/^/copilot: /;p;}' "$error_log"
python3 .github/scripts/github_release_notes.py generate-fallback --tag "$RELEASE_TAG" --output "$out"
fi
rm -f "$error_log"
else
echo "MODELS_TOKEN not set; using the deterministic GitHub release note."
python3 .github/scripts/github_release_notes.py generate-fallback --tag "$RELEASE_TAG" --output "$out"
fi
- name: Generate concise bilingual popup notes
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.MODELS_TOKEN }}
run: |
set -euo pipefail
test -n "$COPILOT_GITHUB_TOKEN" || { echo "::error::Missing MODELS_TOKEN; popup notes cannot be generated"; exit 1; }
python3 .github/scripts/update_popup_notes.py prompt --tag "$RELEASE_TAG" --file .github/release-artifacts/popup-prompt.txt
copilot -p "$(cat .github/release-artifacts/popup-prompt.txt)" -s --model "$RELEASE_NOTES_MODEL" --no-ask-user --available-tools= --disable-builtin-mcps > .github/release-artifacts/popup-notes.json
python3 .github/scripts/update_popup_notes.py validate --file .github/release-artifacts/popup-notes.json
- name: Install Feishu card callback transport
run: |
python3 -m venv "$RUNNER_TEMP/release-review-env"
"$RUNNER_TEMP/release-review-env/bin/pip" install -r .github/scripts/release-review-requirements.txt
"$RUNNER_TEMP/release-review-env/bin/python" test/feishu-card-sdk.py
- name: Wait for Feishu release confirmation
timeout-minutes: 65
env:
FEISHU_APP_ID: ${{ secrets.FEISHU_APP_ID }}
FEISHU_APP_SECRET: ${{ secrets.FEISHU_APP_SECRET }}
FEISHU_RELEASE_CHAT_ID: ${{ vars.FEISHU_RELEASE_CHAT_ID }}
FEISHU_RELEASE_REVIEWER_ID: ${{ vars.FEISHU_RELEASE_REVIEWER_ID }}
COPILOT_GITHUB_TOKEN: ${{ secrets.MODELS_TOKEN }}
run: 'env GITHUB_SHA="$RELEASE_SOURCE_SHA" "$RUNNER_TEMP/release-review-env/bin/python" .github/scripts/confirm_popup_release.py'
- name: Inject approved popup notes into update feeds
run: env GITHUB_SHA="$RELEASE_SOURCE_SHA" node scripts/release/inject-popup-notes.mjs
- name: Preserve release review evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: release-review-${{ github.run_id }}-${{ github.run_attempt }}
path: .github/release-artifacts/
retention-days: 30
- name: Recheck immutable source after human approval
if: inputs.mode == 'publish'
env:
GH_TOKEN: ${{ github.token }}
SOURCE_RUN_ID: ${{ inputs.source_run_id }}
run: |
set -euo pipefail
python3 .github/scripts/validate_publish_source.py > "$RUNNER_TEMP/rechecked-source.json"
python3 -c 'import json, os; assert json.load(open(os.environ["RUNNER_TEMP"] + "/rechecked-source.json"))["sha"] == os.environ["RELEASE_SOURCE_SHA"], "Release tag changed during approval"'
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
run: |
notes=.github/release-artifacts/github-release-notes.md
if gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" release-assets/* --clobber --repo "$GITHUB_REPOSITORY"
gh release edit "$RELEASE_TAG" --notes-file "$notes" --repo "$GITHUB_REPOSITORY"
else
gh release create "$RELEASE_TAG" release-assets/* \