Skip to content

Commit 5bb36fd

Browse files
committed
Add CI/CD pipeline
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent 2835053 commit 5bb36fd

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/pipeline.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger on pushes to the main branch
7+
pull_request:
8+
branches:
9+
- main # Trigger on pull requests targeting the main branch
10+
workflow_dispatch: # Allow manual triggers
11+
12+
jobs:
13+
build-and-test:
14+
name: Build and Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable # Use the stable toolchain
25+
profile: minimal # Install only essential components
26+
override: true
27+
28+
- name: Cache Cargo registry
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cargo/registry
32+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-cargo-registry-
35+
36+
- name: Cache Cargo build
37+
uses: actions/cache@v3
38+
with:
39+
path: target
40+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-cargo-build-
43+
44+
- name: Build the project
45+
run: cargo build --workspace --all-targets
46+
47+
- name: Run tests
48+
run: cargo test --workspace --all-targets
49+
50+
release:
51+
name: Publish to crates.io
52+
needs: build-and-test
53+
runs-on: ubuntu-latest
54+
if: github.ref == 'refs/heads/main' # Only run on the main branch
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v3
59+
60+
- name: Set up Rust
61+
uses: actions-rs/toolchain@v1
62+
with:
63+
toolchain: stable
64+
profile: minimal
65+
override: true
66+
67+
- name: Publish to crates.io
68+
run: cargo publish --workspace --allow-dirty
69+
env:
70+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)