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
name: Publish Crate
on:
push:
tags:
- 'v*.*.*' # Déclenche la publication seulement sur les tags versionnés SemVer
jobs:
publish:
runs-on: ubuntu-latest
container:
image: rust:latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run tests
run: cargo test --verbose
- name: Build crate
run: cargo build --release
- name: Verify version string consistency
run: |
VERSION_TAG=${GITHUB_REF#refs/tags/}
CARGO_VERSION=$(cargo pkgid | sed 's/.*#//')
if [ "$VERSION_TAG" != "$CARGO_VERSION" ]; then
echo "Version tag ($VERSION_TAG) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
- name: Publish crate to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --registry crates-io