Publish Rust SDKs automatically
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.tomlincludes required metadata such asdescriptionandlicense(orlicense-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:
- Sign in at crates.io and select Account Settings > API Tokens > New Token.
- Create a token with
publish-updatescope. Addpublish-newfor first publish of a new crate. - Restrict the token to this crate name when possible.
- Copy the token (starts with
cio...). It’s shown only once. - In GitHub, select your repository and click Settings > Secrets and variables > Actions > New repository secret. Name it
CARGO_REGISTRY_TOKENand paste the token.
Publishing to crates.io is permanent. Versions cannot be deleted. Use cargo yank to prevent new dependents from selecting a version.