release.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - 'v*'
  6. jobs:
  7. # 第一步:类型检查、更新版本号并提交
  8. update-version:
  9. runs-on: ubuntu-latest
  10. outputs:
  11. version: ${{ steps.version.outputs.VERSION }}
  12. steps:
  13. - name: Checkout code
  14. uses: actions/checkout@v4
  15. - name: Setup Node.js
  16. uses: actions/setup-node@v4
  17. with:
  18. node-version: '20'
  19. cache: 'npm'
  20. - name: Install dependencies
  21. run: npm ci
  22. - name: Type check
  23. run: npm run typecheck
  24. - name: Extract version from tag
  25. id: version
  26. run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
  27. - name: Update version in all config files
  28. run: |
  29. # Update package.json
  30. npm pkg set version=${{ steps.version.outputs.VERSION }}
  31. # Update Cargo.toml
  32. sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.VERSION }}"/' src-tauri/Cargo.toml
  33. # Update tauri.conf.json
  34. sed -i 's/"version": ".*"/"version": "${{ steps.version.outputs.VERSION }}"/' src-tauri/tauri.conf.json
  35. - name: Commit version update
  36. run: |
  37. git config user.name "github-actions[bot]"
  38. git config user.email "github-actions[bot]@users.noreply.github.com"
  39. git add package.json src-tauri/Cargo.toml src-tauri/tauri.conf.json
  40. git commit -m "chore: bump version to ${{ steps.version.outputs.VERSION }}" || echo "No changes to commit"
  41. git push origin HEAD:main
  42. # 第二步:并行构建所有平台
  43. build:
  44. needs: update-version
  45. strategy:
  46. fail-fast: false
  47. matrix:
  48. include:
  49. - os: windows-latest
  50. platform: win
  51. target: x86_64-pc-windows-msvc
  52. - os: macos-latest
  53. platform: mac
  54. target: aarch64-apple-darwin
  55. - os: macos-latest
  56. platform: mac-intel
  57. target: x86_64-apple-darwin
  58. - os: ubuntu-22.04
  59. platform: linux
  60. target: x86_64-unknown-linux-gnu
  61. runs-on: ${{ matrix.os }}
  62. steps:
  63. - name: Checkout code
  64. uses: actions/checkout@v4
  65. with:
  66. ref: main
  67. - name: Setup Node.js
  68. uses: actions/setup-node@v4
  69. with:
  70. node-version: '20'
  71. cache: 'npm'
  72. - name: Install Rust toolchain
  73. uses: dtolnay/rust-toolchain@stable
  74. with:
  75. targets: ${{ matrix.target }}
  76. - name: Cache Cargo
  77. uses: actions/cache@v4
  78. with:
  79. path: |
  80. ~/.cargo/bin/
  81. ~/.cargo/registry/index/
  82. ~/.cargo/registry/cache/
  83. ~/.cargo/git/db/
  84. src-tauri/target/
  85. key: cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/Cargo.lock') }}
  86. restore-keys: |
  87. cargo-${{ runner.os }}-${{ matrix.target }}-
  88. - name: Install Linux dependencies
  89. if: matrix.platform == 'linux'
  90. run: |
  91. sudo apt-get update
  92. sudo apt-get install -y \
  93. libwebkit2gtk-4.1-dev \
  94. libappindicator3-dev \
  95. librsvg2-dev \
  96. patchelf \
  97. libgtk-3-dev \
  98. libayatana-appindicator3-dev
  99. - name: Install dependencies
  100. run: npm ci
  101. - name: Build application (Windows)
  102. if: matrix.platform == 'win'
  103. env:
  104. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  105. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
  106. run: node scripts/build.js --target ${{ matrix.target }}
  107. - name: Build application (macOS/Linux)
  108. if: matrix.platform != 'win'
  109. env:
  110. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  111. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
  112. run: |
  113. chmod +x build-mac.sh build-linux.sh
  114. node scripts/build.js --target ${{ matrix.target }}
  115. - name: Upload artifacts
  116. uses: actions/upload-artifact@v4
  117. with:
  118. name: artifacts-${{ matrix.platform }}
  119. path: built/*
  120. if-no-files-found: error
  121. # 第三步:创建 Release 并上传所有产物
  122. release:
  123. needs: [update-version, build]
  124. runs-on: ubuntu-latest
  125. permissions:
  126. contents: write
  127. steps:
  128. - name: Download all artifacts
  129. uses: actions/download-artifact@v4
  130. with:
  131. path: artifacts
  132. pattern: artifacts-*
  133. merge-multiple: true
  134. - name: List artifacts
  135. run: ls -la artifacts/
  136. - name: Create Release
  137. uses: softprops/action-gh-release@v1
  138. with:
  139. tag_name: v${{ needs.update-version.outputs.version }}
  140. name: 'Claude AI Installer v${{ needs.update-version.outputs.version }}'
  141. body: |
  142. ## Downloads
  143. ### Windows
  144. - `*-win-x64-setup.exe` - NSIS 安装程序 (推荐)
  145. - `*-win-x64-portable.exe` - 便携版
  146. - `*-win-x64.msi` - MSI 安装程序
  147. ### macOS
  148. - `*-mac-arm64.dmg` - Apple Silicon (M1/M2/M3)
  149. - `*-mac-x64.dmg` - Intel
  150. ### Linux
  151. - `*-linux-x64.deb` - Debian/Ubuntu
  152. - `*-linux-x64.AppImage` - 通用 AppImage
  153. draft: false
  154. prerelease: false
  155. files: artifacts/*
  156. env:
  157. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}