Skip to content

Commit 66149ed

Browse files
committed
update workflow
1 parent 8d90160 commit 66149ed

File tree

1 file changed

+84
-73
lines changed

1 file changed

+84
-73
lines changed

.github/workflows/release.yml

Lines changed: 84 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ concurrency:
1414

1515
jobs:
1616
build:
17-
name: Build ${{ matrix.target }}
17+
name: Build ${{ matrix.platform }}
1818
runs-on: ${{ matrix.os }}
1919
strategy:
2020
fail-fast: false
2121
matrix:
2222
include:
2323
# macOS ARM64
2424
- os: macos-14
25+
platform: darwin-arm64
2526
target: aarch64-apple-darwin
26-
artifact_name: cc-switch
27-
asset_name: cc-switch-darwin-arm64
27+
binary: cc-switch
2828
# macOS x86_64
2929
- os: macos-14
30+
platform: darwin-x64
3031
target: x86_64-apple-darwin
31-
artifact_name: cc-switch
32-
asset_name: cc-switch-darwin-x64
32+
binary: cc-switch
3333
# Windows x86_64
3434
- os: windows-2022
35+
platform: windows-x64
3536
target: x86_64-pc-windows-msvc
36-
artifact_name: cc-switch.exe
37-
asset_name: cc-switch-windows-x64.exe
37+
binary: cc-switch.exe
3838
# Linux x86_64
3939
- os: ubuntu-22.04
40+
platform: linux-x64
4041
target: x86_64-unknown-linux-gnu
41-
artifact_name: cc-switch
42-
asset_name: cc-switch-linux-x64
42+
binary: cc-switch
4343
# Linux ARM64
4444
- os: ubuntu-22.04
45+
platform: linux-arm64
4546
target: aarch64-unknown-linux-gnu
46-
artifact_name: cc-switch
47-
asset_name: cc-switch-linux-arm64
47+
binary: cc-switch
4848

4949
steps:
5050
- name: Checkout
@@ -55,18 +55,11 @@ jobs:
5555
with:
5656
targets: ${{ matrix.target }}
5757

58-
- name: Cache cargo
59-
uses: actions/cache@v4
58+
- name: Setup Rust cache
59+
uses: Swatinem/rust-cache@v2
6060
with:
61-
path: |
62-
~/.cargo/bin/
63-
~/.cargo/registry/index/
64-
~/.cargo/registry/cache/
65-
~/.cargo/git/db/
66-
src-tauri/target/
67-
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
68-
restore-keys: |
69-
${{ runner.os }}-${{ matrix.target }}-cargo-
61+
workspaces: src-tauri
62+
key: ${{ matrix.target }}
7063

7164
- name: Install Linux dependencies (x64)
7265
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
@@ -96,11 +89,17 @@ jobs:
9689
working-directory: src-tauri
9790
run: cargo build --release --target ${{ matrix.target }}
9891

92+
- name: Prepare binary
93+
shell: bash
94+
run: |
95+
mkdir -p dist
96+
cp src-tauri/target/${{ matrix.target }}/release/${{ matrix.binary }} dist/
97+
9998
- name: Upload artifact
10099
uses: actions/upload-artifact@v4
101100
with:
102-
name: ${{ matrix.asset_name }}
103-
path: src-tauri/target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
101+
name: cc-switch-cli-${{ matrix.platform }}
102+
path: dist/${{ matrix.binary }}
104103
if-no-files-found: error
105104

106105
# Create macOS universal binary
@@ -112,13 +111,13 @@ jobs:
112111
- name: Download ARM64 binary
113112
uses: actions/download-artifact@v4
114113
with:
115-
name: cc-switch-darwin-arm64
114+
name: cc-switch-cli-darwin-arm64
116115
path: arm64
117116

118117
- name: Download x64 binary
119118
uses: actions/download-artifact@v4
120119
with:
121-
name: cc-switch-darwin-x64
120+
name: cc-switch-cli-darwin-x64
122121
path: x64
123122

124123
- name: Create universal binary
@@ -131,7 +130,7 @@ jobs:
131130
- name: Upload universal artifact
132131
uses: actions/upload-artifact@v4
133132
with:
134-
name: cc-switch-darwin-universal
133+
name: cc-switch-cli-darwin-universal
135134
path: universal/cc-switch
136135
if-no-files-found: error
137136

@@ -145,98 +144,110 @@ jobs:
145144
with:
146145
path: artifacts
147146

