--- name: release-rust description: > Create and publish a new release of the Rust project. Handles version bumping, changelog, tagging, and GitHub Release creation via CI. Use when preparing a release, tagging a version, or publishing to crates.io. Triggers: "release", "publish crate", "new version", "bump version". license: MIT metadata: category: rust author: d-oit version: "1.0" tags: rust release publish crates semantic-versioning --- # Skill: release-rust ## Purpose Create and publish a new release of the Rust project. ## Prerequisites - All CI checks pass on main - `CHANGELOG.md` updated - `cargo-dist` installed ## Steps ### 0. Verify crate name availability on crates.io (FIRST TIME PUBLISH ONLY) Before the very first publish, confirm the crate name is not already taken: ```bash # Check via cargo search cargo search # Or via API (404 = available, 200 = taken) curl -s https://crates.io/api/v1/crates/ | python3 -m json.tool | grep '"name"' # Or open in browser: https://crates.io/crates/ ``` > See `.agents/skills/crates-io-name-check/SKILL.md` for full naming guidance and best practices. **Do not proceed with publishing if the name is taken — choose a unique name first.** ### 1. Pre-release checks ```bash cargo fmt --all -- --check cargo clippy --workspace --all-targets --all-features -- -D warnings cargo nextest run --all-features cargo audit && cargo deny check ``` ### 2. Bump the workspace version ```bash ./scripts/bump-version.sh # dry-run: print planned changes ./scripts/bump-version.sh --execute # update VERSION, manifests, README, CHANGELOG ``` ### 3. Commit and tag ```bash git add Cargo.toml Cargo.lock CHANGELOG.md git commit -m "chore: release vX.Y.Z" git tag -a vX.Y.Z -m "Release vX.Y.Z" git push origin main --tags ``` ### 4. GitHub Release via CI Pushing a tag triggers `.github/workflows/release.yml`: - **Release Preflight**: Verifies that the tag matches `v$(cat VERSION)`, checks that the release does not already exist, and asserts manifest consistency. - **Release Gates**: Runs release-tier quality checks. - **Changelog**: Generated using `git-cliff` as the canonical source of truth for release notes. - **Dist Build**: Builds binaries for all targets via cargo-dist with CycloneDX SBOM and cargo-auditable. - **Attestations**: Generates signed GitHub build provenance attestations for all release artifacts. - **Creates GitHub Release**: Publishes the release with assets. - **Publishes crates.io packages**: Runs only for the explicit allowlist in `config/trusted-publishing.json`, using `rust-lang/crates-io-auth-action` under the `release` environment. See [Trusted Publishing](#cratesio-trusted-publishing). ### 5. Verifying Release Attestations Consumers can verify artifact integrity and build provenance using the GitHub CLI: ```bash gh attestation verify --owner d-oit ``` ## crates.io Trusted Publishing Publication is opt-in and package-scoped. The allowlist and OIDC identity live in `config/trusted-publishing.json`; `publish = false` packages are never selected. Full lifecycle, API contract, troubleshooting, and rollback: [`docs/src/releasing/crates-io-trusted-publishing.md`](../../../docs/src/releasing/crates-io-trusted-publishing.md). Tools and commands: ```bash ./scripts/trustpub.sh plan # read-only tuple + dependency order ./scripts/trustpub.sh list --all-configured # current registrations ./scripts/trustpub.sh configure --package X --yes ./scripts/trustpub.sh verify --all-configured ./scripts/trustpub.sh bootstrap --package X # one-time initial publish ./scripts/trustpub.sh require --package X --enabled --confirm-oidc-publish --yes ``` Rules: - The token comes only from `CARGO_REGISTRY_TOKEN` (scope `trusted-publishing`; add `publish-new` for bootstrap). Never print it, store it, or pass it as an argument. - crates.io requires an initial published version before a publisher can be registered; `bootstrap` is the only command that publishes a first version. - Registering a publisher does not enable enforcement. Enable trusted-publishing-only only after a successful OIDC release. - There is no stable `cargo trustpub` subcommand; do not recommend one. `cargo#17114` is an open proposal. - The action is a workflow dependency, not an Agent Skill; verify its pin per `.agents/skills/verify-actions/SKILL.md`. ## Version Scheme - `MAJOR.MINOR.PATCH` (Semantic Versioning) - Breaking = MAJOR, features = MINOR, fixes = PATCH ## Success Criteria - Tag on GitHub - Release with binaries created - CHANGELOG updated - Crate name verified unique on crates.io (first publish) - Allowlisted crates published by the OIDC job, or the allowlist is explicitly empty ## Rationalizations | Rationalization | Reality | |-----------------|---------| | "I'll skip the pre-release checks to save time." | Publishing broken code breaks downstream users. Always run the full check suite. | | "The changelog can be updated after release." | Users read the changelog to understand what changed. Update it before tagging. | | "I'll just push the tag directly." | Use `git tag -a` with a message. Tags without messages are unhelpful in history. | ## Red Flags - [ ] Pushing a tag without running pre-release checks - [ ] Bumping the version without updating CHANGELOG.md - [ ] Publishing to crates.io without verifying crate name availability - [ ] Publishing a crate that is absent from the allowlist or marked `publish = false` - [ ] Adding a long-lived `CARGO_REGISTRY_TOKEN` secret instead of OIDC - [ ] Enabling trusted-publishing-only before a successful OIDC release ## References - [cargo-dist](https://opensource.axo.dev/cargo-dist/) - [Keep a Changelog](https://keepachangelog.com/) - [crates.io naming policy](https://crates.io/policies) - [crates.io Trusted Publishing](https://crates.io/docs/trusted-publishing) - [rust-lang/crates-io-auth-action](https://github.com/rust-lang/crates-io-auth-action) ## GH CLI Usage Post-release failure tracking uses `gh issue create` directly: ```bash # Create a DORA FDRT tracking issue on release failure gh issue create \ --title "🚨 Release vX.Y.Z failed post-release health check" \ --label "hotfix,release-failure" \ --body-file .github/ISSUE_TEMPLATE/release-failure.md ``` This is preferred over `actions/github-script` for single-purpose issue creation.