Skip to content

Commit 72c8662

Browse files
feat: 添加Inno Setup打包支持
新增 SRsetup.iss 配置文件用于生成 Windows 安装程序 在 update_version.py 中添加更新安装程序版本号的函数 在 CI 工作流中添加 Inno Setup 打包步骤
1 parent 28d498d commit 72c8662

3 files changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/build-unified.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,31 @@ jobs:
178178
Compress-Archive -Path zip_dist/SecRandom/* -DestinationPath $outputZip -Force
179179
echo "目录模式打包完成: $outputZip"
180180
181+
# Inno Setup 打包
182+
- name: Inno Setup 打包
183+
if: matrix.platform == 'windows'
184+
run: |
185+
echo "开始 Inno Setup 打包..."
186+
187+
# 确保构建输出目录存在
188+
if (!(Test-Path "build")) {
189+
mkdir build
190+
}
191+
192+
# 运行 Inno Setup 编译器
193+
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" SRsetup.iss
194+
195+
# 检查安装程序是否生成并移动到 zip 目录
196+
if (Test-Path "build/SecRandom setup x64.exe") {
197+
# 修改文件名以包含版本号,方便识别
198+
$setupName = "SecRandom-setup-${{ github.ref_name }}-${{ matrix.arch }}.exe"
199+
Move-Item "build/SecRandom setup x64.exe" "zip/$setupName"
200+
echo "Inno Setup 打包完成: zip/$setupName"
201+
} else {
202+
echo "错误:Inno Setup 安装程序未生成"
203+
exit 1
204+
}
205+
181206
# Linux 打包操作
182207
- name: Linux 打包操作
183208
if: matrix.platform == 'linux'

SRsetup.iss

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
; 脚本由 Inno Setup 脚本向导生成。
2+
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
3+
; 仅供非商业使用
4+
5+
#define MyAppName "SecRandom"
6+
#define MyAppVersion "2.2.0"
7+
#define MyAppPublisher "SECTL"
8+
#define MyAppURL "https://secrandom.netlify.app/"
9+
#define MyAppExeName "SecRandom.exe"
10+
11+
[Setup]
12+
; 注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
13+
; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
14+
AppId={{821CBF9D-8984-4F58-84B9-320941EF31CB}
15+
AppName={#MyAppName}
16+
AppVersion={#MyAppVersion}
17+
;AppVerName={#MyAppName} {#MyAppVersion}
18+
AppPublisher={#MyAppPublisher}
19+
AppPublisherURL={#MyAppURL}
20+
AppSupportURL={#MyAppURL}
21+
AppUpdatesURL={#MyAppURL}
22+
DefaultDirName={autopf}\{#MyAppName}
23+
UninstallDisplayIcon={app}\{#MyAppExeName}
24+
; "ArchitecturesAllowed=x64compatible" 指定
25+
; 安装程序只能在 x64 和 Windows 11 on Arm 上运行。
26+
ArchitecturesAllowed=x64compatible
27+
; "ArchitecturesInstallIn64BitMode=x64compatible" 要求
28+
; 在 X64 或 Windows 11 on Arm 上以 "64-位模式" 进行安装,
29+
; 这意味着它应该使用本地 64 位 Program Files 目录
30+
; 和注册表的 64 位视图。
31+
ArchitecturesInstallIn64BitMode=x64compatible
32+
DefaultGroupName={#MyAppName}
33+
AllowNoIcons=yes
34+
; 取消注释以下行以在非管理安装模式下运行 (仅为当前用户安装)。
35+
;PrivilegesRequired=lowest
36+
PrivilegesRequiredOverridesAllowed=dialog
37+
OutputDir=build
38+
OutputBaseFilename=SecRandom setup x64
39+
SetupIconFile=resources\secrandom-icon-paper.ico
40+
SolidCompression=yes
41+
WizardStyle=modern dynamic windows11
42+
43+
[Languages]
44+
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
45+
46+
[Tasks]
47+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
48+
49+
[Files]
50+
Source: "dist\SecRandom\SecRandom.exe"; DestDir: "{app}"; Flags: ignoreversion
51+
Source: "dist\SecRandom\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
52+
; 注意:不要在任何共享系统文件上使用 "Flags: ignoreversion"
53+
54+
[Icons]
55+
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
56+
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
57+
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
58+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
59+
60+
[Run]
61+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
62+

update_version.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@ def update_config_py(version):
6969
f.write(content)
7070

7171

72+
def update_iss_version(stripped_version):
73+
if os.path.exists("SRsetup.iss"):
74+
with open("SRsetup.iss", "r", encoding="utf-8") as f:
75+
content = f.read()
76+
content = re.sub(
77+
r'#define MyAppVersion "[^"]+"',
78+
f'#define MyAppVersion "{stripped_version}"',
79+
content,
80+
)
81+
with open("SRsetup.iss", "w", encoding="utf-8") as f:
82+
f.write(content)
83+
84+
7285
if __name__ == "__main__":
7386
original_version, stripped_version = get_version_from_env()
7487
update_version_info(stripped_version)
7588
update_config_py(original_version)
89+
update_iss_version(stripped_version)

0 commit comments

Comments
 (0)