147+
- name: Display structure
148+
run: |
149+
ls -R artifacts/
150+
148151
- name: Prepare release assets
149152
run: |
150153
set -euxo pipefail
151154
mkdir -p release-assets
152155
VERSION="${GITHUB_REF_NAME}"
153156
154-
# macOS Universal
155-
if [ -f "artifacts/cc-switch-darwin-universal/cc-switch" ]; then
156-
cp artifacts/cc-switch-darwin-universal/cc-switch release-assets/cc-switch-${VERSION}-darwin-universal
157-
chmod +x release-assets/cc-switch-${VERSION}-darwin-universal
158-
# Also create tar.gz for easier distribution
159-
tar -czvf release-assets/cc-switch-${VERSION}-darwin-universal.tar.gz \
160-
-C artifacts/cc-switch-darwin-universal cc-switch
157+
# macOS Universal (recommended)
158+
if [ -f "artifacts/cc-switch-cli-darwin-universal/cc-switch" ]; then
159+
cp artifacts/cc-switch-cli-darwin-universal/cc-switch release-assets/cc-switch-cli-${VERSION}-darwin-universal
160+
chmod +x release-assets/cc-switch-cli-${VERSION}-darwin-universal
161+
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-universal.tar.gz \
162+
-C artifacts/cc-switch-cli-darwin-universal cc-switch
161163
fi
162164
163165
# macOS ARM64 (standalone)
164-
if [ -f "artifacts/cc-switch-darwin-arm64/cc-switch" ]; then
165-
cp artifacts/cc-switch-darwin-arm64/cc-switch release-assets/cc-switch-${VERSION}-darwin-arm64
166-
chmod +x release-assets/cc-switch-${VERSION}-darwin-arm64
166+
if [ -f "artifacts/cc-switch-cli-darwin-arm64/cc-switch" ]; then
167+
cp artifacts/cc-switch-cli-darwin-arm64/cc-switch release-assets/cc-switch-cli-${VERSION}-darwin-arm64
168+
chmod +x release-assets/cc-switch-cli-${VERSION}-darwin-arm64
169+
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-arm64.tar.gz \
170+
-C artifacts/cc-switch-cli-darwin-arm64 cc-switch
167171
fi
168172
169173
# macOS x64 (standalone)
170-
if [ -f "artifacts/cc-switch-darwin-x64/cc-switch" ]; then
171-
cp artifacts/cc-switch-darwin-x64/cc-switch release-assets/cc-switch-${VERSION}-darwin-x64
172-
chmod +x release-assets/cc-switch-${VERSION}-darwin-x64
174+
if [ -f "artifacts/cc-switch-cli-darwin-x64/cc-switch" ]; then
175+
cp artifacts/cc-switch-cli-darwin-x64/cc-switch release-assets/cc-switch-cli-${VERSION}-darwin-x64
176+
chmod +x release-assets/cc-switch-cli-${VERSION}-darwin-x64
177+
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-x64.tar.gz \
178+
-C artifacts/cc-switch-cli-darwin-x64 cc-switch
173179
fi
174180
175181
# Windows
176-
if [ -f "artifacts/cc-switch-windows-x64.exe/cc-switch.exe" ]; then
177-
cp artifacts/cc-switch-windows-x64.exe/cc-switch.exe release-assets/cc-switch-${VERSION}-windows-x64.exe
182+
if [ -f "artifacts/cc-switch-cli-windows-x64/cc-switch.exe" ]; then
183+
cp artifacts/cc-switch-cli-windows-x64/cc-switch.exe release-assets/cc-switch-cli-${VERSION}-windows-x64.exe
184+
# Create zip for Windows
185+
cd artifacts/cc-switch-cli-windows-x64
186+
zip ../../release-assets/cc-switch-cli-${VERSION}-windows-x64.zip cc-switch.exe
187+
cd ../..
178188
fi
179189
180190
# Linux x64
181-
if [ -f "artifacts/cc-switch-linux-x64/cc-switch" ]; then
182-
cp artifacts/cc-switch-linux-x64/cc-switch release-assets/cc-switch-${VERSION}-linux-x64
183-
chmod +x release-assets/cc-switch-${VERSION}-linux-x64
184-
# Also create tar.gz
185-
tar -czvf release-assets/cc-switch-${VERSION}-linux-x64.tar.gz \
186-
-C artifacts/cc-switch-linux-x64 cc-switch
191+
if [ -f "artifacts/cc-switch-cli-linux-x64/cc-switch" ]; then
192+
cp artifacts/cc-switch-cli-linux-x64/cc-switch release-assets/cc-switch-cli-${VERSION}-linux-x64
193+
chmod +x release-assets/cc-switch-cli-${VERSION}-linux-x64
194+
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-x64.tar.gz \
195+
-C artifacts/cc-switch-cli-linux-x64 cc-switch
187196
fi
188197
189198
# Linux ARM64
190-
if [ -f "artifacts/cc-switch-linux-arm64/cc-switch" ]; then
191-
cp artifacts/cc-switch-linux-arm64/cc-switch release-assets/cc-switch-${VERSION}-linux-arm64
192-
chmod +x release-assets/cc-switch-${VERSION}-linux-arm64
193-
# Also create tar.gz
194-
tar -czvf release-assets/cc-switch-${VERSION}-linux-arm64.tar.gz \
195-
-C artifacts/cc-switch-linux-arm64 cc-switch
199+
if [ -f "artifacts/cc-switch-cli-linux-arm64/cc-switch" ]; then
200+
cp artifacts/cc-switch-cli-linux-arm64/cc-switch release-assets/cc-switch-cli-${VERSION}-linux-arm64
201+
chmod +x release-assets/cc-switch-cli-${VERSION}-linux-arm64
202+
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-arm64.tar.gz \
203+
-C artifacts/cc-switch-cli-linux-arm64 cc-switch
196204
fi
197205
198206
echo "=== Release assets ==="
199-
ls -la release-assets/
207+
ls -lh release-assets/
200208
201209
- name: Create Release
202210
uses: softprops/action-gh-release@v2
203211
with:
204212
tag_name: ${{ github.ref_name }}
205-
name: CC Switch ${{ github.ref_name }}
213+
name: CC Switch CLI ${{ github.ref_name }}
206214
draft: false
207215
prerelease: false
208216
generate_release_notes: true
209217
body: |
210-
## CC Switch ${{ github.ref_name }}
218+
## CC Switch CLI ${{ github.ref_name }}
211219
212220
All-in-One Assistant for Claude Code, Codex & Gemini CLI
213221
214-
### 下载 / Downloads
222+
### 📦 下载 / Downloads
215223
216-
| 平台 Platform | 文件 File | 说明 Note |
217-
|---------------|-----------|-----------|
218-
| **macOS** (Universal) | `cc-switch-${{ github.ref_name }}-darwin-universal` | 支持 Apple Silicon & Intel |
219-
| **macOS** (ARM64) | `cc-switch-${{ github.ref_name }}-darwin-arm64` | Apple Silicon only |
220-
| **macOS** (x64) | `cc-switch-${{ github.ref_name }}-darwin-x64` | Intel only |
221-
| **Windows** (x64) | `cc-switch-${{ github.ref_name }}-windows-x64.exe` | Windows 10/11 |
222-
| **Linux** (x64) | `cc-switch-${{ github.ref_name }}-linux-x64` | glibc 2.31+ |
223-
| **Linux** (ARM64) | `cc-switch-${{ github.ref_name }}-linux-arm64` | 树莓派/ARM 服务器 |
224+
| 平台 | 推荐下载 | 备选 |
225+
|------|----------|------|
226+
| **macOS** | `cc-switch-cli-${{ github.ref_name }}-darwin-universal.tar.gz` | ARM64 / x64 单架构版本 |
227+
| **Windows** | `cc-switch-cli-${{ github.ref_name }}-windows-x64.zip` | `.exe` 单文件版 |
228+
| **Linux (x64)** | `cc-switch-cli-${{ github.ref_name }}-linux-x64.tar.gz` | 直接二进制 |
229+
| **Linux (ARM64)** | `cc-switch-cli-${{ github.ref_name }}-linux-arm64.tar.gz` | 树莓派/ARM 服务器 |
224230
225-
### 安装 / Installation
231+
### 🚀 快速安装
226232
227233
**macOS / Linux:**
228234
```bash
229-
# 下载后添加执行权限
230-
chmod +x cc-switch-*
231-
# 移动到 PATH
232-
sudo mv cc-switch-* /usr/local/bin/cc-switch
235+
# 下载并解压 tar.gz
236+
tar -xzf cc-switch-cli-*.tar.gz
237+
238+
# 添加执行权限并移动到 PATH
239+
chmod +x cc-switch
240+
sudo mv cc-switch /usr/local/bin/
233241
```
234242
235243
**Windows:**
236-
将 `.exe` 文件移动到 PATH 目录,或直接运行。
244+
```powershell
245+
# 解压 zip,然后将 cc-switch.exe 移动到 PATH 目录
246+
# 或直接运行 cc-switch.exe
247+
```
237248
238249
---
239-
> 💡 macOS 如遇 "无法验证开发者" 提示,可执行: `xattr -cr cc-switch-*`
250+
💡 **macOS 提示**: 首次运行如遇 "无法验证开发者",执行:`xattr -cr /usr/local/bin/cc-switch`
240251
files: release-assets/*
241252
env:
242253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)