Skip to content

Commit caa2c91

Browse files
chrisguidryclaude
andauthored
Pin the crates.io publish job's actions and document every feature (#525)
The publish job holds a crates.io token, so its actions are pinned to commits, and a tag that moves cannot change what runs there; Dependabot keeps the pins current. docs.rs builds docket-rs with every feature, so `memory://` and the CLI options appear in its documentation. crates.io trusts a workflow only after the crate exists, so the first release needs a token. The job uses the `crates-io` environment's `CARGO_REGISTRY_TOKEN` secret when it exists, and trusted publishing once that secret is deleted. The `crates-io` environment requires approval and accepts only `rust/v*` tags, and a ruleset protects those tags. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Y2QtufEUxxm9XgTqCWySHG --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c8e175f commit caa2c91

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎.github/workflows/publish-rust.yml‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ jobs:
2626
permissions:
2727
id-token: write # Required for trusted publishing
2828
contents: read
29+
env:
30+
# Only whether the secret exists, never its value.
31+
HAS_BOOTSTRAP_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN != '' }}
2932
defaults:
3033
run:
3134
working-directory: rust
35+
# This job holds a publish token, so its actions are pinned to commits:
36+
# a tag that moves cannot change what runs here.
3237
steps:
33-
- uses: actions/checkout@v7
38+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3439

35-
- uses: dtolnay/rust-toolchain@stable
40+
- uses: dtolnay/rust-toolchain@89b12181fb390509a0842a86cc55eeb8eb928c1d # stable
3641

3742
# Cargo takes the version from Cargo.toml, not from the tag, so the
3843
# two must agree before anything is published.
@@ -46,16 +51,19 @@ jobs:
4651
exit 1
4752
fi
4853
49-
# crates.io trusts this workflow only after the first release, which
50-
# someone publishes by hand with a token.
51-
- uses: rust-lang/crates-io-auth-action@v1
54+
# crates.io trusts this workflow only after the first release. That
55+
# release uses a short-lived token in the environment's
56+
# CARGO_REGISTRY_TOKEN secret, which is deleted once trusted publishing
57+
# works.
58+
- uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
5259
id: auth
60+
if: env.HAS_BOOTSTRAP_TOKEN != 'true'
5361

5462
# docket-rs depends on the exact version of docket-rs-macros, so the
5563
# macros go first.
5664
- name: Publish
5765
env:
58-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
66+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN || steps.auth.outputs.token }}
5967
run: |
6068
cargo publish --locked --package docket-rs-macros
6169
cargo publish --locked --package docket-rs

‎rust/docket/Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,10 @@ sha1 = "0.10"
5252
rstest = "0.27.0"
5353
tokio = { version = "1.53.2", features = ["macros", "rt-multi-thread", "test-util"] }
5454

55+
[package.metadata.docs.rs]
56+
# docs.rs builds the crate once, so it turns on every feature to document
57+
# memory:// and the CLI options too.
58+
all-features = true
59+
5560
[lints]
5661
workspace = true

0 commit comments

Comments
 (0)