- 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
186 lines
6.0 KiB
YAML
186 lines
6.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
- os: ubuntu-latest
|
|
- os: macos-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Install Linux system deps
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
sudo apt-get update
|
|
# Core build tools and pkg-config
|
|
sudo apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
pkg-config \
|
|
curl \
|
|
wget \
|
|
file \
|
|
patchelf \
|
|
libssl-dev
|
|
# GTK/GLib stack for gdk-3.0, glib-2.0, gio-2.0
|
|
sudo apt-get install -y --no-install-recommends \
|
|
libgtk-3-dev \
|
|
librsvg2-dev \
|
|
libayatana-appindicator3-dev
|
|
# WebKit2GTK (version differs across Ubuntu images; try 4.1 then 4.0)
|
|
sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \
|
|
|| sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.0-dev
|
|
# libsoup also changed major version; prefer 3.0 with fallback to 2.4
|
|
sudo apt-get install -y --no-install-recommends libsoup-3.0-dev \
|
|
|| sudo apt-get install -y --no-install-recommends libsoup2.4-dev
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 10.12.3
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
id: pnpm-store
|
|
shell: bash
|
|
run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Setup pnpm cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.pnpm-store.outputs.path }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: ${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Install frontend deps
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- 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:
|
|
tag_name: ${{ github.ref_name }}
|
|
name: CC Switch ${{ github.ref_name }}
|
|
body: |
|
|
## CC Switch ${{ github.ref_name }}
|
|
|
|
Claude Code 供应商切换工具
|
|
|
|
### 下载说明
|
|
|
|
#### 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()
|
|
shell: bash
|
|
run: |
|
|
echo "Listing bundles in src-tauri/target..."
|
|
find src-tauri/target -maxdepth 4 -type f -name "*.*" 2>/dev/null || true
|