Skip to content

Commit e138697

Browse files
authored
chore: add trusted-publisher crates.io release job (#3)
## What changed Adds a separate crates.io publish job to the tag-driven release workflow while keeping the existing WASM GitHub release flow intact. ## Why We want crates.io publishing to follow the `unfmt` trusted-publisher pattern instead of using a long-lived registry token. ## Impact Tag releases will still verify, build, and upload WASM assets, then run a dedicated crates.io publish job authenticated through GitHub OIDC and `rust-lang/crates-io-auth-action`. ## Validation - Reviewed the workflow diff for job ordering and permissions - Ran `cargo publish --dry-run --locked --allow-dirty` successfully
1 parent 140946a commit e138697

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,33 @@ jobs:
125125
dist/sqlc-gen-sqlx.wasm \
126126
dist/sqlc-gen-sqlx.wasm.sha256 \
127127
--clobber
128+
129+
publish-crate:
130+
name: Publish to crates.io
131+
needs: publish-release
132+
runs-on: ubuntu-latest
133+
environment: release
134+
permissions:
135+
contents: read
136+
id-token: write
137+
138+
steps:
139+
- name: Checkout
140+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
141+
142+
- name: Install Rust toolchain
143+
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
144+
with:
145+
toolchain: stable
146+
147+
- name: Cache cargo artifacts
148+
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
149+
150+
- name: Authenticate with crates.io
151+
id: crates-io-auth
152+
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
153+
154+
- name: Publish crate
155+
run: cargo publish --locked
156+
env:
157+
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}

0 commit comments

Comments
 (0)