Repository navigation
2062 lines (1898 loc) · 89.9 KB
/
Copy pathdev-build.yml
File metadata and controls
2062 lines (1898 loc) · 89.9 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: Dev Build
on:
push:
branches:
- dev
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
frontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install 7-Zip
shell: bash
run: |
set -euo pipefail
# 驱动总包是 LZMA2 固实 7z(tools/driver_bundle_7z.py),打包、补齐与其测试都依赖 7z 命令行。
if ! command -v 7zz >/dev/null 2>&1 && ! command -v 7z >/dev/null 2>&1; then
sudo apt-get update -qq
sudo apt-get install -y -qq 7zip || sudo apt-get install -y -qq p7zip-full
fi
echo "Using 7-Zip: $(command -v 7zz || command -v 7z)"
- name: Test release asset contracts
run: |
go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -shellcheck= -pyflakes= \
.github/workflows/release.yml \
.github/workflows/dev-build.yml \
.github/workflows/publish-release.yml
bash tools/detect-changed-driver-agents.test.sh
bash tools/generate-driver-agent-revisions.test.sh
bash tools/verify-driver-revision-contract.test.sh
python3 tools/generate-driver-release-manifest.test.py
python3 tools/generate-update-latest-manifest.test.py
python3 tools/validate-gui-update-manifest.test.py
python3 tools/prepare-vps-release-payload.test.py
python3 tools/edge-release-transaction.test.py
python3 tools/edge-release-retention.test.py
python3 tools/download-mirror-config.test.py
python3 tools/package-driver-release-assets.test.py
python3 tools/complete-driver-release-assets.test.py
python3 tools/verify-driver-agent-fingerprints.test.py
python3 tools/cli-release-assets.test.py
python3 tools/npm-cli-wrapper.test.py
python3 tools/validate-npm-cli-package-version.test.py
python3 tools/generate-winget-cli-manifest.test.py
python3 tools/legal-release-assets.test.py
python3 tools/windows-release-artifacts.test.py
python3 tools/generate-release-notes.test.py
python3 tools/prune-ghcr-dev-snapshots.test.py
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Cache frontend node_modules
uses: actions/cache@v5
with:
path: frontend/node_modules
key: ${{ runner.os }}-node20-frontend-${{ hashFiles('frontend/package-lock.json', 'frontend/patches/*.patch') }}
- name: Install Wails
run: go install -v github.com/wailsapp/wails/v2/cmd/wails@v2.15.0
- name: Build frontend dist
shell: bash
run: |
set -euo pipefail
mkdir -p frontend/dist
printf '<!doctype html><title>GoNavi</title>\n' > frontend/dist/index.html
cp tools/stub-dist.tar.br frontend/dist.tar.br
wails generate module
node frontend/scripts/wails-frontend-install.mjs
npm --prefix frontend run build
test -s frontend/dist.tar.br
- name: Test frontend virtual scrolling
run: npm --prefix frontend test -- src/components/dataGridVirtualScroll.test.ts src/components/virtualListNativeScroll.test.tsx src/components/DataGrid.layout.test.tsx
- name: Pack frontend dist
shell: bash
run: |
test -s frontend/dist.tar.br
# 注意 GNU tar 的 -C 是叠加语义,拆成两条命令避免相对路径踩坑
tar -cf frontend-dist.tar -C frontend/dist .
tar -rf frontend-dist.tar -C frontend dist.tar.br
- name: Upload frontend dist
uses: actions/upload-artifact@v6
with:
name: frontend-dist
path: frontend-dist.tar
if-no-files-found: error
retention-days: 1
driver_agents:
name: Detect changed driver agents
runs-on: ubuntu-latest
outputs:
drivers: ${{ steps.detect.outputs.drivers }}
drivers_darwin_amd64: ${{ steps.detect.outputs.drivers_darwin_amd64 }}
drivers_darwin_arm64: ${{ steps.detect.outputs.drivers_darwin_arm64 }}
drivers_windows_amd64: ${{ steps.detect.outputs.drivers_windows_amd64 }}
drivers_windows_arm64: ${{ steps.detect.outputs.drivers_windows_arm64 }}
drivers_linux_amd64: ${{ steps.detect.outputs.drivers_linux_amd64 }}
drivers_linux_arm64: ${{ steps.detect.outputs.drivers_linux_arm64 }}
has_changes: ${{ steps.detect.outputs.has_changes }}
release_source: ${{ steps.detect.outputs.release_source }}
compare_base: ${{ steps.detect.outputs.compare_base }}
force_global_driver_builds: ${{ steps.detect.outputs.force_global_driver_builds }}
source_commit: ${{ steps.published_source.outputs.source_commit }}
has_manifest: ${{ steps.published_source.outputs.has_manifest }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Resolve published driver release source
id: published_source
env:
DRIVER_RELEASE_TOKEN: ${{ secrets.DRIVER_RELEASE_TOKEN }}
shell: bash
run: |
set -euo pipefail
manifest_path="$RUNNER_TEMP/published-driver-manifest.json"
SOURCE_COMMIT="$(python3 tools/resolve-driver-release-source.py --repo Syngnat/GoNavi-DriverAgents --tag dev-latest --manifest-output "$manifest_path")"
echo "source_commit=${SOURCE_COMMIT}" >> "$GITHUB_OUTPUT"
if [[ -s "$manifest_path" ]]; then
echo "has_manifest=true" >> "$GITHUB_OUTPUT"
echo "🧭 Published dev driver release exposes revision manifest"
else
echo "has_manifest=false" >> "$GITHUB_OUTPUT"
echo "🧭 Published dev driver release has no revision manifest"
fi
if [[ -n "$SOURCE_COMMIT" && -s "$manifest_path" ]]; then
if bash ./tools/validate-driver-release-manifest.sh --commit "$SOURCE_COMMIT" --manifest "$manifest_path"; then
if python3 tools/validate-driver-release-assets.py --repo Syngnat/GoNavi-DriverAgents --tag dev-latest; then
echo "manifest_valid=true" >> "$GITHUB_OUTPUT"
echo "🧭 Published dev driver release manifest and actual assets are consistent with its source commit"
else
echo "manifest_valid=false" >> "$GITHUB_OUTPUT"
echo "⚠️ Published dev driver release assets do not match manifest; forcing full rebuild"
fi
else
echo "manifest_valid=false" >> "$GITHUB_OUTPUT"
echo "⚠️ Published dev driver release manifest is stale; forcing full rebuild"
fi
else
echo "manifest_valid=false" >> "$GITHUB_OUTPUT"
fi
if [[ -n "$SOURCE_COMMIT" ]]; then
echo "🧭 Last published dev driver release source commit: $SOURCE_COMMIT"
else
echo "🧭 Unable to resolve published dev driver release source commit; fallback to push diff base"
fi
- name: Detect changed driver agents
id: detect
shell: bash
run: |
set -euo pipefail
merge_csv() {
local current="$1"
local incoming="$2"
local merged="$current"
local seen=",${current},"
local item
IFS=',' read -r -a items <<< "$incoming"
for item in "${items[@]}"; do
item="$(printf '%s' "$item" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]')"
if [[ -z "$item" ]]; then
continue
fi
if [[ "$seen" == *",$item,"* ]]; then
continue
fi
if [[ -n "$merged" ]]; then
merged="${merged},${item}"
else
merged="$item"
fi
seen="${seen}${item},"
done
printf '%s\n' "$merged"
}
platform_output_key() {
case "$1" in
darwin/amd64) echo "darwin_amd64" ;;
darwin/arm64) echo "darwin_arm64" ;;
windows/amd64) echo "windows_amd64" ;;
windows/arm64) echo "windows_arm64" ;;
linux/amd64) echo "linux_amd64" ;;
linux/arm64) echo "linux_arm64" ;;
*)
echo "unknown platform: $1" >&2
return 1
;;
esac
}
BASE_REF="${{ steps.published_source.outputs.source_commit }}"
HAS_MANIFEST="${{ steps.published_source.outputs.has_manifest }}"
MANIFEST_VALID="${{ steps.published_source.outputs.manifest_valid }}"
if [[ "$HAS_MANIFEST" != "true" ]]; then
echo "⚠️ Published driver release lacks revision manifest; forcing full rebuild to self-heal old assets"
BASE_REF="all"
elif [[ "$MANIFEST_VALID" != "true" ]]; then
echo "⚠️ Published driver release manifest is stale; forcing full rebuild to self-heal old assets"
BASE_REF="all"
fi
if [[ -n "$BASE_REF" ]]; then
if git rev-parse --verify "${BASE_REF}^{commit}" >/dev/null 2>&1 && git merge-base --is-ancestor "$BASE_REF" "$GITHUB_SHA"; then
echo "🧭 Using last published driver release source commit as detection base: $BASE_REF"
else
echo "⚠️ Published driver release source commit is unavailable or not an ancestor of $GITHUB_SHA: $BASE_REF"
BASE_REF=""
fi
fi
if [[ -z "$BASE_REF" ]]; then
echo "⚠️ Falling back to full driver rebuild because published driver release source commit is unavailable"
BASE_REF="all"
fi
echo "🧭 Final driver detection base: $BASE_REF"
FORCE_GLOBAL_DRIVER_BUILDS="$(bash ./tools/should-force-global-driver-builds.sh --base "$BASE_REF" --head "$GITHUB_SHA")"
DRIVERS="$(bash ./tools/detect-changed-driver-agents.sh --base "$BASE_REF" --head "$GITHUB_SHA")"
PLATFORM_OUTPUTS=()
PLATFORM_DIFF_FAILED=false
if [[ "$BASE_REF" != "all" && "$FORCE_GLOBAL_DRIVER_BUILDS" != "true" ]]; then
REVISION_DRIVERS=""
for PLATFORM in darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 linux/amd64 linux/arm64; do
PLATFORM_KEY="$(platform_output_key "$PLATFORM")"
DIFF_ARGS=(bash ./tools/diff-driver-agent-revisions.sh --base "$BASE_REF" --head "$GITHUB_SHA" --platform "$PLATFORM")
if [[ -n "$DRIVERS" ]]; then
DIFF_ARGS+=(--drivers "$DRIVERS")
fi
PLATFORM_DRIVERS="$("${DIFF_ARGS[@]}")" || {
echo "⚠️ 平台 revision 差异对比失败(${PLATFORM}),保守回退为全量驱动重建"
DRIVERS="$(bash ./tools/detect-changed-driver-agents.sh --base all --head "$GITHUB_SHA")"
REVISION_DRIVERS=""
PLATFORM_DIFF_FAILED=true
PLATFORM_OUTPUTS=()
break
}
PLATFORM_OUTPUTS+=("drivers_${PLATFORM_KEY}=${PLATFORM_DRIVERS}")
REVISION_DRIVERS="$(merge_csv "$REVISION_DRIVERS" "$PLATFORM_DRIVERS")"
done
if [[ "$PLATFORM_DIFF_FAILED" == "false" && -n "$REVISION_DRIVERS" ]]; then
echo "🧭 Revision diff union drivers: $REVISION_DRIVERS"
DRIVERS="$(merge_csv "$DRIVERS" "$REVISION_DRIVERS")"
fi
fi
if [[ "$BASE_REF" == "all" || "$FORCE_GLOBAL_DRIVER_BUILDS" == "true" || "$PLATFORM_DIFF_FAILED" == "true" ]]; then
PLATFORM_OUTPUTS=()
for PLATFORM in darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 linux/amd64 linux/arm64; do
PLATFORM_KEY="$(platform_output_key "$PLATFORM")"
PLATFORM_OUTPUTS+=("drivers_${PLATFORM_KEY}=${DRIVERS}")
done
elif [[ ${#PLATFORM_OUTPUTS[@]} -eq 0 ]]; then
for PLATFORM in darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 linux/amd64 linux/arm64; do
PLATFORM_KEY="$(platform_output_key "$PLATFORM")"
PLATFORM_OUTPUTS+=("drivers_${PLATFORM_KEY}=")
done
fi
echo "drivers=${DRIVERS}" >> "$GITHUB_OUTPUT"
echo "compare_base=${BASE_REF}" >> "$GITHUB_OUTPUT"
echo "force_global_driver_builds=${FORCE_GLOBAL_DRIVER_BUILDS}" >> "$GITHUB_OUTPUT"
for OUTPUT_LINE in "${PLATFORM_OUTPUTS[@]}"; do
echo "$OUTPUT_LINE" >> "$GITHUB_OUTPUT"
done
if [ -n "$DRIVERS" ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "🧭 Changed driver agents: $DRIVERS"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "🧭 No driver-agent changes detected"
fi
if [[ "$FORCE_GLOBAL_DRIVER_BUILDS" == "true" ]]; then
echo "🧭 Driver build/release plumbing changed; preserve global driver rebuild set on every platform"
fi
echo "release_source=dev-latest" >> "$GITHUB_OUTPUT"
driver_revision_maps:
name: Generate canonical driver revision map ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: darwin
goarch: amd64
artifact_key: darwin-amd64
- goos: darwin
goarch: arm64
artifact_key: darwin-arm64
- goos: linux
goarch: amd64
artifact_key: linux-amd64
- goos: linux
goarch: arm64
artifact_key: linux-arm64
- goos: windows
goarch: amd64
artifact_key: windows-amd64
- goos: windows
goarch: arm64
artifact_key: windows-arm64
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Generate canonical driver revision map
shell: bash
env:
# proxy.golang.org has been returning HTTP/2 INTERNAL_ERROR mid-download.
GODEBUG: http2client=0
run: |
set -euo pipefail
./tools/generate-driver-agent-revisions.sh --platform "${{ matrix.goos }}/${{ matrix.goarch }}"
test -s internal/db/driver_agent_revisions_gen.go
- name: Upload canonical driver revision map
uses: actions/upload-artifact@v6
with:
name: dev-canonical-driver-revision-map-${{ matrix.artifact_key }}
path: internal/db/driver_agent_revisions_gen.go
if-no-files-found: error
retention-days: 1
cli:
name: Build dev CLI ${{ matrix.goos }}/${{ matrix.goarch }}
needs: driver_revision_maps
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: darwin
goarch: amd64
extension: tar.gz
binary: gonavi
- goos: darwin
goarch: arm64
extension: tar.gz
binary: gonavi
- goos: linux
goarch: amd64
extension: tar.gz
binary: gonavi
- goos: linux
goarch: arm64
extension: tar.gz
binary: gonavi
- goos: windows
goarch: amd64
extension: zip
binary: gonavi.exe
- goos: windows
goarch: arm64
extension: zip
binary: gonavi.exe
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Download canonical driver revision map
uses: actions/download-artifact@v7
with:
name: dev-canonical-driver-revision-map-${{ matrix.goos }}-${{ matrix.goarch }}
path: canonical-driver-revision-map
- name: Install canonical driver revision map
shell: bash
run: |
set -euo pipefail
test -s canonical-driver-revision-map/driver_agent_revisions_gen.go
install -m 0644 canonical-driver-revision-map/driver_agent_revisions_gen.go internal/db/driver_agent_revisions_gen.go
- name: Build and package dev CLI
shell: bash
run: |
set -euo pipefail
version="dev-${GITHUB_SHA:0:7}"
asset="gonavi-cli_${version}_${{ matrix.goos }}_${{ matrix.goarch }}.${{ matrix.extension }}"
stage="${RUNNER_TEMP}/gonavi-cli-${{ matrix.goos }}-${{ matrix.goarch }}"
mkdir -p "$stage"
# catalog.zip 是提交进 git 的派生物,二进制无法参与三方合并;合并后
# 漂移会让 Go 侧 T() 返回裸 key。构建前强制重新生成,与 wails 的
# preBuildHook 保持同一策略。
go generate ./shared/i18n
./tools/write-driver-revision-contract.sh --role cli \
--platform "${{ matrix.goos }}/${{ matrix.goarch }}" \
--output-dir driver-revision-contract
CGO_ENABLED=0 GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \
go build -trimpath -ldflags="-s -w -X GoNavi-Wails/internal/cli.Version=${version}" \
-o "$stage/${{ matrix.binary }}" ./cmd/gonavi
install -m 0644 LICENSE NOTICE "$stage/"
if [[ "${{ matrix.extension }}" == "zip" ]]; then
(cd "$stage" && zip -q -X "${GITHUB_WORKSPACE}/${asset}" "${{ matrix.binary }}" LICENSE NOTICE)
else
tar -C "$stage" -czf "$asset" "${{ matrix.binary }}" LICENSE NOTICE
fi
test -s "$asset"
expected_entries="$(printf '%s\n' "${{ matrix.binary }}" LICENSE NOTICE | sort)"
if [[ "${{ matrix.extension }}" == "zip" ]]; then
actual_entries="$(unzip -Z1 "$asset" | sort)"
else
actual_entries="$(tar -tzf "$asset" | sed 's#^\./##' | sort)"
fi
if [[ "$actual_entries" != "$expected_entries" ]]; then
echo "CLI archive contents are invalid for $asset" >&2
printf 'expected:\n%s\nactual:\n%s\n' "$expected_entries" "$actual_entries" >&2
exit 1
fi
- name: Upload dev CLI artifact
uses: actions/upload-artifact@v6
with:
name: dev-cli-artifact-${{ matrix.goos }}-${{ matrix.goarch }}
path: gonavi-cli_*
if-no-files-found: error
retention-days: 1
- name: Upload dev CLI driver revision contract
uses: actions/upload-artifact@v6
with:
name: dev-cli-driver-revision-contract-${{ matrix.goos }}-${{ matrix.goarch }}
path: driver-revision-contract/*.sha256
if-no-files-found: error
retention-days: 1
build:
name: Build ${{ matrix.platform }}
needs:
- frontend
- driver_agents
- driver_revision_maps
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: darwin/amd64
os_name: MacOS
arch_name: Amd64
build_name: gonavi-build-darwin-amd64
canonical_revision_map: darwin-amd64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: ""
- os: macos-latest
platform: darwin/arm64
os_name: MacOS
arch_name: Arm64
build_name: gonavi-build-darwin-arm64
canonical_revision_map: darwin-arm64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: ""
- os: windows-2025-vs2026
platform: windows/amd64
os_name: Windows
arch_name: Amd64
build_name: gonavi-build-windows-amd64
canonical_revision_map: windows-amd64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: ""
- os: windows-2025-vs2026
platform: windows/arm64
os_name: Windows
arch_name: Arm64
build_name: gonavi-build-windows-arm64
canonical_revision_map: windows-arm64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: ""
- os: ubuntu-22.04
platform: linux/amd64
os_name: Linux
arch_name: Amd64
build_name: gonavi-build-linux-amd64
canonical_revision_map: linux-amd64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: "4.0"
- os: ubuntu-22.04-arm
platform: linux/arm64
os_name: Linux
arch_name: Arm64
build_name: gonavi-build-linux-arm64
canonical_revision_map: linux-arm64
wails_tags: ""
artifact_suffix: ""
driver_revision_variant: ""
build_optional_agents: true
linux_webkit: "4.0"
- os: ubuntu-24.04
platform: linux/amd64
os_name: Linux
arch_name: Amd64
build_name: gonavi-build-linux-amd64-webkit41
canonical_revision_map: linux-amd64
wails_tags: "webkit2_41"
artifact_suffix: "-WebKit41"
driver_revision_variant: "webkit41"
build_optional_agents: false
linux_webkit: "4.1"
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Download canonical driver revision map
uses: actions/download-artifact@v7
with:
name: dev-canonical-driver-revision-map-${{ matrix.canonical_revision_map }}
path: canonical-driver-revision-map
- name: Install canonical driver revision map
shell: bash
run: |
set -euo pipefail
test -s canonical-driver-revision-map/driver_agent_revisions_gen.go
install -m 0644 canonical-driver-revision-map/driver_agent_revisions_gen.go internal/db/driver_agent_revisions_gen.go
- name: Download frontend dist
id: download_frontend_dist
continue-on-error: true
uses: actions/download-artifact@v7
with:
name: frontend-dist
path: frontend-artifact
- name: Reset failed frontend dist download
if: steps.download_frontend_dist.outcome != 'success'
shell: bash
run: rm -rf frontend-artifact
- name: Retry frontend dist download
if: steps.download_frontend_dist.outcome != 'success'
uses: actions/download-artifact@v7
with:
name: frontend-dist
path: frontend-artifact
- name: Extract frontend dist
shell: bash
run: |
set -euo pipefail
mkdir -p frontend/dist
test -s frontend-artifact/frontend-dist.tar
tar -xf frontend-artifact/frontend-dist.tar -C frontend/dist
test -s frontend/dist/index.html
# dist.tar.br 与 dist 内容一起打在 tar 里,移到 frontend/ 下供 go:embed
mv frontend/dist/dist.tar.br frontend/dist.tar.br
test -s frontend/dist.tar.br
- name: Install WiX Toolset (Windows)
if: contains(matrix.platform, 'windows')
shell: pwsh
run: |
$wixVersion = "6.0.2"
$wixTools = Join-Path $env:RUNNER_TEMP "wix-tools"
dotnet tool install wix --tool-path $wixTools --version $wixVersion
if ($LASTEXITCODE -ne 0) {
throw "WiX Toolset 安装失败,退出码: $LASTEXITCODE"
}
$wixTools | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
$env:PATH = "$wixTools;$env:PATH"
wix extension add --global "WixToolset.UI.wixext/$wixVersion"
if ($LASTEXITCODE -ne 0) {
throw "WiX UI 扩展安装失败,退出码: $LASTEXITCODE"
}
wix --version
- name: Install Linux Dependencies
if: contains(matrix.platform, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev
if [ "${{ matrix.linux_webkit }}" = "4.1" ]; then
sudo apt-get install -y libwebkit2gtk-4.1-dev libsoup-3.0-dev
else
sudo apt-get install -y libwebkit2gtk-4.0-dev
fi
sudo apt-get install -y upx-ucl || sudo apt-get install -y upx
upx --version
sudo apt-get install -y libfuse2 || sudo apt-get install -y libfuse2t64 || true
if [ "${{ matrix.arch_name }}" != "Amd64" ]; then
echo "⚠️ Linux arm64 暂不生成 AppImage,仅产出 tar.gz"
touch /tmp/skip-appimage
exit 0
fi
LINUXDEPLOY_URL="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
PLUGIN_URL="https://github.com/linuxdeploy/linuxdeploy-plugin-gtk/releases/download/continuous/linuxdeploy-plugin-gtk-x86_64.AppImage"
echo "📥 下载 linuxdeploy..."
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=3 \
-O /tmp/linuxdeploy "$LINUXDEPLOY_URL" || {
echo "⚠️ linuxdeploy 下载失败,AppImage 打包将跳过"
touch /tmp/skip-appimage
}
echo "📥 下载 linuxdeploy-plugin-gtk..."
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=3 \
-O /tmp/linuxdeploy-plugin-gtk "$PLUGIN_URL" || {
echo "⚠️ linuxdeploy-plugin-gtk 下载失败,AppImage 打包将跳过"
touch /tmp/skip-appimage
}
if [ ! -f /tmp/skip-appimage ]; then
chmod +x /tmp/linuxdeploy /tmp/linuxdeploy-plugin-gtk
echo "✅ AppImage 工具准备完成"
fi
- name: Install Wails
run: go install -v github.com/wailsapp/wails/v2/cmd/wails@v2.15.0
- name: Setup MSYS2 Toolchain For DuckDB (Windows AMD64)
id: msys2_duckdb
if: ${{ matrix.platform == 'windows/amd64' }}
continue-on-error: true
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-binutils
- name: Configure DuckDB CGO Toolchain (Windows AMD64)
if: ${{ matrix.platform == 'windows/amd64' }}
shell: pwsh
run: |
function Find-MingwBin([string[]]$candidates) {
foreach ($bin in $candidates) {
if ([string]::IsNullOrWhiteSpace($bin)) {
continue
}
$gcc = Join-Path $bin 'gcc.exe'
$gxx = Join-Path $bin 'g++.exe'
if ((Test-Path $gcc) -and (Test-Path $gxx)) {
return $bin
}
}
return $null
}
$msys2Outcome = "${{ steps.msys2_duckdb.outcome }}"
$msys2Location = "${{ steps.msys2_duckdb.outputs['msys2-location'] }}"
$candidateBins = @()
if (-not [string]::IsNullOrWhiteSpace($msys2Location)) {
$candidateBins += Join-Path $msys2Location 'ucrt64\bin'
}
$candidateBins += @(
'C:\msys64\ucrt64\bin',
'D:\a\_temp\msys64\ucrt64\bin'
)
$candidateBins = @($candidateBins | Select-Object -Unique)
$mingwBin = Find-MingwBin $candidateBins
if (-not $mingwBin) {
if ($msys2Outcome -ne 'success') {
Write-Warning "⚠️ MSYS2 安装步骤结果为 $msys2Outcome,回退到 UCRT64 本机路径探测"
} else {
Write-Warning "⚠️ MSYS2 已执行,但未找到 UCRT64 gcc/g++,回退到本机路径探测"
}
$mingwBin = Find-MingwBin $candidateBins
}
if (-not $mingwBin) {
Write-Error "❌ 未找到可用的 DuckDB UCRT64 编译器。已检查:$($candidateBins -join ', ')"
exit 1
}
$gcc = (Join-Path $mingwBin 'gcc.exe')
$gxx = (Join-Path $mingwBin 'g++.exe')
if (!(Test-Path $gcc) -or !(Test-Path $gxx)) {
Write-Error "❌ DuckDB 编译器缺失:gcc=$gcc g++=$gxx"
exit 1
}
"$mingwBin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
"CC=$gcc" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
"CXX=$gxx" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
Write-Host "✅ 已配置 DuckDB cgo 编译器: gcc=$gcc g++=$gxx"
- name: Verify DuckDB CGO Toolchain (Windows AMD64)
if: ${{ matrix.platform == 'windows/amd64' }}
shell: pwsh
run: |
& "$env:CC" --version
& "$env:CXX" --version
- name: Test Windows Online Updater (Windows AMD64)
if: ${{ matrix.platform == 'windows/amd64' }}
shell: pwsh
run: go test . ./internal/app -run '^(TestShouldEnableWindowsMSISingleInstanceOnlyForInstalledMainGUI|TestPrimaryWindowActivatorQueuesRequestsUntilRuntimeStartup|TestAcquireWindowsMSISingleInstance|TestResolveWindowsUpdateMaintenanceName|TestAcquireWindowsUpdateMaintenance|TestPrepareWindowsUpdateHandoff|TestWindowsPowerShellUpdater|TestBuildWindowsLaunchCommandUsesHiddenPowerShellFile|TestExpectedAssetNameForExecutableUsesWindowsPortableSuffix|TestShouldWindowsUpdateLaunchDownloadedAssetDirectly|TestResolveUpdateInstallMode|TestExpectedAssetNameForWindowsInstallMode|TestPortableUpdatePackageAcceptsZipAndLegacyExe|TestResolveReusableStagedUpdateForPlatformReusesPortableZipInsideStagedDir|TestResolveWindowsUpdateFinalTargetPathMapsDownloadedPortableZipToExe|TestResolveUpdateWorkspaceDirForPlatformSeparatesMSIFromInstallDirectory|TestValidateUpdatePackageForCurrentInstallMode|TestWindowsUpdateRequiresExplicitCloseConfirmation|TestInstallUpdateAndRestartRequiresCloseConfirmationOnWindows|TestInstallUpdateAndRestartSkipsCloseConfirmationForSingleWindowsInstance|TestInstallUpdateAndRestartMSI|TestFindOtherWindowsUpdateInstances|TestCloseWindowsUpdateInstances|TestInstallUpdateAndRestartClosesOtherTargetInstances|TestBuildWindowsMSIUpdatePowerShellScript|TestBuildWindowsMSILaunchCommand|TestResolveWindowsMSIExecPath)' -count=1 -timeout=3m
# ---- 生成 dev 版本号 ----
- name: Generate Dev Version
id: version
shell: bash
run: |
SHORT_SHA="${GITHUB_SHA:0:7}"
DEV_VERSION="dev-${SHORT_SHA}"
echo "version=${DEV_VERSION}" >> "$GITHUB_OUTPUT"
echo "📌 Dev 版本号: ${DEV_VERSION}"
- name: Build
shell: bash
run: |
set -euo pipefail
DEV_VERSION="${{ steps.version.outputs.version }}"
revision_contract_args=(
--role gui
--platform "${{ matrix.platform }}"
--output-dir driver-revision-contract
)
if [[ -n "${{ matrix.driver_revision_variant }}" ]]; then
revision_contract_args+=(--variant "${{ matrix.driver_revision_variant }}")
fi
./tools/write-driver-revision-contract.sh "${revision_contract_args[@]}"
REVISION_HASH="$(python3 - <<'PY'
import hashlib
from pathlib import Path
print(hashlib.sha256(Path("internal/db/driver_agent_revisions_gen.go").read_bytes()).hexdigest())
PY
)"
export GOCACHE="${RUNNER_TEMP}/go-build-${{ matrix.os_name }}-${{ matrix.arch_name }}-${REVISION_HASH}"
mkdir -p "$GOCACHE"
echo "🧭 使用隔离 GOCACHE:$GOCACHE"
python3 scripts/ci-apply-wails-webkit-tags.py "${{ matrix.linux_webkit }}"
if [ -n "${{ matrix.wails_tags }}" ]; then
wails build -s -skipbindings -trimpath -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -tags "${{ matrix.wails_tags }}" -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${DEV_VERSION}"
else
wails build -s -skipbindings -trimpath -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${DEV_VERSION}"
fi
- name: Select Platform Driver Set
id: platform_drivers
if: ${{ matrix.build_optional_agents && needs.driver_agents.outputs.has_changes == 'true' }}
shell: bash
run: |
set -euo pipefail
case "${{ matrix.platform }}" in
darwin/amd64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_darwin_amd64 }}'
;;
darwin/arm64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_darwin_arm64 }}'
;;
windows/amd64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_windows_amd64 }}'
;;
windows/arm64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_windows_arm64 }}'
;;
linux/amd64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_linux_amd64 }}'
;;
linux/arm64)
DRIVERS='${{ needs.driver_agents.outputs.drivers_linux_arm64 }}'
;;
*)
echo "unsupported platform: ${{ matrix.platform }}" >&2
exit 1
;;
esac
echo "drivers=${DRIVERS}" >> "$GITHUB_OUTPUT"
if [[ -n "$DRIVERS" ]]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "🧭 当前平台最终需要重建的 driver agents: ${DRIVERS}"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "🧭 当前平台无需重建 driver agents"
fi
- name: Build Optional Driver Agents
if: ${{ matrix.build_optional_agents && steps.platform_drivers.outputs.has_changes == 'true' }}
shell: bash
env:
CHANGED_DRIVER_AGENTS: ${{ steps.platform_drivers.outputs.drivers }}
run: |
set -euo pipefail
TARGET_PLATFORM="${{ matrix.platform }}"
GOOS="${TARGET_PLATFORM%%/*}"
GOARCH="${TARGET_PLATFORM##*/}"
# driver agent 经 internal/db 间接嵌入 shared/i18n,catalog.zip 漂移
# 同样会让其编译进过期目录;先重新生成再编译。
go generate ./shared/i18n
# 数据源描述表里声明的驱动(TiDB、崖山等)按描述表归一、取构建标签与发布平台。
source ./tools/datasource-registry.sh
load_datasource_registry "$PWD"
REVISION_HASH="$(python3 - <<'PY'
import hashlib
from pathlib import Path
print(hashlib.sha256(Path("internal/db/driver_agent_revisions_gen.go").read_bytes()).hexdigest())
PY
)"
export GOCACHE="${RUNNER_TEMP}/go-build-${{ matrix.os_name }}-${{ matrix.arch_name }}-${REVISION_HASH}"
mkdir -p "$GOCACHE"
echo "🧭 可选驱动使用隔离 GOCACHE:$GOCACHE"
normalize_driver_token() {
local value
value="$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]')"
case "$value" in
"") return 1 ;;
doris|diros) echo "doris" ;;
open_gauss|open-gauss) echo "opengauss" ;;
gaussdb|gauss_db|gauss-db) echo "gaussdb" ;;
elastic|elasticsearch) echo "elasticsearch" ;;
mariadb|oceanbase|starrocks|sphinx|sqlserver|sqlite|duckdb|dameng|kingbase|highgo|vastbase|opengauss|gaussdb|iris|cache|mongodb|tdengine|iotdb|clickhouse|trino|kafka|rocketmq|pulsar)
echo "$value"
;;
*)
if registry_normalize_driver "$value"; then
return 0
fi
echo "❌ 不支持的 driver-agent:${1:-}" >&2
return 1
;;
esac
}
build_driver_name() {
case "$1" in
doris) echo "diros" ;;
*) echo "$1" ;;
esac
}
declare -a RAW_DRIVERS=()
declare -a DRIVERS=()
IFS=',' read -r -a RAW_DRIVERS <<< "$CHANGED_DRIVER_AGENTS"
for RAW_DRIVER in "${RAW_DRIVERS[@]}"; do
[[ -n "${RAW_DRIVER//[[:space:]]/}" ]] || continue
# 清单里出现无法识别的驱动时直接失败:此前这里静默跳过,新驱动整批漏发而 CI 仍然是绿的。
if ! DRIVER="$(normalize_driver_token "$RAW_DRIVER")"; then
echo "❌ 驱动构建清单里有无法识别的 driver-agent:${RAW_DRIVER}" >&2
exit 1
fi
DRIVERS+=("$DRIVER")
done
if [ ${#DRIVERS[@]} -eq 0 ]; then
echo "🧭 没有需要构建的 driver-agent"
exit 0
fi
NORMALIZED_CHANGED_DRIVER_AGENTS="$(IFS=,; echo "${DRIVERS[*]}")"
echo "🧭 归一后的 driver-agent 构建列表:${NORMALIZED_CHANGED_DRIVER_AGENTS}"
OUTDIR="drivers/${{ matrix.os_name }}"
mkdir -p "$OUTDIR"
DUCKDB_WINDOWS_LIBRARY_VERSION="v1.4.4"
DUCKDB_WINDOWS_LIBRARY_URL="https://github.com/duckdb/duckdb/releases/download/${DUCKDB_WINDOWS_LIBRARY_VERSION}/libduckdb-windows-amd64.zip"
prepare_duckdb_windows_library() {
local lib_dir="$RUNNER_TEMP/duckdb-windows-${DUCKDB_WINDOWS_LIBRARY_VERSION}"
local extract_dir="$RUNNER_TEMP/duckdb-windows-extract-${DUCKDB_WINDOWS_LIBRARY_VERSION}"
local zip_path="$RUNNER_TEMP/libduckdb-windows-amd64.zip"
if [ -f "$lib_dir/duckdb.dll" ] && [ -f "$lib_dir/libduckdb.dll.a" ] && [ -f "$lib_dir/libduckdb.a" ]; then
echo "$lib_dir"
return 0
fi
mkdir -p "$lib_dir"
rm -rf "$extract_dir"
rm -f "$zip_path"
local attempt dll_path
for attempt in 1 2 3; do
echo "📥 下载 DuckDB Windows 动态库 (${attempt}/3): ${DUCKDB_WINDOWS_LIBRARY_URL}" >&2
if curl --retry 3 --retry-delay 2 --retry-all-errors --connect-timeout 20 --max-time 300 -fsSL "$DUCKDB_WINDOWS_LIBRARY_URL" -o "$zip_path"; then
if unzip -tq "$zip_path" >/dev/null 2>&1; then
rm -rf "$lib_dir"
rm -rf "$extract_dir"
mkdir -p "$lib_dir"
mkdir -p "$extract_dir"
unzip -qo "$zip_path" -d "$extract_dir"
dll_path="$(find "$extract_dir" -type f -name duckdb.dll | head -n 1 || true)"
if [ -n "$dll_path" ]; then
cp "$dll_path" "$lib_dir/duckdb.dll"
go run ./cmd/mingw-import-lib \
--dll "$lib_dir/duckdb.dll" \
--output-lib "$lib_dir/libduckdb.dll.a"
cp "$lib_dir/libduckdb.dll.a" "$lib_dir/libduckdb.a"
rm -rf "$extract_dir"
echo "$lib_dir"
return 0
fi
echo "⚠️ DuckDB Windows 动态库压缩包缺少 duckdb.dll,准备重试" >&2
else
echo "⚠️ DuckDB Windows 动态库压缩包校验失败,准备重试" >&2
fi
else
echo "⚠️ DuckDB Windows 动态库下载失败,准备重试" >&2
fi
rm -f "$zip_path"
rm -rf "$lib_dir"
rm -rf "$extract_dir"
mkdir -p "$lib_dir"
sleep $((attempt * 2))
done
echo "❌ 无法准备 DuckDB Windows 动态库:${DUCKDB_WINDOWS_LIBRARY_URL}" >&2
return 1
}
for DRIVER in "${DRIVERS[@]}"; do
BUILD_DRIVER="$(build_driver_name "$DRIVER")"
if [ "$DRIVER" = "duckdb" ] && [ "$GOOS" = "windows" ] && [ "$GOARCH" != "amd64" ]; then
echo "⚠️ 跳过 DuckDB driver(当前平台 ${GOOS}/${GOARCH} 不受支持,仅支持 windows/amd64)"
continue
fi
if ! registry_driver_platform_supported "$DRIVER" "$TARGET_PLATFORM"; then
echo "⚠️ 跳过 ${DRIVER} driver(描述表未声明 ${TARGET_PLATFORM} 平台)"
continue
fi
DRIVER_CGO="$(registry_driver_cgo "$DRIVER" 2>/dev/null || echo 0)"
DRIVER_VARIANTS=("")
if [ "$DRIVER" = "mongodb" ]; then
DRIVER_VARIANTS=("v1" "v2" "")
fi
for DRIVER_VARIANT in "${DRIVER_VARIANTS[@]}"; do
TAG="$(registry_driver_build_tag "$DRIVER" 2>/dev/null || echo "gonavi_${BUILD_DRIVER}_driver")"
BUILD_TAGS="$TAG"
OUTPUT_STEM="${DRIVER}-driver-agent"
if [ "$DRIVER" = "mongodb" ]; then
if [ "$DRIVER_VARIANT" = "v1" ]; then
BUILD_TAGS="gonavi_mongodb_driver_v1"
OUTPUT_STEM="mongodb-driver-agent-v1"
elif [ "$DRIVER_VARIANT" = "v2" ]; then
BUILD_TAGS="gonavi_mongodb_driver"
OUTPUT_STEM="mongodb-driver-agent-v2"
else
BUILD_TAGS="gonavi_mongodb_driver"
fi
fi
OUTPUT="${OUTPUT_STEM}-${GOOS}-${GOARCH}"
if [ "$GOOS" = "windows" ]; then
OUTPUT="${OUTPUT}.exe"
fi