From 532a0fd8b6658d7d7017e70926e318298b027e47 Mon Sep 17 00:00:00 2001 From: vancur2021 Date: Tue, 16 Dec 2025 05:17:00 +0800 Subject: [PATCH 1/3] Update build-release.yml --- .github/workflows/build-release.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c891d06..d3bc0d6 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -108,11 +108,11 @@ jobs: runs-on: macos-latest steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v4 # 建议用 v4 - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v5 # 建议用 v5 with: - python-version: '3.14' + python-version: '3.12' # 建议用稳定版 - name: Install dependencies run: | python -m venv .venv @@ -122,12 +122,20 @@ jobs: pip install -r requirements.txt - name: Build app with PyInstaller run: | - .venv/bin/pyinstaller ./tchMaterial-parser.spec + # 显式指定生成单文件 + .venv/bin/pyinstaller --clean --onefile ./tchMaterial-parser.spec + + - name: Sign binary + run: | + # 修复 macOS ARM64 无法运行的问题 + codesign --force --deep --sign - dist/tchMaterial-parser + - name: Create zip archive run: | cd dist - mv tchMaterial-parser tchMaterial-parser-mac-arm64.app - zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64.app + mv tchMaterial-parser tchMaterial-parser-mac-arm64 + chmod +x tchMaterial-parser-mac-arm64 + zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64 - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: From dd7ba5c4a8595008625e606608bb463796f8a622 Mon Sep 17 00:00:00 2001 From: vancur2021 Date: Tue, 16 Dec 2025 05:22:14 +0800 Subject: [PATCH 2/3] Update build-release.yml --- .github/workflows/build-release.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index d3bc0d6..3f85701 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -108,11 +108,11 @@ jobs: runs-on: macos-latest steps: - name: Checkout code - uses: actions/checkout@v4 # 建议用 v4 + uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 # 建议用 v5 + uses: actions/setup-python@v6 with: - python-version: '3.12' # 建议用稳定版 + python-version: '3.12' # 建议改用 3.12 稳定版,3.14 太新可能导致其他问题 - name: Install dependencies run: | python -m venv .venv @@ -120,22 +120,32 @@ jobs: python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt + - name: Build app with PyInstaller run: | - # 显式指定生成单文件 - .venv/bin/pyinstaller --clean --onefile ./tchMaterial-parser.spec - - - name: Sign binary + # 1. 去掉 --onefile,因为 .spec 文件里已经包含配置了 + # 2. 加上 --clean 清理缓存 + .venv/bin/pyinstaller --clean ./tchMaterial-parser.spec + + - name: Sign the binary run: | - # 修复 macOS ARM64 无法运行的问题 + # 【关键步骤】对生成的二进制文件进行 Ad-hoc 签名 + # 假设 spec 文件生成的默认名字是 tchMaterial-parser codesign --force --deep --sign - dist/tchMaterial-parser - name: Create zip archive run: | cd dist + # 【关键步骤】不要重命名为 .app! + # 直接改名为更有辨识度的名字(无后缀,或者加 .command) mv tchMaterial-parser tchMaterial-parser-mac-arm64 + + # 赋予可执行权限 chmod +x tchMaterial-parser-mac-arm64 + + # 压缩 zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64 + - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: From 3fe75e87b720189cf5d7c52d114b3ba94ec86eaa Mon Sep 17 00:00:00 2001 From: vancur2021 Date: Tue, 16 Dec 2025 05:32:22 +0800 Subject: [PATCH 3/3] Update build-release.yml --- .github/workflows/build-release.yml | 33 ++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3f85701..3434b0e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -109,10 +109,12 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v5 + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.12' # 建议改用 3.12 稳定版,3.14 太新可能导致其他问题 + python-version: '3.12' # 推荐使用 3.12 稳定版 + - name: Install dependencies run: | python -m venv .venv @@ -123,27 +125,37 @@ jobs: - name: Build app with PyInstaller run: | - # 1. 去掉 --onefile,因为 .spec 文件里已经包含配置了 - # 2. 加上 --clean 清理缓存 - .venv/bin/pyinstaller --clean ./tchMaterial-parser.spec + # 激活虚拟环境 + source .venv/bin/activate + + # 执行打包命令 + # --clean: 清理缓存 + # --onefile: 强制生成单文件 + # --name: 指定输出文件名 + # --add-data: 打包资源文件 (格式为 源路径:目标路径) + # src/tchMaterial-parser.pyw: 你的入口脚本 + + pyinstaller --clean --onefile --name tchMaterial-parser \ + --add-data "res:res" \ + --add-data "version.txt:." \ + src/tchMaterial-parser.pyw - name: Sign the binary run: | - # 【关键步骤】对生成的二进制文件进行 Ad-hoc 签名 - # 假设 spec 文件生成的默认名字是 tchMaterial-parser + # 对生成的单文件进行 Ad-hoc 签名 + # 这一步是解决“文件已损坏”的核心 codesign --force --deep --sign - dist/tchMaterial-parser - name: Create zip archive run: | cd dist - # 【关键步骤】不要重命名为 .app! - # 直接改名为更有辨识度的名字(无后缀,或者加 .command) + # 改名为带架构后缀的文件名 mv tchMaterial-parser tchMaterial-parser-mac-arm64 - # 赋予可执行权限 + # 赋予可执行权限(双重保险) chmod +x tchMaterial-parser-mac-arm64 - # 压缩 + # 压缩为 zip zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64 - name: Upload Release Asset @@ -153,3 +165,4 @@ jobs: tag_name: ${{ inputs.tag || github.ref_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +