| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- name: Release
- on:
- push:
- tags:
- - 'v*'
- jobs:
- # 第一步:类型检查、更新版本号并提交
- update-version:
- runs-on: ubuntu-latest
- outputs:
- version: ${{ steps.version.outputs.VERSION }}
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'npm'
- - name: Install dependencies
- run: npm ci
- - name: Type check
- run: npm run typecheck
- - name: Extract version from tag
- id: version
- run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- - name: Update version in all config files
- run: |
- # Update package.json
- npm pkg set version=${{ steps.version.outputs.VERSION }}
- # Update Cargo.toml
- sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.VERSION }}"/' src-tauri/Cargo.toml
- # Update tauri.conf.json
- sed -i 's/"version": ".*"/"version": "${{ steps.version.outputs.VERSION }}"/' src-tauri/tauri.conf.json
- - name: Commit version update
- run: |
- git config user.name "github-actions[bot]"
- git config user.email "github-actions[bot]@users.noreply.github.com"
- git add package.json src-tauri/Cargo.toml src-tauri/tauri.conf.json
- git commit -m "chore: bump version to ${{ steps.version.outputs.VERSION }}" || echo "No changes to commit"
- git push origin HEAD:main
- # 第二步:并行构建所有平台
- build:
- needs: update-version
- strategy:
- fail-fast: false
- matrix:
- include:
- - os: windows-latest
- platform: win
- target: x86_64-pc-windows-msvc
- - os: macos-latest
- platform: mac
- target: aarch64-apple-darwin
- - os: macos-latest
- platform: mac-intel
- target: x86_64-apple-darwin
- - os: ubuntu-22.04
- platform: linux
- target: x86_64-unknown-linux-gnu
- runs-on: ${{ matrix.os }}
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- ref: main
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'npm'
- - name: Install Rust toolchain
- uses: dtolnay/rust-toolchain@stable
- with:
- targets: ${{ matrix.target }}
- - name: Cache Cargo
- uses: actions/cache@v4
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- src-tauri/target/
- key: cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/Cargo.lock') }}
- restore-keys: |
- cargo-${{ runner.os }}-${{ matrix.target }}-
- - name: Install Linux dependencies
- if: matrix.platform == 'linux'
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- libwebkit2gtk-4.1-dev \
- libappindicator3-dev \
- librsvg2-dev \
- patchelf \
- libgtk-3-dev \
- libayatana-appindicator3-dev
- - name: Install dependencies
- run: npm ci
- - name: Build application (Windows)
- if: matrix.platform == 'win'
- env:
- TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
- TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
- run: node scripts/build.js --target ${{ matrix.target }}
- - name: Build application (macOS/Linux)
- if: matrix.platform != 'win'
- env:
- TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
- TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
- run: |
- chmod +x build-mac.sh build-linux.sh
- node scripts/build.js --target ${{ matrix.target }}
- - name: Upload artifacts
- uses: actions/upload-artifact@v4
- with:
- name: artifacts-${{ matrix.platform }}
- path: built/*
- if-no-files-found: error
- # 第三步:创建 Release 并上传所有产物
- release:
- needs: [update-version, build]
- runs-on: ubuntu-latest
- permissions:
- contents: write
- steps:
- - name: Download all artifacts
- uses: actions/download-artifact@v4
- with:
- path: artifacts
- pattern: artifacts-*
- merge-multiple: true
- - name: List artifacts
- run: ls -la artifacts/
- - name: Create Release
- uses: softprops/action-gh-release@v1
- with:
- tag_name: v${{ needs.update-version.outputs.version }}
- name: 'Claude AI Installer v${{ needs.update-version.outputs.version }}'
- body: |
- ## Downloads
- ### Windows
- - `*-win-x64-setup.exe` - NSIS 安装程序 (推荐)
- - `*-win-x64-portable.exe` - 便携版
- - `*-win-x64.msi` - MSI 安装程序
- ### macOS
- - `*-mac-arm64.dmg` - Apple Silicon (M1/M2/M3)
- - `*-mac-x64.dmg` - Intel
- ### Linux
- - `*-linux-x64.deb` - Debian/Ubuntu
- - `*-linux-x64.AppImage` - 通用 AppImage
- draft: false
- prerelease: false
- files: artifacts/*
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|