fix(win): improve version detection and asset provisioning for windows #19
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| jobs: | |
| build-tauri: | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: "macos-latest" | |
| args: "--target aarch64-apple-darwin" | |
| - platform: "macos-latest" | |
| args: "--target x86_64-apple-darwin" | |
| - platform: "macos-latest" | |
| args: "--target universal-apple-darwin" | |
| - platform: "ubuntu-22.04" | |
| args: "" | |
| - platform: "ubuntu-24.04-arm" | |
| args: "" | |
| - platform: "windows-latest" | |
| args: "" | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies (Linux) | |
| if: startsWith(matrix.platform, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf pkg-config libsoup-3.0-dev javascriptcoregtk-4.1 libjavascriptcoregtk-4.1-dev | |
| sudo apt-get install -y libnm-dev xdg-utils | |
| - name: Rust setup | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || (contains(matrix.args, 'aarch64') && 'aarch64-unknown-linux-gnu' || '') }} | |
| - name: Node.js setup | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| cache-dependency-path: apps/web-dashboard/package-lock.json | |
| - name: Install Frontend Dependencies | |
| run: | | |
| cd apps/web-dashboard | |
| npm install | |
| - name: Build Tauri App | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | |
| CI: true | |
| MACOSX_DEPLOYMENT_TARGET: "10.13" | |
| with: | |
| projectPath: apps/desktop | |
| tauriScript: npx @tauri-apps/cli@2 | |
| args: ${{ matrix.args }} | |
| - name: Rename and Prepare Artifacts | |
| shell: bash | |
| run: | | |
| # 建立更健壮的架构识别机制 | |
| if [[ "${{ matrix.args }}" == *"--target aarch64"* ]]; then | |
| ARCH="aarch64" | |
| elif [[ "${{ matrix.args }}" == *"--target x86_64"* ]]; then | |
| ARCH="x64" | |
| elif [[ "${{ matrix.args }}" == *"--target universal"* ]]; then | |
| ARCH="universal" | |
| elif [[ "${{ matrix.platform }}" == *"arm"* ]]; then | |
| ARCH="aarch64" | |
| elif [[ "${{ matrix.platform }}" == *"ubuntu"* ]]; then | |
| ARCH="amd64" | |
| elif [[ "${{ matrix.platform }}" == *"windows"* ]]; then | |
| ARCH="x64" | |
| else | |
| ARCH="unknown" | |
| fi | |
| echo "Processing artifacts for ARCH: $ARCH on ${{ matrix.platform }}" | |
| mkdir -p artifacts-out | |
| VER_CLEAN=${{ github.ref_name }} | |
| VER_CLEAN=${VER_CLEAN#v} | |
| # 1. macOS 处理 (DMG + Updater Tarball) | |
| # 尝试多个可能的 Tauri v2 路径 (适配 universal 与单架构) | |
| find target -name "*.dmg" -exec cp {} artifacts-out/Antigravity.Tools_${VER_CLEAN}_${ARCH}.dmg \; 2>/dev/null || true | |
| find target -name "*.app.tar.gz" -exec cp {} artifacts-out/Antigravity.Tools_${ARCH}.app.tar.gz \; 2>/dev/null || true | |
| find target -name "*.app.tar.gz.sig" -exec cp {} artifacts-out/Antigravity.Tools_${ARCH}.app.tar.gz.sig \; 2>/dev/null || true | |
| # 2. Windows 处理 (NSIS Setup + Portable EXE) | |
| if [[ "${{ matrix.platform }}" == *"windows"* ]]; then | |
| # NSIS 安装包 | |
| find target -name "*setup.exe" -exec cp {} artifacts-out/Antigravity.Tools_${VER_CLEAN}_x64-setup.exe \; 2>/dev/null || true | |
| # Portable 单文件 (直接拷贝编译出的二进制) | |
| cp target/release/antigravity_tools_ls.exe artifacts-out/Antigravity.Tools_${VER_CLEAN}_x64_portable.exe 2>/dev/null || true | |
| fi | |
| # 3. Linux 处理 (AppImage + Signatures) | |
| if [[ "${{ matrix.platform }}" == *"ubuntu"* ]]; then | |
| find target -name "*.AppImage" -exec cp {} artifacts-out/Antigravity.Tools_${VER_CLEAN}_${ARCH}.AppImage \; 2>/dev/null || true | |
| find target -name "*.AppImage.sig" -exec cp {} artifacts-out/Antigravity.Tools_${VER_CLEAN}_${ARCH}.AppImage.sig \; 2>/dev/null || true | |
| fi | |
| echo "Contents of artifacts-out:" | |
| ls -R artifacts-out/ | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-assets-${{ matrix.platform }}-${{ strategy.job-index }} | |
| path: artifacts-out/* | |
| if-no-files-found: error | |
| publish-release: | |
| needs: build-tauri | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # 下载所有构建产物 (仅限 release 相关的 assets 和 updater) | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: all-artifacts | |
| pattern: "{release-assets-*,updater-json-*}" | |
| merge-multiple: true | |
| - name: Extract Release Notes | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| echo "Extracting release notes for version $VERSION" | |
| # Extract English Notes | |
| awk -v ver="$VERSION" ' | |
| BEGIN { capture=0 } | |
| $0 ~ "^### " ver { capture=1; next } | |
| capture && $0 ~ "^### v" { capture=0; exit } | |
| capture { print } | |
| ' README.md > release_notes_en.md | |
| # Extract Chinese Notes | |
| awk -v ver="$VERSION" ' | |
| BEGIN { capture=0 } | |
| $0 ~ "^### " ver { capture=1; next } | |
| capture && $0 ~ "^### v" { capture=0; exit } | |
| capture { print } | |
| ' README_ZH.md > release_notes_zh.md | |
| if [ -s release_notes_en.md ] || [ -s release_notes_zh.md ]; then | |
| echo "## English Changelog" > release_notes.md | |
| cat release_notes_en.md >> release_notes.md | |
| echo "" >> release_notes.md | |
| echo "## 中文更新日志" >> release_notes.md | |
| cat release_notes_zh.md >> release_notes.md | |
| else | |
| echo "See the assets to download this version and install." > release_notes.md | |
| fi | |
| - name: Build updater.json from signatures | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| DOWNLOAD_BASE="https://github.com/${REPO}/releases/download/${VERSION}" | |
| VER="${VERSION#v}" | |
| # Helper: read signature content from .sig file in artifacts | |
| read_sig() { | |
| local pattern="$1" | |
| local sig_file | |
| sig_file=$(find all-artifacts -name "$pattern" -type f 2>/dev/null | head -1) | |
| if [ -n "$sig_file" ] && [ -f "$sig_file" ]; then | |
| cat "$sig_file" | |
| else | |
| echo "" | |
| fi | |
| } | |
| # Read signatures for each platform | |
| MACOS_UNI_SIG=$(read_sig "*_universal.app.tar.gz.sig") | |
| MACOS_AARCH64_SIG=$(read_sig "*_aarch64.app.tar.gz.sig") | |
| MACOS_X64_SIG=$(read_sig "*_x64.app.tar.gz.sig") | |
| WINDOWS_NSIS_SIG=$(read_sig "*_x64-setup.exe.sig") | |
| LINUX_AMD64_SIG=$(read_sig "*_amd64.AppImage.sig") | |
| LINUX_AARCH64_SIG=$(read_sig "*_aarch64.AppImage.sig") | |
| echo "Signatures found:" | |
| [ -n "$MACOS_UNI_SIG" ] && echo " macOS Universal: YES" || echo " macOS Universal: NO" | |
| [ -n "$MACOS_AARCH64_SIG" ] && echo " macOS aarch64: YES" || echo " macOS aarch64: NO" | |
| [ -n "$MACOS_X64_SIG" ] && echo " macOS x64: YES" || echo " macOS x64: NO" | |
| [ -n "$WINDOWS_NSIS_SIG" ] && echo " Windows x64: YES" || echo " Windows x64: NO" | |
| [ -n "$LINUX_AMD64_SIG" ] && echo " Linux amd64: YES" || echo " Linux amd64: NO" | |
| [ -n "$LINUX_AARCH64_SIG" ] && echo " Linux aarch64: YES" || echo " Linux aarch64: NO" | |
| # Build updater.json with platform-specific download URLs and signatures | |
| # macOS: arch-suffixed filenames (no version in name) | |
| # Windows/Linux: version included in filename | |
| jq -n \ | |
| --arg version "$VER" \ | |
| --arg notes "See release page for details" \ | |
| --arg pub_date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ | |
| --arg dl "$DOWNLOAD_BASE" \ | |
| --arg mac_a64_sig "$MACOS_AARCH64_SIG" \ | |
| --arg mac_x64_sig "$MACOS_X64_SIG" \ | |
| --arg win_nsis_sig "$WINDOWS_NSIS_SIG" \ | |
| --arg linux_amd64_sig "$LINUX_AMD64_SIG" \ | |
| --arg linux_a64_sig "$LINUX_AARCH64_SIG" \ | |
| --arg mac_a64_url "$([ -n "$MACOS_AARCH64_SIG" ] && echo "Antigravity.Tools_aarch64.app.tar.gz" || echo "Antigravity.Tools_universal.app.tar.gz")" \ | |
| --arg mac_x64_url "$([ -n "$MACOS_X64_SIG" ] && echo "Antigravity.Tools_x64.app.tar.gz" || echo "Antigravity.Tools_universal.app.tar.gz")" \ | |
| --arg ver "$VER" \ | |
| '{ | |
| version: $version, | |
| notes: $notes, | |
| pub_date: $pub_date, | |
| platforms: { | |
| "darwin-aarch64": { | |
| url: "\($dl)/\($mac_a64_url)", | |
| signature: $mac_a64_sig | |
| }, | |
| "darwin-x86_64": { | |
| url: "\($dl)/\($mac_x64_url)", | |
| signature: $mac_x64_sig | |
| }, | |
| "windows-x86_64": { | |
| url: "\($dl)/Antigravity.Tools_\($ver)_x64-setup.exe", | |
| signature: $win_nsis_sig | |
| }, | |
| "linux-x86_64": { | |
| url: "\($dl)/Antigravity.Tools_\($ver)_amd64.AppImage", | |
| signature: $linux_amd64_sig | |
| }, | |
| "linux-aarch64": { | |
| url: "\($dl)/Antigravity.Tools_\($ver)_aarch64.AppImage", | |
| signature: $linux_a64_sig | |
| } | |
| } | |
| }' > updater.json | |
| echo "Generated updater.json:" | |
| cat updater.json | |
| # 使用 ncipollo/release-action 进行统一发布,支持稳健覆盖 | |
| - name: Create or Update GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| allowUpdates: true | |
| name: "Antigravity Tools ${{ github.ref_name }}" | |
| bodyFile: "release_notes.md" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| artifacts: "all-artifacts/**/*,updater.json" | |
| artifactErrorsFailBuild: false | |
| replacesArtifacts: true | |
| makeLatest: legacy | |