release.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - 'v*'
  6. jobs:
  7. # 第一步:并行构建所有平台
  8. build:
  9. strategy:
  10. fail-fast: false
  11. matrix:
  12. include:
  13. - os: windows-latest
  14. platform: win
  15. target: x86_64-pc-windows-msvc
  16. - os: macos-latest
  17. platform: mac
  18. target: aarch64-apple-darwin
  19. - os: macos-latest
  20. platform: mac-intel
  21. target: x86_64-apple-darwin
  22. - os: ubuntu-22.04
  23. platform: linux
  24. target: x86_64-unknown-linux-gnu
  25. runs-on: ${{ matrix.os }}
  26. steps:
  27. - name: Checkout code
  28. uses: actions/checkout@v4
  29. - name: Setup Node.js
  30. uses: actions/setup-node@v4
  31. with:
  32. node-version: '20'
  33. cache: 'npm'
  34. - name: Install Rust toolchain
  35. uses: dtolnay/rust-toolchain@stable
  36. with:
  37. targets: ${{ matrix.target }}
  38. - name: Cache Rust
  39. uses: Swatinem/rust-cache@v2
  40. with:
  41. workspaces: src-tauri -> target
  42. cache-targets: true
  43. shared-key: ${{ matrix.target }}
  44. - name: Install Linux dependencies (cached)
  45. if: matrix.platform == 'linux'
  46. uses: awalsh128/cache-apt-pkgs-action@latest
  47. with:
  48. packages: libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf libgtk-3-dev
  49. version: 1.0
  50. - name: Install dependencies
  51. run: npm ci
  52. - name: Build application (Windows)
  53. if: matrix.platform == 'win'
  54. env:
  55. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  56. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
  57. run: node scripts/build.js --target ${{ matrix.target }}
  58. - name: Build application (macOS/Linux)
  59. if: matrix.platform != 'win'
  60. env:
  61. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  62. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
  63. run: |
  64. chmod +x build-mac.sh build-linux.sh
  65. node scripts/build.js --target ${{ matrix.target }}
  66. - name: Upload artifacts
  67. uses: actions/upload-artifact@v4
  68. with:
  69. name: artifacts-${{ matrix.platform }}
  70. path: built/*
  71. if-no-files-found: error
  72. # 第二步:创建 Release 并上传所有产物
  73. release:
  74. needs: build
  75. runs-on: ubuntu-latest
  76. permissions:
  77. contents: write
  78. steps:
  79. - name: Download all artifacts
  80. uses: actions/download-artifact@v4
  81. with:
  82. path: artifacts
  83. pattern: artifacts-*
  84. merge-multiple: true
  85. - name: List artifacts
  86. run: ls -la artifacts/
  87. - name: Create Release
  88. uses: softprops/action-gh-release@v1
  89. with:
  90. body: |
  91. ## Downloads
  92. ### Windows
  93. - `*-win-x64-setup.exe` - NSIS 安装程序 (推荐)
  94. - `*-win-x64-portable.exe` - 便携版
  95. - `*-win-x64.msi` - MSI 安装程序
  96. ### macOS
  97. - `*-mac-arm64.dmg` - Apple Silicon (M1/M2/M3)
  98. - `*-mac-x64.dmg` - Intel
  99. ### Linux
  100. - `*-linux-x64.deb` - Debian/Ubuntu
  101. - `*-linux-x64.AppImage` - 通用 AppImage
  102. draft: false
  103. prerelease: false
  104. files: artifacts/*
  105. env:
  106. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}