Publish Rust SDKs automatically

View as Markdown

You can publish SDKs generated in Postman to crates.io. Automated publishing is supported through GitHub Actions, which can be configured to publish your SDKs to crates.io whenever a new release is created in your GitHub repository. By default, the predefined workflow creates a new release every time an automatic PR is merged.

You can also publish manually from your local machine. To learn more, see Publish Rust SDKs manually.

To publish your SDKs automatically, use a crates.io API token stored in GitHub secrets.

Prerequisites

  • A crates.io account.
  • A verified email on the account. crates.io refuses to publish without it.
  • The crate name is available, or you are an owner. Names are global and first-come, first-served.
  • Cargo.toml includes required metadata such as description and license (or license-file).

Create a crates.io API token and add it to your GitHub repo

A crates.io token (CARGO_REGISTRY_TOKEN) is used for authentication with the cargo publish command.

To create a crates.io API token and add it to your GitHub repo, do the following:

  1. Sign in at crates.io and select Account Settings > API Tokens > New Token.
  2. Create a token with publish-update scope. Add publish-new for first publish of a new crate.
  3. Restrict the token to this crate name when possible.
  4. Copy the token (starts with cio...). It’s shown only once.
  5. In GitHub, select your repository and click Settings > Secrets and variables > Actions > New repository secret. Name it CARGO_REGISTRY_TOKEN and paste the token.

Publishing to crates.io is permanent. Versions cannot be deleted. Use cargo yank to prevent new dependents from selecting a version.