Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

ci: publish to crates.io via trusted publishing (#3564)

Maximilian Roos481125801f5f
diff --git a/.github/CLAUDE.md b/.github/CLAUDE.md
index 8e1151bf4..a7e32a6cb 100644
--- a/.github/CLAUDE.md
+++ b/.github/CLAUDE.md
@@ -25,9 +25,12 @@ Only the repo owner (`@max-sixty`, admin) can merge to `main`.
## Environment protection
-`CARGO_REGISTRY_TOKEN` and `AUR_SSH_PRIVATE_KEY` are in a protected GitHub
-Environment (`release`) requiring deployment approval from `@max-sixty`,
-restricted to `v*` tags.
+`AUR_SSH_PRIVATE_KEY` is in a protected GitHub Environment (`release`) requiring
+deployment approval from `@max-sixty`, restricted to `v*` tags.
+
+crates.io publishing holds no stored token — it uses Trusted Publishing.
+crates.io mints a short-lived one only for an OIDC claim from `release.yaml`
+running in that same `release` environment.
## Build environment
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index dba1688c5..7f24714d5 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -330,18 +330,29 @@ jobs:
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
+ # Auth is via crates.io Trusted Publishing (GitHub Actions OIDC): the job mints
+ # a short-lived, auto-revoked token per run instead of a long-lived API token.
+ # This requires a Trusted Publisher to be configured for the crate on
+ # crates.io, scoped to this repo, the `release.yaml` workflow, and the
+ # `release` environment.
publish-cargo:
needs:
- plan
- host
runs-on: ubuntu-24.04
environment: release
+ permissions:
+ contents: read
+ id-token: write
if: ${{ needs.plan.outputs.publishing == 'true' }}
steps:
- uses: actions/checkout@v7
+ - name: Authenticate with crates.io
+ id: auth
+ uses: rust-lang/crates-io-auth-action@v1
- name: Publish to crates.io
env:
- CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --package worktrunk
publish-winget: