diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 3f57f43..8bf81ff 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -21,10 +21,10 @@ jobs: - os: windows-latest platform: windows/arm64 artifact_name: npc-gui-windows-arm64 - - os: macos-13 # Intel Mac 运行器 + - os: macos-15 # 使用最新的 macOS 15 Intel 运行器 platform: darwin/amd64 artifact_name: npc-gui-macos-amd64 - - os: macos-latest # Apple M系列运行器 + - os: macos-latest # Apple Silicon (M系列) platform: darwin/arm64 artifact_name: npc-gui-macos-arm64 - os: ubuntu-latest @@ -58,8 +58,12 @@ jobs: - name: Install Linux dependencies if: runner.os == 'Linux' run: | - sudo apt-get update - sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config + # 增加重试机制,防止 apt 锁死或网络抖动 + for i in {1..3}; do + sudo apt-get update && \ + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config && break || \ + (echo "Retry $i..." && sleep 5) + done - name: Enable corepack for Yarn run: corepack enable @@ -81,12 +85,13 @@ jobs: CGO_ENABLED: 1 shell: bash run: | - # 根据平台决定是否添加 -webview2 + # 动态构建参数 FLAGS="-clean -trimpath" - if [[ "${{ matrix.os }}" == *"windows"* ]]; then + if [[ "${{ runner.os }}" == "Windows" ]]; then FLAGS="$FLAGS -webview2 embed" fi + # 执行构建 wails build -platform ${{ matrix.platform }} $FLAGS - name: Package (Windows) @@ -94,8 +99,13 @@ jobs: working-directory: ${{ env.GUI_DIR }} shell: pwsh run: | - $exeName = Get-ChildItem -Path "build/bin/*.exe" | Select-Object -First 1 -ExpandProperty Name - Compress-Archive -Path "build/bin/$exeName" -DestinationPath "build/bin/${{ matrix.artifact_name }}.zip" -Force + $exeFile = Get-ChildItem -Path "build/bin/*.exe" | Select-Object -First 1 + if ($exeFile) { + Compress-Archive -Path $exeFile.FullName -DestinationPath "build/bin/${{ matrix.artifact_name }}.zip" -Force + } else { + Write-Error "No exe found in build/bin" + exit 1 + } - name: Package (macOS/Linux) if: runner.os != 'Windows' @@ -103,12 +113,21 @@ jobs: run: | cd build/bin if [ "${{ runner.os }}" == "macOS" ]; then - # Mac 打包 .app - zip -r "${{ matrix.artifact_name }}.zip" ./*.app + # 打包 Mac 的 .app 目录 + APP_DIR=$(ls -d *.app | head -n 1) + if [ -n "$APP_DIR" ]; then + zip -r "${{ matrix.artifact_name }}.zip" "$APP_DIR" + else + echo "No .app found" && exit 1 + fi else - # Linux 打包二进制 - BINARY_NAME=$(ls -F | grep -v / | head -n 1) - zip "${{ matrix.artifact_name }}.zip" "$BINARY_NAME" + # 打包 Linux 二进制文件 + BINARY_NAME=$(ls -F | grep -v / | head -n 1 | sed 's/\*//') + if [ -n "$BINARY_NAME" ]; then + zip "${{ matrix.artifact_name }}.zip" "$BINARY_NAME" + else + echo "No binary found" && exit 1 + fi fi - name: Upload to GitHub Artifacts