Skip to content

Commit 563acd1

Browse files
committed
add sample github action for crates.io publishing
Add a github action sample workflow file for auto-publishing crates on creation of 'v*' tags. The sample workflow assumes a non-workspace setup, so that cargo publish can be run from the repository root (= crate root). For multi-crate repositories, repository_setup.sh will generate derivatives of this file. There is a useless `cd .` in the `run` step which only exists so that sed can easily replace it with the path for crates in a workspace when auto-generating workflows. Signed-off-by: Patrick Roy <[email protected]>
1 parent ad2d96b commit 563acd1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
tags: ['v*'] # Triggers when pushing version tags
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
# environment: release # Optional: for enhanced security
11+
permissions:
12+
id-token: write # Required for OIDC token exchange
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: rust-lang/crates-io-auth-action@v1
16+
id: auth
17+
- run: |
18+
cd .
19+
cargo publish
20+
env:
21+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

0 commit comments

Comments
 (0)