Skip to content

Commit 7d5f8bf

Browse files
wflixuclaude
andcommitted
ci: split GitHub Actions into separate CI and Release workflows
- Create dedicated ci.yml for push/PR testing to main branch - Keep release.yml focused on version tag releases - Remove unnecessary conditional checks from release workflow - Cleaner separation of concerns for different trigger events CI workflow triggers: - Push to main branch: run tests only - PR to main branch: run tests only Release workflow triggers: - Push version tags: run tests + publish + create release 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 2817cf6 commit 7d5f8bf

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
# 测试所有平台和 Rust 版本
14+
test:
15+
name: Test
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
20+
rust: [stable]
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install Rust
25+
uses: dtolnay/rust-toolchain@master
26+
with:
27+
toolchain: ${{ matrix.rust }}
28+
29+
- name: Cache dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.cargo/registry
34+
~/.cargo/git
35+
target
36+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
37+
38+
- name: Build binaries
39+
run: cargo build --verbose --all-features
40+
41+
- name: Run tests
42+
run: cargo test --verbose --all-features
43+
44+
- name: Run clippy
45+
run: cargo clippy --all-features -- -D warnings

.github/workflows/release.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
name: CI
1+
name: Release
22

33
on:
44
push:
5-
branches: [ main ]
65
tags:
76
- 'v*'
8-
pull_request:
9-
branches: [ main ]
107

118
env:
129
CARGO_TERM_COLOR: always
1310

1411
jobs:
15-
# 测试所有平台和 Rust 版本
12+
# 运行测试以确保发布版本质量
1613
test:
1714
name: Test
1815
runs-on: ${{ matrix.os }}
@@ -46,12 +43,11 @@ jobs:
4643
- name: Run clippy
4744
run: cargo clippy --all-features -- -D warnings
4845

49-
# 发布到 crates.io (仅在推送标签时执行)
46+
# 发布到 crates.io
5047
publish:
5148
name: Publish to crates.io
5249
runs-on: ubuntu-latest
5350
needs: test
54-
if: startsWith(github.ref, 'refs/tags/')
5551
steps:
5652
- uses: actions/checkout@v4
5753

@@ -89,12 +85,11 @@ jobs:
8985
- name: Publish mdz to crates.io
9086
run: cargo publish -p mdz --token ${{ secrets.CRATES_IO_TOKEN }}
9187

92-
# 构建 GitHub Releases (仅在推送标签时执行)
88+
# 构建 GitHub Releases
9389
release:
9490
name: Create GitHub Release
9591
runs-on: ubuntu-latest
9692
needs: publish
97-
if: startsWith(github.ref, 'refs/tags/')
9893
steps:
9994
- uses: actions/checkout@v4
10095

0 commit comments

Comments
 (0)