ci(release): generate macOS zip, Windows installer + portable, Linux deb; split per-OS build and asset steps
This commit is contained in:
173
.github/workflows/release.yml
vendored
173
.github/workflows/release.yml
vendored
@@ -30,6 +30,11 @@ jobs:
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Add macOS targets
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
||||
|
||||
- name: Install Linux system deps
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
@@ -78,74 +83,102 @@ jobs:
|
||||
- name: Install frontend deps
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build Tauri App
|
||||
- name: Build Tauri App (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: pnpm tauri build --target universal-apple-darwin
|
||||
|
||||
- name: Build Tauri App (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: pnpm tauri build
|
||||
|
||||
- name: Build Tauri App (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: pnpm tauri build
|
||||
|
||||
- name: Prepare macOS Assets
|
||||
if: runner.os == 'macOS'
|
||||
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
|
||||
set -euxo pipefail
|
||||
mkdir -p release-assets
|
||||
echo "Looking for .app bundle..."
|
||||
APP_PATH=""
|
||||
for path in \
|
||||
"src-tauri/target/release/bundle/macos" \
|
||||
"src-tauri/target/universal-apple-darwin/release/bundle/macos" \
|
||||
"src-tauri/target/aarch64-apple-darwin/release/bundle/macos" \
|
||||
"src-tauri/target/x86_64-apple-darwin/release/bundle/macos"; do
|
||||
if [ -d "$path" ]; then
|
||||
APP_PATH=$(find "$path" -name "*.app" -type d | head -1)
|
||||
[ -n "$APP_PATH" ] && break
|
||||
fi
|
||||
done
|
||||
if [ -z "$APP_PATH" ]; then
|
||||
echo "No .app found" >&2
|
||||
exit 1
|
||||
fi
|
||||
APP_DIR=$(dirname "$APP_PATH")
|
||||
APP_NAME=$(basename "$APP_PATH")
|
||||
cd "$APP_DIR"
|
||||
# 使用 ditto 打包更兼容资源分叉
|
||||
ditto -c -k --sequesterRsrc --keepParent "$APP_NAME" "CC-Switch-macOS.zip"
|
||||
mv "CC-Switch-macOS.zip" "$GITHUB_WORKSPACE/release-assets/"
|
||||
echo "macOS zip ready"
|
||||
|
||||
- name: Prepare Windows Assets
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
New-Item -ItemType Directory -Force -Path release-assets | Out-Null
|
||||
# 安装器(优先 NSIS,其次 MSI)
|
||||
$installer = Get-ChildItem -Path 'src-tauri/target/release/bundle' -Recurse -Include *.exe,*.msi -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -match '\\bundle\\(nsis|msi)\\' } |
|
||||
Select-Object -First 1
|
||||
if ($null -ne $installer) {
|
||||
$dest = if ($installer.Extension -ieq '.msi') { 'CC-Switch-Setup.msi' } else { 'CC-Switch-Setup.exe' }
|
||||
Copy-Item $installer.FullName (Join-Path release-assets $dest)
|
||||
Write-Host "Installer copied: $dest"
|
||||
} else {
|
||||
Write-Warning 'No Windows installer found'
|
||||
}
|
||||
# 绿色版(portable):仅可执行文件
|
||||
$exeCandidates = @(
|
||||
'src-tauri/target/release/cc-switch.exe',
|
||||
'src-tauri/target/x86_64-pc-windows-msvc/release/cc-switch.exe'
|
||||
)
|
||||
$exePath = $exeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
if ($null -ne $exePath) {
|
||||
$portableDir = 'release-assets/CC-Switch-Portable'
|
||||
New-Item -ItemType Directory -Force -Path $portableDir | Out-Null
|
||||
Copy-Item $exePath $portableDir
|
||||
Compress-Archive -Path "$portableDir/*" -DestinationPath 'release-assets/CC-Switch-Windows-Portable.zip' -Force
|
||||
Remove-Item -Recurse -Force $portableDir
|
||||
Write-Host 'Windows portable zip created'
|
||||
} else {
|
||||
Write-Warning 'Portable exe not found'
|
||||
}
|
||||
|
||||
- name: Prepare Linux Assets
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
mkdir -p release-assets
|
||||
# 仅上传安装包(deb)
|
||||
DEB=$(find src-tauri/target/release/bundle -name "*.deb" | head -1 || true)
|
||||
if [ -n "$DEB" ]; then
|
||||
cp "$DEB" release-assets/
|
||||
echo "Deb package copied"
|
||||
else
|
||||
# Linux: 构建 AppImage 和 deb
|
||||
pnpm tauri build
|
||||
echo "No .deb found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Prepare Release Assets
|
||||
id: prepare
|
||||
- name: List prepared assets
|
||||
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/
|
||||
ls -la release-assets || true
|
||||
|
||||
- name: Upload Release Assets
|
||||
uses: softprops/action-gh-release@v1
|
||||
@@ -157,22 +190,14 @@ jobs:
|
||||
|
||||
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: `CC-Switch-macOS.zip`(解压即用)
|
||||
- Windows: `CC-Switch-Setup.exe` 或 `CC-Switch-Setup.msi`(安装版);`CC-Switch-Windows-Portable.zip`(绿色版)
|
||||
- Linux: `*.deb`(Debian/Ubuntu 安装包)
|
||||
|
||||
---
|
||||
|
||||
**macOS 签名问题**:如遇"已损坏"提示,请在终端运行 `xattr -cr "/Applications/CC Switch.app"`
|
||||
提示:macOS 如遇“已损坏”提示,可在终端执行:`xattr -cr "/Applications/CC Switch.app"`
|
||||
files: release-assets/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user