-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (50 loc) · 1.38 KB
/
publish.yml
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
name: Build and Publish
on:
push:
tags:
- 'v*'
branches:
- 'main'
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Check formatting
run: cargo fmt -- --check
publish:
name: Publish
needs: test
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Update version in Cargo.toml
shell: bash
run: |
VERSION=${GITHUB_REF#refs/tags/v}
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
echo "Updated version to: $VERSION"
grep "^version = " Cargo.toml
- name: Publish to crates.io
shell: bash
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --token "$CARGO_REGISTRY_TOKEN"