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
name: Publish to crates.io
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Verify tag matches Cargo.toml version
if: startsWith(github.ref, 'refs/tags/v')
run: |
tag="${GITHUB_REF#refs/tags/v}"
crate=$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name=="responses-proxy") | .version')
if [ "$tag" != "$crate" ]; then
echo "Tag v$tag does not match Cargo.toml version $crate" >&2
exit 1
fi
- name: cargo test
run: cargo test --all-features
- name: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish