-
Notifications
You must be signed in to change notification settings - Fork 50
1560 lines (1319 loc) · 58.5 KB
/
release.yml
File metadata and controls
1560 lines (1319 loc) · 58.5 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 Build(发布构建)
permissions:
contents: write
on:
release:
types: [ created ] # 当创建新的 Release 时触发
workflow_dispatch: { } # 支持手动触发
env:
JAVA_VERSION: '17'
JAVA_DISTRIBUTION: 'jetbrains' # 使用 JetBrains Runtime(JBR),为 Swing 应用优化
JLINK_MODULES: 'java.base,java.desktop,java.logging,jdk.unsupported,java.naming,java.net.http,java.prefs,java.sql,java.security.sasl,java.security.jgss,jdk.crypto.ec,java.management,java.management.rmi,jdk.crypto.cryptoki'
# 通用 Java 选项(所有平台共享)
JAVA_OPTIONS_COMMON: '-Xms512m|-Xmx1g|-XX:MaxMetaspaceSize=256m|-XX:MetaspaceSize=128m|-XX:MaxDirectMemorySize=256m|-XX:+UseG1GC|-XX:MaxGCPauseMillis=200|-XX:InitiatingHeapOccupancyPercent=45|-XX:+UseStringDeduplication|-XX:+HeapDumpOnOutOfMemoryError|-XX:HeapDumpPath=./dumps|-Dfile.encoding=UTF-8|-Dswing.aatext=true|-Djava.net.preferIPv4Stack=true|-Dhttp.keepAlive=true'
# Windows 特定选项
JAVA_OPTIONS_WINDOWS: '-Djavax.accessibility.assistive_technologies='
# macOS 特定选项
JAVA_OPTIONS_MACOS: '-Dsun.java2d.metal=false|-Dapple.awt.application.appearance=system|--add-opens java.desktop/java.awt=ALL-UNNAMED|--add-opens java.desktop/sun.lwawt=ALL-UNNAMED|--add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED|--add-exports java.desktop/com.apple.eawt=ALL-UNNAMED'
# Linux 特定选项
JAVA_OPTIONS_LINUX: '-Dawt.useSystemAAFontSettings=on|--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED'
jobs:
# 提取版本号,供所有 job 复用
get-version:
name: Get Version(获取版本号)
runs-on: ubuntu-latest
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version(提取版本号)
id: extract_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Validate release source and version(校验默认分支与版本一致性)
shell: bash
run: |
set -euo pipefail
DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
CURRENT_REF="${{ github.ref_name }}"
VERSION="${{ steps.extract_version.outputs.version }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "$CURRENT_REF" != "$DEFAULT_BRANCH" ]; then
echo "workflow_dispatch is only allowed from the default branch: ${DEFAULT_BRANCH}" >&2
exit 1
fi
if [ "${{ github.event_name }}" = "release" ]; then
TAG_NAME="${{ github.event.release.tag_name }}"
TARGET_COMMITISH="${{ github.event.release.target_commitish }}"
EXPECTED_TAG="v${VERSION}"
if [ "$TARGET_COMMITISH" != "$DEFAULT_BRANCH" ]; then
echo "Release must target default branch ${DEFAULT_BRANCH}, got ${TARGET_COMMITISH}" >&2
exit 1
fi
if [ "$TAG_NAME" != "$EXPECTED_TAG" ]; then
echo "Release tag ${TAG_NAME} does not match pom version ${VERSION}" >&2
exit 1
fi
fi
# 构建 Fat JAR(跨平台),供所有平台复用
build-jar-artifact:
name: Build Fat JAR(构建跨平台 JAR)
runs-on: ubuntu-latest
needs: [ get-version ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven(使用 Maven 构建 Fat JAR)
run: mvn -B clean package -DskipTests
- name: Upload JAR for reuse(上传 JAR 供其他 job 复用)
uses: actions/upload-artifact@v4
with:
name: app-jar
path: easy-postman-app/target/easy-postman-${{ needs.get-version.outputs.version }}.jar
retention-days: 1
build-windows-portable:
name: Build Windows Portable(构建 Windows 绿色版)
runs-on: windows-latest
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Create runtime with jlink(使用 jlink 创建 Windows 精简 JRE)
shell: pwsh
run: |
$runtimeDir = "target\runtime"
if (Test-Path $runtimeDir) { Remove-Item -Recurse -Force $runtimeDir }
jlink `
--add-modules $env:JLINK_MODULES `
--strip-java-debug-attributes `
--strip-native-commands `
--strip-debug `
--no-header-files `
--no-man-pages `
--compress=2 `
--verbose `
--output $runtimeDir
# 验证 JRE 大小
$size = (Get-ChildItem -Path $runtimeDir -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB
Write-Host "✅ JRE 创建成功,大小: $([math]::Round($size, 2)) MB"
- name: Prepare dist-input(准备打包输入目录)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$jarNameWithVersion = "easy-postman-$version.jar"
$jarName = "easy-postman.jar"
$distInputDir = "target\dist-input"
if (Test-Path $distInputDir) { Remove-Item -Recurse -Force $distInputDir }
New-Item -ItemType Directory -Path $distInputDir | Out-Null
Copy-Item "target\$jarNameWithVersion" -Destination "$distInputDir\$jarName"
- name: Create app-image with jpackage(创建应用镜像,免安装)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$jarName = "easy-postman.jar"
$appImageDir = "target\app-image"
if (Test-Path $appImageDir) { Remove-Item -Recurse -Force $appImageDir }
# 解析通用 Java 选项
$javaOptsCommon = $env:JAVA_OPTIONS_COMMON -split '\|'
# 解析 Windows 特定选项
$javaOptsWindows = $env:JAVA_OPTIONS_WINDOWS -split '\|'
# 构建 jpackage 参数列表
$jpackageArgs = @(
'--type', 'app-image',
'--input', 'target\dist-input',
'--main-jar', $jarName,
'--main-class', 'com.laker.postman.App',
'--runtime-image', 'target\runtime',
'--dest', 'target',
'--icon', 'assets\win\EasyPostman.ico',
'--name', 'EasyPostman',
'--app-version', $version,
'--vendor', 'Laker',
'--copyright', '© 2025 Laker'
)
# 添加通用 Java 选项
foreach ($opt in $javaOptsCommon) {
$jpackageArgs += '--java-options'
$jpackageArgs += $opt
}
# 添加 Windows 特定选项
foreach ($opt in $javaOptsWindows) {
if ($opt -ne '') {
$jpackageArgs += '--java-options'
$jpackageArgs += $opt
}
}
# 执行 jpackage
& jpackage @jpackageArgs
- name: Package portable version(打包绿色版为 ZIP)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$appImageDir = "target\EasyPostman"
$zipName = "EasyPostman-$version-windows-x64-portable.zip"
if (-not (Test-Path "dist")) { New-Item -ItemType Directory -Path "dist" | Out-Null }
# 创建 .portable 标识文件,用于运行时检测便携版
$portableMarker = Join-Path $appImageDir ".portable"
"This is a portable version" | Out-File -FilePath $portableMarker -Encoding UTF8
Write-Host "Created .portable marker file"
# 压缩为 ZIP
Compress-Archive -Path $appImageDir -DestinationPath "dist\$zipName" -Force
Write-Host "✅ Created portable version: $zipName"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-Windows-Portable
path: dist/*-portable.zip
retention-days: 7
build-windows-exe:
name: Build Windows EXE Installer(构建 Windows EXE 安装程序)
runs-on: windows-latest
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Install Inno Setup(安装 Inno Setup)
shell: pwsh
run: |
Write-Host "📦 Installing Inno Setup..."
choco install innosetup -y --no-progress
# 刷新环境变量
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# 验证安装
$iscc = Get-Command iscc -ErrorAction SilentlyContinue
if ($iscc) {
Write-Host "✅ Inno Setup installed: $($iscc.Source)"
# 显示版本信息(iscc 不带参数会显示版本和帮助)
& iscc 2>&1 | Select-Object -First 5
} else {
Write-Error "❌ Inno Setup installation failed"
exit 1
}
- name: Create runtime with jlink(使用 jlink 创建 Windows 精简 JRE)
shell: pwsh
run: |
$runtimeDir = "target\runtime"
if (Test-Path $runtimeDir) { Remove-Item -Recurse -Force $runtimeDir }
jlink `
--add-modules $env:JLINK_MODULES `
--strip-java-debug-attributes `
--strip-native-commands `
--strip-debug `
--no-header-files `
--no-man-pages `
--compress=2 `
--verbose `
--output $runtimeDir
# 验证 JRE 大小
$size = (Get-ChildItem -Path $runtimeDir -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB
Write-Host "✅ JRE 创建成功,大小: $([math]::Round($size, 2)) MB"
- name: Prepare dist-input(准备打包输入目录)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$jarNameWithVersion = "easy-postman-$version.jar"
$jarName = "easy-postman.jar"
$distInputDir = "target\dist-input"
if (Test-Path $distInputDir) { Remove-Item -Recurse -Force $distInputDir }
New-Item -ItemType Directory -Path $distInputDir | Out-Null
Copy-Item "target\$jarNameWithVersion" -Destination "$distInputDir\$jarName"
- name: Create app-image with jpackage(创建应用镜像)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$jarName = "easy-postman.jar"
# 解析通用 Java 选项
$javaOptsCommon = $env:JAVA_OPTIONS_COMMON -split '\|'
# 解析 Windows 特定选项
$javaOptsWindows = $env:JAVA_OPTIONS_WINDOWS -split '\|'
# 构建 jpackage 参数列表
$jpackageArgs = @(
'--type', 'app-image',
'--input', 'target\dist-input',
'--main-jar', $jarName,
'--main-class', 'com.laker.postman.App',
'--runtime-image', 'target\runtime',
'--dest', 'target',
'--icon', 'assets\win\EasyPostman.ico',
'--name', 'EasyPostman',
'--app-version', $version,
'--vendor', 'Laker',
'--copyright', '© 2025 Laker'
)
# 添加通用 Java 选项
foreach ($opt in $javaOptsCommon) {
$jpackageArgs += '--java-options'
$jpackageArgs += $opt
}
# 添加 Windows 特定选项
foreach ($opt in $javaOptsWindows) {
if ($opt -ne '') {
$jpackageArgs += '--java-options'
$jpackageArgs += $opt
}
}
# 执行 jpackage
& jpackage @jpackageArgs
Write-Host "✅ App image created at: target\EasyPostman"
- name: Create EXE with Inno Setup(使用 Inno Setup 创建 EXE 安装程序)
shell: pwsh
run: |
$version = "${{ needs.get-version.outputs.version }}"
$issScript = "build\easy-postman.iss"
$arch = "x64" # 当前构建为 x64,未来可扩展为 arm64
# 确保输出目录存在
if (-not (Test-Path "dist")) {
New-Item -ItemType Directory -Path "dist" | Out-Null
}
Write-Host "🔨 Building EXE installer with Inno Setup..."
Write-Host " Version: $version"
Write-Host " Architecture: $arch"
Write-Host " Script: $issScript"
Write-Host " Source: target\EasyPostman"
# 验证源目录存在
if (-not (Test-Path "target\EasyPostman")) {
Write-Error "❌ Source directory not found: target\EasyPostman"
exit 1
}
# 运行 Inno Setup 编译器
# 注意:路径相对于 ISS 脚本位置(build 目录),所以需要 ..\
& iscc `
"/DMyAppVersion=$version" `
"/DMyAppSourceDir=..\target\EasyPostman" `
"/DMyOutputDir=..\dist" `
"/DMyArch=$arch" `
$issScript
if ($LASTEXITCODE -ne 0) {
Write-Error "❌ Inno Setup compilation failed with exit code: $LASTEXITCODE"
exit 1
}
# 验证 EXE 文件
$expectedExeName = "EasyPostman-$version-windows-$arch.exe"
$exeFile = Get-Item "dist\$expectedExeName" -ErrorAction SilentlyContinue
if ($exeFile) {
Write-Host "✅ EXE installer created successfully!"
Write-Host " File: $($exeFile.Name)"
Write-Host " Size: $([math]::Round($exeFile.Length / 1MB, 2)) MB"
Write-Host " Path: $($exeFile.FullName)"
} else {
Write-Error "❌ Expected EXE file not found: $expectedExeName"
Write-Host "Files in dist folder:"
Get-ChildItem "dist" | ForEach-Object { Write-Host " - $($_.Name)" }
exit 1
}
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-Windows-EXE
path: dist/*.exe
retention-days: 7
build-macos-intel:
name: Build macOS Intel DMG(构建 macOS Intel 版安装包)
runs-on: macos-15-intel # Intel x86_64
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Create runtime with jlink(使用 jlink 创建 macOS Intel 精简 JRE)
run: |
rm -rf target/runtime
# 创建 macOS Intel 平台的 JRE
jlink \
--add-modules ${{ env.JLINK_MODULES }} \
--strip-java-debug-attributes \
--strip-native-commands \
--strip-debug \
--no-header-files \
--no-man-pages \
--compress=2 \
--verbose \
--output target/runtime
# 验证 JRE 大小
echo "✅ JRE 创建成功,大小: $(du -sh target/runtime | cut -f1)"
- name: Prepare dist-input(准备打包输入目录)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
rm -rf target/dist-input
mkdir -p target/dist-input
cp target/easy-postman-$VERSION.jar target/dist-input/easy-postman.jar
- name: Create DMG with jpackage(使用 jpackage 创建 DMG 镜像)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
mkdir -p dist
# 解析通用 Java 选项
IFS='|' read -ra JAVA_OPTS_COMMON <<< "${{ env.JAVA_OPTIONS_COMMON }}"
# 解析 macOS 特定选项
IFS='|' read -ra JAVA_OPTS_MACOS <<< "${{ env.JAVA_OPTIONS_MACOS }}"
# 构建 jpackage 参数数组
JPACKAGE_ARGS=(
--input target/dist-input
--main-jar "easy-postman.jar"
--main-class com.laker.postman.App
--runtime-image target/runtime
--type dmg
--name "EasyPostman"
--app-version "$VERSION"
--dest dist
--icon assets/mac/EasyPostman.icns
--vendor "Laker"
--copyright "© 2025 Laker"
)
# 添加通用 Java 选项
for opt in "${JAVA_OPTS_COMMON[@]}"; do
JPACKAGE_ARGS+=(--java-options "$opt")
done
# 添加 macOS 特定选项
for opt in "${JAVA_OPTS_MACOS[@]}"; do
if [ -n "$opt" ]; then
JPACKAGE_ARGS+=(--java-options "$opt")
fi
done
# 执行 jpackage
jpackage "${JPACKAGE_ARGS[@]}"
# 重命名为 Intel 版本(使用标准架构标识)
mv dist/EasyPostman-$VERSION.dmg dist/EasyPostman-$VERSION-macos-x86_64.dmg
echo "✅ Created: EasyPostman-$VERSION-macos-x86_64.dmg"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-macOS-Intel-DMG
path: dist/*-macos-x86_64.dmg
retention-days: 7
build-macos-arm:
name: Build macOS Apple Silicon DMG(构建 macOS Apple Silicon 版安装包)
runs-on: macos-latest # Apple Silicon (M1/M2/M3/M4)
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Create runtime with jlink(使用 jlink 创建 macOS ARM 精简 JRE)
run: |
rm -rf target/runtime
# 创建 macOS ARM 平台的 JRE
jlink \
--add-modules ${{ env.JLINK_MODULES }} \
--strip-java-debug-attributes \
--strip-native-commands \
--strip-debug \
--no-header-files \
--no-man-pages \
--compress=2 \
--verbose \
--output target/runtime
# 验证 JRE 大小
echo "✅ JRE 创建成功,大小: $(du -sh target/runtime | cut -f1)"
- name: Prepare dist-input(准备打包输入目录)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
rm -rf target/dist-input
mkdir -p target/dist-input
cp target/easy-postman-$VERSION.jar target/dist-input/easy-postman.jar
- name: Create DMG with jpackage(使用 jpackage 创建 DMG 镜像)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
mkdir -p dist
# 解析通用 Java 选项
IFS='|' read -ra JAVA_OPTS_COMMON <<< "${{ env.JAVA_OPTIONS_COMMON }}"
# 解析 macOS 特定选项
IFS='|' read -ra JAVA_OPTS_MACOS <<< "${{ env.JAVA_OPTIONS_MACOS }}"
# 构建 jpackage 参数数组
JPACKAGE_ARGS=(
--input target/dist-input
--main-jar "easy-postman.jar"
--main-class com.laker.postman.App
--runtime-image target/runtime
--type dmg
--name "EasyPostman"
--app-version "$VERSION"
--dest dist
--icon assets/mac/EasyPostman.icns
--vendor "Laker"
--copyright "© 2025 Laker"
)
# 添加通用 Java 选项
for opt in "${JAVA_OPTS_COMMON[@]}"; do
JPACKAGE_ARGS+=(--java-options "$opt")
done
# 添加 macOS 特定选项
for opt in "${JAVA_OPTS_MACOS[@]}"; do
if [ -n "$opt" ]; then
JPACKAGE_ARGS+=(--java-options "$opt")
fi
done
# 执行 jpackage
jpackage "${JPACKAGE_ARGS[@]}"
# 重命名为 ARM 版本(使用标准架构标识)
mv dist/EasyPostman-$VERSION.dmg dist/EasyPostman-$VERSION-macos-arm64.dmg
echo "✅ Created: EasyPostman-$VERSION-macos-arm64.dmg"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-macOS-ARM-DMG
path: dist/*-macos-arm64.dmg
retention-days: 7
build-jar:
name: Build Standalone JAR(构建独立 JAR 包)
runs-on: ubuntu-latest
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Download JAR artifact(下载已构建的 JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: dist
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-Standalone-JAR
path: dist/*.jar
retention-days: 7
build-ubuntu-amd64:
name: Build Ubuntu DEB amd64(构建 Ubuntu x64 安装包)
runs-on: ubuntu-22.04
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Install dependencies(安装系统依赖)
run: |
sudo apt-get update
# 安装 GTK3、WebKit、打包工具,以及 DEB 兼容重打包所需压缩工具
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev binutils zstd xz-utils
- name: Create runtime with jlink(使用 jlink 创建 Linux 精简 JRE)
run: |
rm -rf target/runtime
# 创建 Linux 平台的 JRE
jlink \
--add-modules ${{ env.JLINK_MODULES }} \
--strip-debug \
--no-header-files \
--no-man-pages \
--compress=2 \
--output target/runtime
- name: Prepare dist-input(准备打包输入目录)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
rm -rf target/dist-input
mkdir -p target/dist-input
cp target/easy-postman-$VERSION.jar target/dist-input/easy-postman.jar
- name: Create DEB with jpackage(使用 jpackage 创建 DEB 安装包)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
mkdir -p dist
# 解析通用 Java 选项
IFS='|' read -ra JAVA_OPTS_COMMON <<< "${{ env.JAVA_OPTIONS_COMMON }}"
# 解析 Linux 特定选项
IFS='|' read -ra JAVA_OPTS_LINUX <<< "${{ env.JAVA_OPTIONS_LINUX }}"
# 构建 jpackage 参数数组
JPACKAGE_ARGS=(
--input target/dist-input
--main-jar "easy-postman.jar"
--main-class com.laker.postman.App
--runtime-image target/runtime
--type deb
--name "EasyPostman"
--app-version "$VERSION"
--dest dist
--vendor "Laker"
--copyright "© 2025 Laker"
--description "A modern API testing tool similar to Postman"
--linux-shortcut
--linux-menu-group "Development"
--linux-app-category "Development"
)
# 添加通用 Java 选项
for opt in "${JAVA_OPTS_COMMON[@]}"; do
JPACKAGE_ARGS+=(--java-options "$opt")
done
# 添加 Linux 特定选项
for opt in "${JAVA_OPTS_LINUX[@]}"; do
if [ -n "$opt" ]; then
JPACKAGE_ARGS+=(--java-options "$opt")
fi
done
# 执行 jpackage
jpackage "${JPACKAGE_ARGS[@]}"
- name: Repack DEB members to xz(重打包为 xz 兼容格式)
run: |
DEB_FILE=$(find dist -maxdepth 1 -type f -name "*.deb" | sort | tail -n 1)
if [ -z "$DEB_FILE" ]; then
echo "No DEB file generated by jpackage" >&2
exit 1
fi
bash build/repack-deb-to-xz.sh "$DEB_FILE"
echo "Repacked package:"
ar t "$DEB_FILE"
- name: Rename amd64 DEB to stable release name(统一 amd64 包名)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
ORIGINAL_DEB=$(find dist -maxdepth 1 -type f -name "*.deb" | sort | tail -n 1)
if [ -z "$ORIGINAL_DEB" ]; then
echo "No DEB file available for renaming" >&2
exit 1
fi
TARGET_DEB="dist/EasyPostman-${VERSION}-linux-amd64.deb"
mv "$ORIGINAL_DEB" "$TARGET_DEB"
echo "Generated amd64 DEB:"
ls -1 "$TARGET_DEB"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-Ubuntu-DEB-amd64
path: dist/*-linux-amd64.deb
retention-days: 7
build-ubuntu-arm64:
name: Build Ubuntu DEB arm64(构建 Ubuntu ARM64 安装包)
runs-on: ubuntu-22.04-arm
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Install dependencies(安装系统依赖)
run: |
sudo apt-get update
# 安装 GTK3、WebKit、打包工具,以及 DEB 兼容重打包所需压缩工具
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev binutils zstd xz-utils
- name: Create runtime with jlink(使用 jlink 创建 Linux 精简 JRE)
run: |
rm -rf target/runtime
# 创建 Linux 平台的 JRE
jlink \
--add-modules ${{ env.JLINK_MODULES }} \
--strip-debug \
--no-header-files \
--no-man-pages \
--compress=2 \
--output target/runtime
- name: Prepare dist-input(准备打包输入目录)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
rm -rf target/dist-input
mkdir -p target/dist-input
cp target/easy-postman-$VERSION.jar target/dist-input/easy-postman.jar
- name: Create DEB with jpackage(使用 jpackage 创建 DEB 安装包)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
mkdir -p dist
# 解析通用 Java 选项
IFS='|' read -ra JAVA_OPTS_COMMON <<< "${{ env.JAVA_OPTIONS_COMMON }}"
# 解析 Linux 特定选项
IFS='|' read -ra JAVA_OPTS_LINUX <<< "${{ env.JAVA_OPTIONS_LINUX }}"
# 构建 jpackage 参数数组
JPACKAGE_ARGS=(
--input target/dist-input
--main-jar "easy-postman.jar"
--main-class com.laker.postman.App
--runtime-image target/runtime
--type deb
--name "EasyPostman"
--app-version "$VERSION"
--dest dist
--vendor "Laker"
--copyright "© 2025 Laker"
--description "A modern API testing tool similar to Postman"
--linux-shortcut
--linux-menu-group "Development"
--linux-app-category "Development"
)
# 添加通用 Java 选项
for opt in "${JAVA_OPTS_COMMON[@]}"; do
JPACKAGE_ARGS+=(--java-options "$opt")
done
# 添加 Linux 特定选项
for opt in "${JAVA_OPTS_LINUX[@]}"; do
if [ -n "$opt" ]; then
JPACKAGE_ARGS+=(--java-options "$opt")
fi
done
# 执行 jpackage
jpackage "${JPACKAGE_ARGS[@]}"
- name: Repack DEB members to xz(重打包为 xz 兼容格式)
run: |
DEB_FILE=$(find dist -maxdepth 1 -type f -name "*.deb" | sort | tail -n 1)
if [ -z "$DEB_FILE" ]; then
echo "No DEB file generated by jpackage" >&2
exit 1
fi
bash build/repack-deb-to-xz.sh "$DEB_FILE"
echo "Repacked package:"
ar t "$DEB_FILE"
- name: Create generic and compatibility ARM64 variants(生成通用 ARM64 和兼容版安装包)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
ORIGINAL_DEB=$(find dist -maxdepth 1 -type f -name "*.deb" | sort | tail -n 1)
if [ -z "$ORIGINAL_DEB" ]; then
echo "No DEB file available for renaming" >&2
exit 1
fi
GENERIC_DEB="dist/EasyPostman-${VERSION}-linux-arm64.deb"
COMPAT_DEB="dist/EasyPostman-${VERSION}-linux-arm64-compat.deb"
mv "$ORIGINAL_DEB" "$GENERIC_DEB"
cp "$GENERIC_DEB" "$COMPAT_DEB"
echo "Generated ARM64 variants:"
ls -1 "$GENERIC_DEB" "$COMPAT_DEB"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with:
name: EasyPostman-Ubuntu-DEB-arm64
path: |
dist/*-linux-arm64.deb
dist/*-linux-arm64-compat.deb
retention-days: 7
build-rpm-amd64:
name: Build RPM amd64(构建 RPM x64 安装包)
runs-on: ubuntu-22.04
needs: [ get-version, build-jar-artifact ]
if: github.event_name != 'release' || startsWith(github.event.release.tag_name || '', 'v')
steps:
- name: Checkout(检出代码)
uses: actions/checkout@v4
- name: Setup Java(配置 Java)
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
check-latest: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Fat JAR(下载跨平台 Fat JAR)
uses: actions/download-artifact@v4
with:
name: app-jar
path: target
- name: Install dependencies(安装系统依赖)
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev binutils rpm
- name: Create runtime with jlink(使用 jlink 创建 Linux 精简 JRE)
run: |
rm -rf target/runtime
jlink \
--add-modules ${{ env.JLINK_MODULES }} \
--strip-debug \
--no-header-files \
--no-man-pages \
--compress=2 \
--output target/runtime
- name: Prepare dist-input(准备打包输入目录)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
rm -rf target/dist-input
mkdir -p target/dist-input
cp target/easy-postman-$VERSION.jar target/dist-input/easy-postman.jar
- name: Create RPM with jpackage(使用 jpackage 创建 RPM 安装包)
run: |
VERSION="${{ needs.get-version.outputs.version }}"
mkdir -p dist
IFS='|' read -ra JAVA_OPTS_COMMON <<< "${{ env.JAVA_OPTIONS_COMMON }}"
IFS='|' read -ra JAVA_OPTS_LINUX <<< "${{ env.JAVA_OPTIONS_LINUX }}"
JPACKAGE_ARGS=(
--input target/dist-input
--main-jar "easy-postman.jar"
--main-class com.laker.postman.App
--runtime-image target/runtime
--type rpm
--name "EasyPostman"
--app-version "$VERSION"
--dest dist
--vendor "Laker"
--copyright "© 2025 Laker"
--description "A modern API testing tool similar to Postman"
--linux-shortcut
--linux-menu-group "Development"
--linux-app-category "Development"
--linux-rpm-license-type "MIT"
)
for opt in "${JAVA_OPTS_COMMON[@]}"; do
JPACKAGE_ARGS+=(--java-options "$opt")
done
for opt in "${JAVA_OPTS_LINUX[@]}"; do
if [ -n "$opt" ]; then
JPACKAGE_ARGS+=(--java-options "$opt")
fi
done
jpackage "${JPACKAGE_ARGS[@]}"
- name: Upload as Artifact(上传为构建产物)
uses: actions/upload-artifact@v4
with: