Skip to content

Commit 129e816

Browse files
committed
修复构建错误 打包 pi win
1 parent e04fbc4 commit 129e816

3 files changed

Lines changed: 50 additions & 114 deletions

File tree

.github/workflows/build-unified.yml

Lines changed: 34 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ on:
2525
- all
2626
- windows
2727
- linux
28-
packager:
29-
description: '打包工具 (pyinstaller/nuitka/both)'
30-
required: false
31-
default: 'pyinstaller'
32-
type: choice
33-
options:
34-
- pyinstaller
35-
- nuitka
36-
- both
3728
release:
3829
description: '是否发布版本'
3930
required: false
@@ -62,8 +53,6 @@ jobs:
6253
github.event_name == 'workflow_dispatch' ||
6354
contains(github.event.head_commit.message, '打包') ||
6455
contains(github.event.head_commit.message, 'pi') ||
65-
contains(github.event.head_commit.message, 'nk') ||
66-
contains(github.event.head_commit.message, 'both') ||
6756
contains(github.event.head_commit.message, 'all') ||
6857
contains(github.event.head_commit.message, 'win') ||
6958
contains(github.event.head_commit.message, 'linux') ||
@@ -84,13 +73,7 @@ jobs:
8473
pack_mode: dir
8574
packager: pyinstaller
8675
platform: windows
87-
# Windows Nuitka 构建
88-
- os: windows-2022
89-
arch: x64
90-
pack_mode: dir
91-
packager: nuitka
92-
platform: windows
93-
# Linux 构建
76+
# Linux PyInstaller 构建
9477
- os: ubuntu-22.04
9578
arch: x64
9679
pack_mode: dir
@@ -113,6 +96,7 @@ jobs:
11396
echo "- 平台: ${{ matrix.platform }}"
11497
echo "- 架构: ${{ matrix.arch }}"
11598
echo "- 打包工具: ${{ matrix.packager }}"
99+
echo "- 打包模式: ${{ matrix.pack_mode }}"
116100
echo "- 事件类型: ${{ github.event_name }}"
117101
echo "- Ref: ${{ github.ref }}"
118102
echo "- Commit: ${{ github.sha }}"
@@ -186,15 +170,12 @@ jobs:
186170
# Windows PyInstaller 构建
187171
- name: 运行 Windows PyInstaller 构建
188172
if: |
189-
matrix.platform == 'windows' &&
190-
matrix.packager == 'pyinstaller' &&
191-
(github.event_name != 'workflow_dispatch' ||
192-
(inputs.build_target == 'all' || inputs.build_target == 'windows') &&
193-
(inputs.packager == 'pyinstaller' || inputs.packager == 'both')) &&
194-
(github.event_name == 'workflow_dispatch' ||
173+
matrix.platform == 'windows' &&
174+
(github.event_name != 'workflow_dispatch' ||
175+
(inputs.build_target == 'all' || inputs.build_target == 'windows')) &&
176+
(github.event_name == 'workflow_dispatch' ||
195177
(contains(github.event.head_commit.message, '打包') ||
196178
contains(github.event.head_commit.message, 'pi') ||
197-
contains(github.event.head_commit.message, 'both') ||
198179
contains(github.event.head_commit.message, 'all') ||
199180
contains(github.event.head_commit.message, 'win'))) &&
200181
(github.event_name != 'push' ||
@@ -207,49 +188,43 @@ jobs:
207188
echo "依赖同步完成,开始打包..."
208189
uv run build_pyinstaller.py
209190
210-
# Windows Nuitka 构建
211-
- name: 运行 Windows Nuitka 构建
191+
# Windows PyInstaller 构建
192+
- name: 运行 Windows PyInstaller 构建
212193
if: |
213-
matrix.platform == 'windows' &&
214-
matrix.packager == 'nuitka' &&
215-
(github.event_name != 'workflow_dispatch' ||
216-
(inputs.build_target == 'all' || inputs.build_target == 'windows') &&
217-
(inputs.packager == 'nuitka' || inputs.packager == 'both')) &&
218-
(github.event_name == 'workflow_dispatch' ||
194+
matrix.platform == 'windows' &&
195+
(github.event_name != 'workflow_dispatch' ||
196+
(inputs.build_target == 'all' || inputs.build_target == 'windows')) &&
197+
(github.event_name == 'workflow_dispatch' ||
219198
(contains(github.event.head_commit.message, '打包') ||
220-
contains(github.event.head_commit.message, 'nk') ||
221-
contains(github.event.head_commit.message, 'both') ||
199+
contains(github.event.head_commit.message, 'pi') ||
222200
contains(github.event.head_commit.message, 'all') ||
223201
contains(github.event.head_commit.message, 'win'))) &&
224202
(github.event_name != 'push' ||
225203
!startsWith(github.ref, 'refs/tags/v') ||
226204
(startsWith(github.ref_name, 'v') && contains(github.ref_name, '.') && !contains(github.ref_name, '-')))
227205
run: |
228-
echo "开始 Windows Nuitka 构建流程..."
206+
echo "开始 Windows PyInstaller 构建流程..."
229207
echo "使用uv进行依赖同步..."
230208
uv sync --frozen
231209
echo "依赖同步完成,开始打包..."
232-
uv run build_nuitka.py
210+
uv run build_pyinstaller.py
233211
234-
# Linux 构建
235-
- name: 运行 Linux 构建
212+
# Linux PyInstaller 构建
213+
- name: 运行 Linux PyInstaller 构建
236214
if: |
237-
matrix.platform == 'linux' &&
238-
matrix.packager == 'pyinstaller' &&
239-
(github.event_name != 'workflow_dispatch' ||
240-
(inputs.build_target == 'all' || inputs.build_target == 'linux') &&
241-
(inputs.packager == 'pyinstaller' || inputs.packager == 'both')) &&
242-
(github.event_name == 'workflow_dispatch' ||
215+
matrix.platform == 'linux' &&
216+
(github.event_name != 'workflow_dispatch' ||
217+
(inputs.build_target == 'all' || inputs.build_target == 'linux')) &&
218+
(github.event_name == 'workflow_dispatch' ||
243219
(contains(github.event.head_commit.message, '打包') ||
244220
contains(github.event.head_commit.message, 'pi') ||
245-
contains(github.event.head_commit.message, 'both') ||
246221
contains(github.event.head_commit.message, 'all') ||
247222
contains(github.event.head_commit.message, 'linux'))) &&
248223
(github.event_name != 'push' ||
249224
!startsWith(github.ref, 'refs/tags/v') ||
250225
(startsWith(github.ref_name, 'v') && contains(github.ref_name, '.') && !contains(github.ref_name, '-')))
251226
run: |
252-
echo "开始 Linux 构建流程..."
227+
echo "开始 Linux PyInstaller 构建流程..."
253228
echo "使用uv进行依赖同步..."
254229
uv sync --frozen
255230
echo "依赖同步完成,开始打包..."
@@ -264,7 +239,7 @@ jobs:
264239
echo "开始 Windows 打包操作..."
265240
266241
# 检查构建是否成功
267-
if (!(Test-Path "dist/SecRandom")) {
242+
if (!(Test-Path "dist/SecRandom" -PathType Container)) {
268243
echo "错误:dist/SecRandom 目录不存在,构建可能失败了"
269244
echo "可用的dist目录内容:"
270245
if (Test-Path "dist") {
@@ -278,7 +253,7 @@ jobs:
278253
# 创建zip_dist/SecRandom目录
279254
mkdir -p zip_dist/SecRandom
280255
281-
# 复制dist/SecRandom目录下的所有文件到zip_dist/SecRandom目录下
256+
# 复制dist/SecRandom目录内容
282257
Copy-Item -Recurse -Force dist/SecRandom/* zip_dist/SecRandom/
283258
284259
# 创建app目录
@@ -292,11 +267,7 @@ jobs:
292267
293268
# 使用 zip 压缩文件
294269
mkdir zip -Force
295-
if ("${{ matrix.packager }}" -eq "nuitka") {
296-
$outputZip = "zip/SecRandom-Windows-Nuitka-${{ github.ref_name }}-${{ matrix.arch }}-dir.zip"
297-
} else {
298-
$outputZip = "zip/SecRandom-Windows-PyInstaller-${{ github.ref_name }}-${{ matrix.arch }}-dir.zip"
299-
}
270+
$outputZip = "zip/SecRandom-Windows-${{ github.ref_name }}-${{ matrix.arch }}-dir.zip"
300271
Compress-Archive -Path zip_dist/SecRandom/* -DestinationPath $outputZip -Force
301272
echo "目录模式打包完成: $outputZip"
302273
@@ -323,7 +294,7 @@ jobs:
323294
# 创建zip_dist/SecRandom目录
324295
mkdir -p zip_dist/SecRandom
325296
326-
# 复制dist/SecRandom目录下的所有文件到zip_dist/SecRandom目录下
297+
# 复制dist/SecRandom目录内容
327298
cp -r dist/SecRandom/* zip_dist/SecRandom/
328299
329300
# 创建app目录
@@ -348,7 +319,7 @@ jobs:
348319
(github.event_name != 'workflow_dispatch' || inputs.package == 'true')
349320
uses: actions/upload-artifact@v4.4.2
350321
with:
351-
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.pack_mode }}-${{ matrix.packager }}
322+
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.pack_mode }}
352323
path: ./zip
353324
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
354325

@@ -407,8 +378,6 @@ jobs:
407378
# Windows 构建产物
408379
mv artifacts/windows-2022-x64-dir-pyinstaller/* release/ 2>/dev/null || echo "未找到 Windows x64 PyInstaller 构建产物"
409380
mv artifacts/windows-2022-x86-dir-pyinstaller/* release/ 2>/dev/null || echo "未找到 Windows x86 PyInstaller 构建产物"
410-
mv artifacts/windows-2022-x64-dir-nuitka/* release/ 2>/dev/null || echo "未找到 Windows x64 Nuitka 构建产物"
411-
mv artifacts/windows-2022-x86-dir-nuitka/* release/ 2>/dev/null || echo "未找到 Windows x86 Nuitka 构建产物"
412381
# Linux 构建产物
413382
mv artifacts/ubuntu-22.04-x64-dir-pyinstaller/* release/ 2>/dev/null || echo "未找到 Linux x64 构建产物"
414383
echo "构建产物整理完成"
@@ -456,18 +425,14 @@ jobs:
456425
echo "| Linux | x64 | [下载](https://www.123684.com/s/9529jv-U4Fxh) |" >> ../CHANGELOG.md
457426
echo "" >> ../CHANGELOG.md
458427
echo "**Github 镜像 下载链接**" >> ../CHANGELOG.md
459-
echo "| 镜像源 | 平台/打包方式 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
428+
echo "| 镜像源 | 平台 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
460429
echo "| --- | --- | --- | --- |" >> ../CHANGELOG.md
461-
echo "| ghfast.top | Windows 目录模式 (PyInstaller) | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-PyInstaller-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
462-
echo "| ghfast.top | Windows 目录模式 (PyInstaller) | x86 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-PyInstaller-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
463-
echo "| ghfast.top | Windows 目录模式 (Nuitka) | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-Nuitka-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
464-
echo "| ghfast.top | Windows 目录模式 (Nuitka) | x86 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-Nuitka-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
465-
echo "| ghfast.top | Linux 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Linux-${{ github.ref_name }}-x64-dir.tar.gz) |" >> ../CHANGELOG.md
466-
echo "| gh-proxy.com | Windows 目录模式 (PyInstaller) | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-PyInstaller-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
467-
echo "| gh-proxy.com | Windows 目录模式 (PyInstaller) | x86 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-PyInstaller-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
468-
echo "| gh-proxy.com | Windows 目录模式 (Nuitka) | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-Nuitka-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
469-
echo "| gh-proxy.com | Windows 目录模式 (Nuitka) | x86 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-Nuitka-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
470-
echo "| gh-proxy.com | Linux 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Linux-${{ github.ref_name }}-x64-dir.tar.gz) |" >> ../CHANGELOG.md
430+
echo "| ghfast.top | Windows | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
431+
echo "| ghfast.top | Windows | x86 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
432+
echo "| ghfast.top | Linux | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Linux-${{ github.ref_name }}-x64-dir.tar.gz) |" >> ../CHANGELOG.md
433+
echo "| gh-proxy.com | Windows | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
434+
echo "| gh-proxy.com | Windows | x86 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
435+
echo "| gh-proxy.com | Linux | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Linux-${{ github.ref_name }}-x64-dir.tar.gz) |" >> ../CHANGELOG.md
471436
echo "" >> ../CHANGELOG.md
472437
echo "**SHA256 校验值-请核对下载的文件的SHA256值是否正确**" >> ../CHANGELOG.md
473438
echo "| 文件名 | SHA256 值 |" >> ../CHANGELOG.md

README.md

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,13 @@ SecRandom 项目使用统一的 GitHub Actions 工作流进行构建和发布,
220220
- 在 commit 消息中包含 `打包` 关键词
221221
- 例如:`git commit -m "新增功能 打包"`
222222

223-
2. **指定打包工具**
224-
- `pi` - PyInstaller 简称
225-
- `nk` - Nuitka 简称
226-
- `both` - 两种打包工具同时使用
227-
- 例如:`git commit -m "优化性能 打包 pi"`
228-
229-
3. **指定构建平台**
223+
2. **指定构建平台**
230224
- `win` - Windows 平台
231225
- `linux` - Linux 平台
232226
- `all` - 所有平台
233227
- 例如:`git commit -m "修复bug 打包 linux"`
234228

235-
4. **触发所有平台构建**
229+
3. **触发所有平台构建**
236230
- 创建符合版本号规范的 tag(格式:`v数字.数字.数字.数字`
237231
- 例如:`git tag v1.2.3.4 && git push origin v1.2.3.4`
238232

@@ -243,47 +237,12 @@ SecRandom 项目使用统一的 GitHub Actions 工作流进行构建和发布,
243237
| 关键词 | 含义 | 示例 |
244238
|--------|------|------|
245239
| `打包` | 通用打包触发 | `git commit -m "新增功能 打包"` |
246-
| `pi` | PyInstaller 打包 | `git commit -m "优化性能 打包 pi"` |
247-
| `nk` | Nuitka 打包 | `git commit -m "修复bug 打包 nk"` |
248-
| `both` | 两种工具同时打包 | `git commit -m "新功能 打包 both"` |
249240
| `win` | Windows 平台 | `git commit -m "修复UI 打包 win"` |
250241
| `linux` | Linux 平台 | `git commit -m "优化性能 打包 linux"` |
251242
| `all` | 所有平台 | `git commit -m "大更新 打包 all"` |
252243

253244
**组合使用示例:**
254-
- `git commit -m "优化性能 打包 pi win"` - 使用 PyInstaller 构建 Windows 平台
255-
- `git commit -m "修复bug 打包 pi linux"` - 使用 PyInstaller 构建 Linux 平台(Linux 暂不支持 Nuitka)
256-
- `git commit -m "新功能 打包 both all"` - 同时使用两种工具构建所有平台(Windows 用两种工具,Linux 仅用 PyInstaller)
257-
258-
#### 自动触发工作流
259-
260-
- **Push 到主分支**:推送到 `master` 分支会自动触发构建
261-
- **创建 Tag**:创建符合 `v*.*.*.*` 格式的 tag 会自动触发构建和发布流程
262-
- **Pull Request**:向主分支发起 PR 时会自动触发构建验证
263-
- **注意**:Linux 平台目前仅支持 PyInstaller 打包,如需 Nuitka 支持请提交 Issue
264-
265-
#### 版本号规范
266-
267-
发布版本必须严格符合以下格式:
268-
- **格式**`v主版本号.次版本号.修订号.构建号`(四个数字段,每段1位或多位数字)
269-
- **正则验证**`^v\d+\.\d+\.\d+\.\d+$`
270-
- **示例**`v1.2.3.4``v2.0.0.1``v10.20.30.40`
271-
- **要求**
272-
- 必须以字母 `v` 开头
273-
- 使用点号 `.` 分隔四个数字段
274-
- 每个数字段可以包含一个或多个数字(0-9)
275-
- 不允许有前导零(如 `v01.2.3.4` 不符合规范)
276-
- **不符合规范的 tag 不会触发发布流程**,请严格按照格式创建版本标签
277-
278-
#### 工作流特性
279-
280-
- **跨平台构建**:支持 Windows (x86/x64) 和 Linux (x64)
281-
- **双打包工具**:Windows 支持 PyInstaller 和 Nuitka 两种打包方式,Linux 目前仅支持 PyInstaller
282-
- **正则验证**:使用正则表达式 `^v\d+\.\d+\.\d+\.\d+$` 严格验证版本号格式
283-
- **灵活配置**:可通过参数控制构建目标、打包工具和发布行为
284-
- **自动发布**:支持自动发布到 GitHub Releases 并生成 CHANGELOG
285-
- **产物归档**:构建产物会自动上传为 Artifacts 供下载
286-
- **依赖管理**:使用 uv 工具进行高效的依赖管理和打包
287-
- **缓存优化**:智能缓存依赖,加快构建速度
245+
- `git commit -m "优化性能 打包 pi"` - 使用 PyInstaller 构建 Windows 平台
246+
- `git commit -m "修复bug 打包 pi"` - 使用 PyInstaller 构建 Linux 平台
288247

289248
**Copyright © 2025 SECTL**

Secrandom.spec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,15 @@ exe = EXE(
6868
codesign_identity=None,
6969
entitlements_file=None,
7070
)
71+
72+
# 创建目录模式输出
73+
coll = COLLECT(
74+
exe,
75+
a.binaries,
76+
a.zipfiles,
77+
a.datas,
78+
strip=False,
79+
upx=True,
80+
upx_exclude=[],
81+
name="SecRandom",
82+
)

0 commit comments

Comments
 (0)