From d5a65f1004501a1a19c6f72d862e4fc052b392fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E9=94=8B?= Date: Mon, 2 Feb 2026 20:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?Release=20=E5=8F=91=E5=B8=83=E6=97=B6=E7=9A=84=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E5=86=B2=E7=AA=81=E4=B8=8E=E6=97=A5=E5=BF=97=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复了多个 Job 同时 Finalize Release 导致的竞争条件失败问题 - 改用串行发布策略:先并行构建所有平台产物,最后统一汇总发布 - 将 macOS/Windows 打包脚本中的关键日志信息修改为中文 - 确保发布的 Release 默认为 Draft 状态,等待人工确认 --- .github/workflows/release.yml | 65 +++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50ec84e..9aac3cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,8 @@ permissions: contents: write jobs: - build-and-release: + # Phase 1: Build in parallel and output artifacts + build: name: Build ${{ matrix.platform }} runs-on: ${{ matrix.os }} strategy: @@ -19,12 +20,15 @@ jobs: - os: macos-latest platform: darwin/amd64 artifact_name: GoNavi-mac-amd64 + asset_ext: .dmg - os: macos-latest platform: darwin/arm64 artifact_name: GoNavi-mac-arm64 + asset_ext: .dmg - os: windows-latest platform: windows/amd64 artifact_name: GoNavi-windows-amd64 + asset_ext: .exe steps: - name: Checkout code @@ -49,36 +53,26 @@ jobs: run: | wails build -platform ${{ matrix.platform }} -clean -o ${{ matrix.artifact_name }} - - name: Package macOS Application + # macOS Packaging + - name: Package macOS DMG if: contains(matrix.platform, 'darwin') run: | - # Install create-dmg brew install create-dmg - cd build/bin - echo "📂 列出 build/bin 目录内容:" - ls -F - # Find .app bundle APP_PATH=$(find . -maxdepth 1 -name "*.app" | head -n 1) - if [ -z "$APP_PATH" ]; then echo "❌ 未找到 .app 应用包!" exit 1 fi - - # Get pure name (e.g. GoNavi.app) APP_NAME=$(basename "$APP_PATH") - # Ad-hoc codesign to prevent "Damaged" error (requires user to allow anyway, but valid structure) echo "🔏 正在进行 Ad-hoc 签名..." codesign --force --options runtime --deep --sign - "$APP_NAME" DMG_NAME="${{ matrix.artifact_name }}.dmg" - echo "📦 正在生成 DMG: $DMG_NAME..." - # Create DMG create-dmg \ --volname "GoNavi Installer" \ --window-pos 200 120 \ @@ -90,24 +84,19 @@ jobs: "$DMG_NAME" \ "$APP_NAME" - # Move DMG to root for upload - mv "$DMG_NAME" "../../$DMG_NAME" + mv "$DMG_NAME" ../../ - - name: Package Windows Executable + # Windows Packaging + - name: Prepare Windows Exe if: contains(matrix.platform, 'windows') shell: bash run: | cd build/bin - echo "📂 列出 build/bin 目录内容:" - ls -F - TARGET="${{ matrix.artifact_name }}" if [ -f "$TARGET.exe" ]; then - echo "✅ 找到 $TARGET.exe" FINAL_EXE="$TARGET.exe" elif [ -f "$TARGET" ]; then - echo "⚠️ 找到无后缀文件 $TARGET,正在添加 .exe 后缀..." mv "$TARGET" "$TARGET.exe" FINAL_EXE="$TARGET.exe" else @@ -116,12 +105,38 @@ jobs: fi echo "📦 正在移动 $FINAL_EXE 到根目录..." - mv "$FINAL_EXE" "../../${{ matrix.artifact_name }}.exe" + mv "$FINAL_EXE" "../../$FINAL_EXE" - - name: Upload Release Asset + # Upload to Actions Artifacts (Temporary Storage) + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ strategy.job-index }} # Unique name per job + path: GoNavi-*${{ matrix.asset_ext }} + retention-days: 1 + + # Phase 2: Collect all artifacts and Publish Release (Single Job) + release: + name: Publish Release + needs: build + runs-on: ubuntu-latest + steps: + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + path: release-assets + pattern: build-artifacts-* + merge-multiple: true + + - name: List Assets + run: ls -R release-assets + + - name: Create Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: ${{ matrix.artifact_name }}* + files: release-assets/* + draft: true + make_latest: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}