Repository navigation
384 lines (335 loc) · 12.3 KB
/
Copy pathrelease.yml
File metadata and controls
384 lines (335 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
RUST_VERSION: 1.91.1
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
jobs:
benchmark-gate:
name: Blocking benchmark gate
runs-on: ubuntu-22.04
timeout-minutes: 20
env:
TERM: xterm-256color
LANG: C.UTF-8
LC_ALL: C.UTF-8
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
key: release-benchmark-gate
- name: Build release binary
working-directory: src-tauri
run: cargo build --release
- name: Run blocking benchmarks
run: |
python3 scripts/benchmark_cc_switch.py \
--binary src-tauri/target/release/cc-switch \
--operation-set ci-blocking \
--iterations 5 \
--warmup 1 \
--providers-per-app 12 \
--usage-rows 500 \
--sessions-per-app 8 \
--mcp-rows 4 \
--skill-rows 4 \
--redact-paths \
--fail-fast \
--json-output benchmark-results.json
- name: Check benchmark thresholds
run: |
python3 scripts/check_benchmark_thresholds.py \
benchmark-results.json \
--summary-output benchmark-summary.md
- name: Upload benchmark artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: release-benchmark-results
path: |
benchmark-results.json
benchmark-summary.md
if-no-files-found: warn
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
needs: benchmark-gate
strategy:
fail-fast: false
matrix:
include:
# macOS ARM64
- os: macos-14
platform: darwin-arm64
target: aarch64-apple-darwin
binary: cc-switch
# macOS x86_64
- os: macos-14
platform: darwin-x64
target: x86_64-apple-darwin
binary: cc-switch
# Windows x86_64
- os: windows-2022
platform: windows-x64
target: x86_64-pc-windows-msvc
binary: cc-switch.exe
# Linux x86_64 - MUSL (recommended)
- os: ubuntu-22.04
platform: linux-x64-musl
target: x86_64-unknown-linux-musl
binary: cc-switch
use_cross: true
# Linux x86_64 - GLIBC (fallback)
- os: ubuntu-22.04
platform: linux-x64
target: x86_64-unknown-linux-gnu
binary: cc-switch
use_cross: false
# Linux ARM64 - MUSL (recommended)
- os: ubuntu-22.04
platform: linux-arm64-musl
target: aarch64-unknown-linux-musl
binary: cc-switch
use_cross: true
# Linux ARM64 - GLIBC (fallback)
- os: ubuntu-22.04
platform: linux-arm64
target: aarch64-unknown-linux-gnu
binary: cc-switch
use_cross: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: ${{ matrix.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
key: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross == true
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install Linux dependencies (GLIBC x64)
if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
libssl-dev
- name: Build with cross
if: matrix.use_cross == true
working-directory: src-tauri
run: cross build --release --target ${{ matrix.target }}
- name: Build with cargo
if: matrix.use_cross != true
working-directory: src-tauri
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary
shell: bash
run: |
mkdir -p dist
cp src-tauri/target/${{ matrix.target }}/release/${{ matrix.binary }} dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cc-switch-cli-${{ matrix.platform }}
path: dist/${{ matrix.binary }}
if-no-files-found: error
# Create macOS universal binary
universal-macos:
name: Universal macOS Binary
runs-on: macos-14
needs: build
steps:
- name: Download ARM64 binary
uses: actions/download-artifact@v4
with:
name: cc-switch-cli-darwin-arm64
path: arm64
- name: Download x64 binary
uses: actions/download-artifact@v4
with:
name: cc-switch-cli-darwin-x64
path: x64
- name: Create universal binary
run: |
mkdir -p universal
lipo -create -output universal/cc-switch arm64/cc-switch x64/cc-switch
chmod +x universal/cc-switch
file universal/cc-switch
- name: Upload universal artifact
uses: actions/upload-artifact@v4
with:
name: cc-switch-cli-darwin-universal
path: universal/cc-switch
if-no-files-found: error
release:
name: Create Release
runs-on: ubuntu-22.04
needs: [build, universal-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: cc-switch-cli-*
- name: Display structure
run: |
ls -R artifacts/
- name: Install minisign
shell: bash
run: |
set -euxo pipefail
MINISIGN_VERSION="0.12"
case "$(uname -m)" in
x86_64|amd64) MINISIGN_ARCH="x86_64" ;;
aarch64|arm64) MINISIGN_ARCH="aarch64" ;;
*)
echo "Unsupported minisign architecture: $(uname -m)" >&2
exit 1
;;
esac
curl -fsSL \
"https://github.com/jedisct1/minisign/releases/download/${MINISIGN_VERSION}/minisign-${MINISIGN_VERSION}-linux.tar.gz" \
-o /tmp/minisign.tar.gz
tar -xzf /tmp/minisign.tar.gz -C /tmp
sudo install -m 0755 \
"/tmp/minisign-linux/${MINISIGN_ARCH}/minisign" \
/usr/local/bin/minisign
minisign -v
- name: Prepare release assets
run: |
set -euxo pipefail
mkdir -p release-assets
VERSION="${GITHUB_REF_NAME}"
# macOS Universal
if [ -f "artifacts/cc-switch-cli-darwin-universal/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-universal.tar.gz \
-C artifacts/cc-switch-cli-darwin-universal cc-switch
cp release-assets/cc-switch-cli-${VERSION}-darwin-universal.tar.gz \
release-assets/cc-switch-cli-darwin-universal.tar.gz
fi
# macOS ARM64
if [ -f "artifacts/cc-switch-cli-darwin-arm64/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-arm64.tar.gz \
-C artifacts/cc-switch-cli-darwin-arm64 cc-switch
cp release-assets/cc-switch-cli-${VERSION}-darwin-arm64.tar.gz \
release-assets/cc-switch-cli-darwin-arm64.tar.gz
fi
# macOS x64
if [ -f "artifacts/cc-switch-cli-darwin-x64/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-darwin-x64.tar.gz \
-C artifacts/cc-switch-cli-darwin-x64 cc-switch
cp release-assets/cc-switch-cli-${VERSION}-darwin-x64.tar.gz \
release-assets/cc-switch-cli-darwin-x64.tar.gz
fi
# Windows
if [ -f "artifacts/cc-switch-cli-windows-x64/cc-switch.exe" ]; then
cd artifacts/cc-switch-cli-windows-x64
zip ../../release-assets/cc-switch-cli-${VERSION}-windows-x64.zip cc-switch.exe
cd ../..
cp release-assets/cc-switch-cli-${VERSION}-windows-x64.zip \
release-assets/cc-switch-cli-windows-x64.zip
fi
# Linux x64 - MUSL
if [ -f "artifacts/cc-switch-cli-linux-x64-musl/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-x64-musl.tar.gz \
-C artifacts/cc-switch-cli-linux-x64-musl cc-switch
cp release-assets/cc-switch-cli-${VERSION}-linux-x64-musl.tar.gz \
release-assets/cc-switch-cli-linux-x64-musl.tar.gz
fi
# Linux x64 - GLIBC
if [ -f "artifacts/cc-switch-cli-linux-x64/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-x64.tar.gz \
-C artifacts/cc-switch-cli-linux-x64 cc-switch
cp release-assets/cc-switch-cli-${VERSION}-linux-x64.tar.gz \
release-assets/cc-switch-cli-linux-x64.tar.gz
fi
# Linux ARM64 - MUSL
if [ -f "artifacts/cc-switch-cli-linux-arm64-musl/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-arm64-musl.tar.gz \
-C artifacts/cc-switch-cli-linux-arm64-musl cc-switch
cp release-assets/cc-switch-cli-${VERSION}-linux-arm64-musl.tar.gz \
release-assets/cc-switch-cli-linux-arm64-musl.tar.gz
fi
# Linux ARM64 - GLIBC
if [ -f "artifacts/cc-switch-cli-linux-arm64/cc-switch" ]; then
tar -czf release-assets/cc-switch-cli-${VERSION}-linux-arm64.tar.gz \
-C artifacts/cc-switch-cli-linux-arm64 cc-switch
cp release-assets/cc-switch-cli-${VERSION}-linux-arm64.tar.gz \
release-assets/cc-switch-cli-linux-arm64.tar.gz
fi
# Include install script
cp install.sh release-assets/install.sh
echo "=== Release assets ==="
ls -lh release-assets/
- name: Sign updater assets and generate latest.json
env:
CC_SWITCH_MINISIGN_SECRET_KEY: ${{ secrets.CC_SWITCH_MINISIGN_SECRET_KEY }}
run: |
set -euxo pipefail
if [ -z "${CC_SWITCH_MINISIGN_SECRET_KEY}" ]; then
echo "CC_SWITCH_MINISIGN_SECRET_KEY is not configured" >&2
exit 1
fi
key_file="$(mktemp)"
trap 'rm -f "${key_file}"' EXIT
printf '%s' "${CC_SWITCH_MINISIGN_SECRET_KEY}" > "${key_file}"
chmod 600 "${key_file}"
shopt -s nullglob
for asset in release-assets/cc-switch-cli-*.tar.gz release-assets/cc-switch-cli-*.zip; do
minisign -S \
-s "${key_file}" \
-m "${asset}" \
-x "${asset}.minisig" \
-t "cc-switch-cli ${GITHUB_REF_NAME}"
done
for asset in release-assets/cc-switch-cli-*.tar.gz release-assets/cc-switch-cli-*.zip; do
minisign -Vm "${asset}" \
-p src-tauri/updater/minisign.pub \
-x "${asset}.minisig"
done
python3 scripts/generate_latest_json.py \
release-assets \
"${GITHUB_REF_NAME}" \
"$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
"https://github.com/SaladDay/cc-switch-cli/releases/download/${GITHUB_REF_NAME}" \
"CC Switch CLI ${GITHUB_REF_NAME}"
rm -f release-assets/*.minisig
(
cd release-assets
rm -f checksums.txt
sha256sum * > checksums.txt
)
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: CC Switch CLI ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
body_path: docs/releases/${{ github.ref_name }}.md
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}