release.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 Tauri application
  102. uses: tauri-apps/tauri-action@v0
  103. env:
  104. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  105. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  106. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
  107. with:
  108. tagName: v${{ needs.update-version.outputs.version }}
  109. releaseName: 'Claude AI Installer v${{ needs.update-version.outputs.version }}'
  110. releaseBody: 'See the assets to download this version and install.'
  111. releaseDraft: false
  112. prerelease: false
  113. args: --target ${{ matrix.target }}