Cargo Releases

This page documents deployments using the next major version dpl v2, which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Be sure to read the v2 deployment overview.

Travis CI can automatically release your Rust crate to crates.io after a successful build.

For a minimal configuration, add the following to your .travis.yml:

deploy:
  provider: cargo
  token: <encrypted token>
  edge: true # opt in to dpl v2

The API token can be obtained by logging in to your crates.io account, and generating a new token at https://crates.io/me.

Status #

Support for deployments to Cargo is *stable**.

Known options #

Use the following options to further configure the deployment.

token Cargo registry API token — required, secret, type: string
allow_dirty Allow publishing from a dirty git working directory — type: boolean

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Environment variables #

All options can be given as environment variables if prefixed with CARGO_.

For example, token can be given as CARGO_TOKEN=<token>.

Securing secrets #

Secret option values should be given as either encrypted strings in your build configuration (.travis.yml file) or environment variables in your repository settings.

Environment variables can be set on the settings page of your repository, or using travis env set:

travis env set CARGO_TOKEN <token>

In order to encrypt option values when adding them to your .travis.yml file use travis encrypt:

travis encrypt <token>

Or use --add to directly add it to your .travis.yml file. Note that this command has to be run in your repository’s root directory:

travis encrypt --add deploy.token <token>

Deploying tags #

Most likely, you would only want to deploy when a new version of your package is cut.

To do this, you can include a tags condition like so:

deploy:
  provider: cargo
  # ⋮
  on:
    tags: true

If you tag a commit locally, remember to run git push --tags to ensure that your tags are uploaded to GitHub.

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #