From a05fefb54ccf844e2c3e197363abab6877455b66 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 29 Aug 2025 14:40:40 +0800 Subject: [PATCH] feat: optimize release workflow for better distribution - Configure GitHub Actions to generate platform-specific releases: - macOS: zip package only (avoids signing issues) - Windows: installer (NSIS) and portable version - Linux: AppImage and deb packages - Update Tauri config to build all available targets - Add documentation for macOS signature workarounds --- .github/workflows/release.yml | 106 +++++++++++++++++++++++++++++----- README.md | 10 +++- src-tauri/tauri.conf.json | 2 +- 3 files changed, 103 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd88b6b..6e445d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,24 +78,104 @@ jobs: - name: Install frontend deps run: pnpm install --frozen-lockfile - - name: Build and Release (Tauri) - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build Tauri App + shell: bash + run: | + if [ "${{ runner.os }}" == "macOS" ]; then + # macOS: 只构建 app bundle (用于创建 zip) + pnpm tauri build --target aarch64-apple-darwin + elif [ "${{ runner.os }}" == "Windows" ]; then + # Windows: 构建 NSIS 安装器 + pnpm tauri build --target x86_64-pc-windows-msvc + else + # Linux: 构建 AppImage 和 deb + pnpm tauri build + fi + + - name: Prepare Release Assets + id: prepare + shell: bash + run: | + mkdir -p release-assets + + if [ "${{ runner.os }}" == "macOS" ]; then + # macOS: 创建 zip 包 + APP_PATH=$(find src-tauri/target/release/bundle/macos -name "*.app" -type d | head -1) + if [ -n "$APP_PATH" ]; then + APP_NAME=$(basename "$APP_PATH") + cd "$(dirname "$APP_PATH")" + zip -r "CC-Switch-macOS.zip" "$APP_NAME" + mv "CC-Switch-macOS.zip" "$GITHUB_WORKSPACE/release-assets/" + echo "Created macOS zip" + fi + + elif [ "${{ runner.os }}" == "Windows" ]; then + # Windows: 复制 NSIS 安装器 + NSIS_PATH=$(find src-tauri/target/release/bundle/nsis -name "*.exe" | head -1) + if [ -n "$NSIS_PATH" ]; then + cp "$NSIS_PATH" "release-assets/CC-Switch-Setup.exe" + echo "Copied Windows installer" + fi + + # Windows: 创建绿色版 (portable) + EXE_PATH="src-tauri/target/release/cc-switch.exe" + if [ -f "$EXE_PATH" ]; then + mkdir -p "release-assets/CC-Switch-Portable" + cp "$EXE_PATH" "release-assets/CC-Switch-Portable/" + cd release-assets + zip -r "CC-Switch-Windows-Portable.zip" "CC-Switch-Portable" + rm -rf "CC-Switch-Portable" + cd .. + echo "Created Windows portable version" + fi + + else + # Linux: 复制 AppImage 和 deb + APPIMAGE=$(find src-tauri/target/release/bundle -name "*.AppImage" | head -1) + DEB=$(find src-tauri/target/release/bundle -name "*.deb" | head -1) + + if [ -n "$APPIMAGE" ]; then + cp "$APPIMAGE" "release-assets/CC-Switch.AppImage" + echo "Copied AppImage" + fi + + if [ -n "$DEB" ]; then + cp "$DEB" "release-assets/" + echo "Copied deb package" + fi + fi + + ls -la release-assets/ + + - name: Upload Release Assets + uses: softprops/action-gh-release@v1 with: - tagName: ${{ github.ref_name }} - releaseName: CC Switch ${{ github.ref_name }} - releaseBody: | + tag_name: ${{ github.ref_name }} + name: CC Switch ${{ github.ref_name }} + body: | ## CC Switch ${{ github.ref_name }} - Claude Code 供应商切换工具(Tauri 构建) + Claude Code 供应商切换工具 - - Windows: .msi / NSIS 安装包 - - macOS: .dmg / .app 压缩包 - - Linux: AppImage / deb / rpm + ### 下载说明 - 如遇未知开发者提示,请在系统隐私与安全设置中选择“仍要打开”。 - tauriScript: pnpm tauri + #### macOS + - `CC-Switch-macOS.zip` - 解压即用(推荐) + + #### Windows + - `CC-Switch-Setup.exe` - 安装版 + - `CC-Switch-Windows-Portable.zip` - 绿色版,解压即用 + + #### Linux + - `CC-Switch.AppImage` - AppImage 格式 + - `*.deb` - Debian/Ubuntu 安装包 + + --- + + **macOS 签名问题**:如遇"已损坏"提示,请在终端运行 `xattr -cr "/Applications/CC Switch.app"` + files: release-assets/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: List generated bundles (debug) if: always() diff --git a/README.md b/README.md index 65b3f16..5389f9a 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,15 @@ ### macOS 用户 -从 [Releases](../../releases) 页面下载最新版本的 `CC-Switch_3.0.0_x64.dmg` (Intel) 或 `CC-Switch_3.0.0_aarch64.dmg` (Apple Silicon)。 +从 [Releases](../../releases) 页面下载最新版本: + +- **推荐**: `CC-Switch.zip` - 解压即用,无需安装 +- `CC-Switch_3.0.0_aarch64.dmg` (Apple Silicon) - 需要安装 + +> **注意**:由于应用未签名,macOS 可能提示"已损坏"。解决方法: +> 1. **推荐**:下载 zip 版本,解压后直接使用 +> 2. 或在终端运行:`xattr -cr "/Applications/CC Switch.app"` +> 3. 或在"系统设置 > 隐私与安全"中选择"仍要打开" ### Linux 用户 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c7aac19..24454ee 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -28,7 +28,7 @@ }, "bundle": { "active": true, - "targets": ["app", "dmg", "nsis", "appimage"], + "targets": "all", "icon": [ "icons/32x32.png", "icons/128x128.png",