Skip to content

Commit 290455a

Browse files
committed
ci: implement publish
1 parent 40a183d commit 290455a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: dtolnay/rust-toolchain@stable
15+
16+
- name: Verify tag matches Cargo.toml version
17+
run: |
18+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
19+
TAG_VERSION=${GITHUB_REF#refs/tags/}
20+
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
21+
echo "Tag $TAG_VERSION does not match Cargo.toml version $CARGO_VERSION"
22+
exit 1
23+
fi
24+
25+
- name: Publish
26+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)