@@ -33,15 +33,19 @@ jobs:
3333 arch : arm64
3434 python : python3.10
3535 asr : funasr-onnx
36- artifact_path : |
37- desktop/release/*.dmg
36+ python_env_exe : python-env/bin/python3
37+ build_script : build:mac
38+ debug : " "
39+ artifact_glob : desktop/release/*.dmg
3840 - os : windows-latest
3941 platform : win
4042 arch : x64
4143 python : python
4244 asr : funasr-onnx
43- artifact_path : |
44- desktop/release/*.exe
45+ python_env_exe : python-env/Scripts/python.exe
46+ build_script : build:win
47+ debug : electron-builder
48+ artifact_glob : desktop/release/*.exe
4549
4650 defaults :
4751 run :
@@ -72,13 +76,64 @@ jobs:
7276 with :
7377 python-version : ' 3.10'
7478
79+ # Windows: 安装 Visual Studio Build Tools(用于编译 native 模块)
80+ - name : Setup MSVC Build Tools (Windows only)
81+ if : matrix.platform == 'win'
82+ uses : microsoft/setup-msbuild@v2
83+
7584 - name : Install dependencies
7685 run : pnpm install --frozen-lockfile
7786
87+ # Windows: 确保 app-builder.exe 存在且可执行
88+ - name : Verify and fix app-builder (Windows only)
89+ if : matrix.platform == 'win'
90+ shell : pwsh
91+ run : |
92+ # 查找 app-builder.exe
93+ $appBuilder = Get-ChildItem -Path "node_modules" -Recurse -Filter "app-builder.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
94+
95+ if ($appBuilder) {
96+ Write-Host "Found app-builder.exe at: $($appBuilder.FullName)"
97+ Write-Host "File size: $($appBuilder.Length) bytes"
98+
99+ # 验证文件是否为有效的 PE 文件
100+ $bytes = [System.IO.File]::ReadAllBytes($appBuilder.FullName)
101+ if ($bytes[0] -eq 0x4D -and $bytes[1] -eq 0x5A) {
102+ Write-Host "✓ Valid PE executable"
103+ } else {
104+ Write-Warning "File may be corrupted, reinstalling..."
105+ Remove-Item -Recurse -Force "node_modules/app-builder-bin" -ErrorAction SilentlyContinue
106+ Remove-Item -Recurse -Force "node_modules/.pnpm/app-builder-bin*" -ErrorAction SilentlyContinue
107+ pnpm install --frozen-lockfile
108+ }
109+ } else {
110+ Write-Warning "app-builder.exe not found, attempting reinstall..."
111+ pnpm install --frozen-lockfile
112+ }
113+
114+ # 再次验证
115+ $appBuilder = Get-ChildItem -Path "node_modules" -Recurse -Filter "app-builder.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
116+ if (-not $appBuilder) {
117+ Write-Error "app-builder.exe still not found after reinstall!"
118+ exit 1
119+ }
120+
78121 - name : Prepare Python env for ASR backend
79- working-directory : desktop
80122 run : pnpm run prepare:python
81123
124+ # 验证 Python 环境和 PyInstaller
125+ - name : Verify Python environment
126+ run : |
127+ PYTHON_PATH="${{ format('{0}/desktop/{1}', github.workspace, matrix.python_env_exe) }}"
128+ echo "Python path: $PYTHON_PATH"
129+ "$PYTHON_PATH" --version
130+ # 注意:在 bash -o pipefail 下,`pip list | head -30` 会因为 head 提前关闭 stdout 触发 BrokenPipe(exit 120),从而让 CI 失败。
131+ # 这里用 sed 打印前 30 行但不提前关闭管道,避免 BrokenPipe。
132+ "$PYTHON_PATH" -m pip list | sed -n '1,30p'
133+ "$PYTHON_PATH" -c "import PyInstaller; print('PyInstaller OK')" || echo "PyInstaller import check failed"
134+ echo "Checking for PyInstaller module..."
135+ "$PYTHON_PATH" -m PyInstaller --version || true
136+
82137 - name : Print app version
83138 id : meta
84139 run : |
@@ -89,19 +144,32 @@ jobs:
89144 env :
90145 PYTHON : ${{ matrix.python }}
91146 ASR_IMPL : ${{ matrix.asr }}
92- ASR_PYTHON_PATH : ${{ matrix.platform == 'win' && format('{0}/desktop/python-env/Scripts/python.exe', github.workspace) || format('{0}/desktop/python-env/bin/python3', github.workspace) }}
147+ ASR_PYTHON_PATH : ${{ format('{0}/desktop/{1}', github.workspace, matrix.python_env_exe) }}
148+ DEBUG : ${{ matrix.debug }}
149+ run : |
150+ echo "=== Build Environment ==="
151+ echo "Platform: ${{ matrix.platform }}"
152+ echo "Arch: ${{ matrix.arch }}"
153+ echo "ASR_PYTHON_PATH: $ASR_PYTHON_PATH"
154+ echo "========================="
155+
156+ pnpm run ${{ matrix.build_script }} -- --${{ matrix.arch }}
157+
158+ # Windows: 列出构建产物帮助调试
159+ - name : List build artifacts
160+ if : always()
93161 run : |
94- if [ "${{ matrix.platform }}" = "mac" ]; then
95- pnpm run build:mac -- --${{ matrix.arch }}
96- else
97- pnpm run build:win -- --${{ matrix.arch }}
98- fi
162+ echo "=== Release directory contents ==="
163+ ls -la release/ || echo "release/ not found"
164+ echo "=== Backend dist contents ==="
165+ ls -la backend/dist/ || echo "backend/dist/ not found"
166+ ls -la backend/dist/asr-backend/ 2>/dev/null | sed -n '1,20p' || echo "asr-backend dir not found"
99167
100168 - name : Upload artifacts
101169 uses : actions/upload-artifact@v4
102170 with :
103171 name : livegalgame-desktop-${{ matrix.platform }}-${{ matrix.arch }}-v${{ steps.meta.outputs.app_version }}
104- path : ${{ matrix.artifact_path }}
172+ path : ${{ matrix.artifact_glob }}
105173 if-no-files-found : error
106174 retention-days : 14
107175
0 commit comments