Skip to content

Commit c8d9c8e

Browse files
committed
ci: add GitHub Actions workflow to publish crate on tag push
- Add `publish.yml` to automate publishing to crates.io - Trigger release on 'v*' tag creation
1 parent d5aceee commit c8d9c8e

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v5
15+
16+
- name: Cache Rust dependencies
17+
uses: Swatinem/rust-cache@v2
18+
with:
19+
# Only save in the main branch.
20+
save-if: ${{ github.ref == 'refs/heads/main' }}
21+
22+
# Similar to cache-all-crates.
23+
# If `true` the workspace crates will be cached.
24+
# Useful if the workspace contains libraries that are only updated sporadically.
25+
# default: "false"
26+
cache-workspace-crates: true
27+
28+
# Determines which crates are cached.
29+
# If `true` all crates will be cached, otherwise only dependent crates will be cached.
30+
# Useful if additional crates are used for CI tooling.
31+
# default: "false"
32+
cache-all-crates: true
33+
34+
# Determines whether workspace `target` directories are cached.
35+
# If `false`, only the cargo registry will be cached.
36+
# default: "true"
37+
cache-targets: true
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Build (trigger cache usage)
43+
run: cargo check --workspace --all-targets
44+
45+
- name: Login to crates.io
46+
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
47+
48+
- name: Publish all crates
49+
run: cargo publish --all --allow-dirty
50+
env:
51+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

0 commit comments

Comments
 (0)