-
Notifications
You must be signed in to change notification settings - Fork 10
70 lines (57 loc) · 1.55 KB
/
ci.yml
File metadata and controls
70 lines (57 loc) · 1.55 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
name: CI
on:
push:
branches:
- master
- 'ft*'
pull_request:
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Build, Lint, and Test
runs-on: ubuntu-latest
container:
image: rust:alpine
steps:
- name: Install Alpine dependencies
run: apk add --no-cache git musl-dev
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust components
run: rustup component add clippy rustfmt
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-alpine-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Lint with Clippy
run: cargo clippy -- -D warnings
- name: Run Tests
run: cargo test --verbose
publish:
name: Publish to Crates.io
runs-on: ubuntu-latest
needs: test
environment: master
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build Release
run: cargo build --release
- name: Publish to Crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --token $CARGO_REGISTRY_TOKEN