Skip to content

Commit c171ca1

Browse files
committed
chore: automated crates.io publishing
1 parent cbfd384 commit c171ca1

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
publish:
12+
name: Publish
13+
runs-on: ubuntu-latest
14+
environment: crates-io
15+
permissions:
16+
id-token: write
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- uses: dtolnay/rust-toolchain@stable
24+
25+
- name: Install protoc
26+
uses: arduino/setup-protoc@v3
27+
with:
28+
version: "27.x"
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Verify version matches tag
32+
run: |
33+
CARGO_VERSION="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
34+
TAG_VERSION="${GITHUB_REF_NAME#v}"
35+
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
36+
echo "::error::Cargo.toml version ($CARGO_VERSION) does not match release tag ($TAG_VERSION)"
37+
exit 1
38+
fi
39+
40+
- name: Publish to crates.io
41+
run: cargo publish

0 commit comments

Comments
 (0)