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: Release
# Triggered by Rafael publishing the GitHub Release (UI or `gh release create`).
# This workflow does NOT create the release — it only publishes the crate to
# crates.io.
#
# crates.io publishes are IRREVERSIBLE. `cargo yank` exists but the version
# number is permanently burned. PR CI is the gate for catching issues before
# this workflow ever runs.
on:
release:
types:
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "::error::CARGO_REGISTRY_TOKEN secret is not configured in repo settings"
exit 1
fi
cargo publish --token "$CARGO_REGISTRY_TOKEN"