Rust Cargo Authentication

Publish Rust crates to crates.io

Option 1: Pass Token as Input

- uses: a-line-services/release-pilot@v1
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    cargo-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Getting a crates.io Token

  1. Go to crates.io/settings/tokens
  2. Click "New Token"
  3. Give it a name (e.g., "GitHub Actions")
  4. Select scopes: publish-new and publish-update
  5. Copy the token and add it as CARGO_REGISTRY_TOKEN secret in your repo

Option 2: Pre-configure Credentials

If you prefer to configure credentials manually:

- name: Configure Cargo credentials
  run: |
    mkdir -p ~/.cargo
    cat > ~/.cargo/credentials.toml << EOF
    [registry]
    token = "${{ secrets.CARGO_REGISTRY_TOKEN }}"
    EOF

- uses: a-line-services/release-pilot@v1
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}

Option 3: Environment Variable

Cargo also respects the CARGO_REGISTRY_TOKEN environment variable:

- uses: a-line-services/release-pilot@v1
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
  env:
    CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Publishing Requirements

Before Publishing

Ensure your Cargo.toml has all required fields:

[package]
name = "your-crate"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "A short description"
repository = "https://github.com/you/your-crate"

Workspaces

For Cargo workspaces, configure each crate as a separate package:

# .github/release-pilot.yml
packages:
  - name: core
    ecosystem: cargo
    path: ./crates/core

  - name: cli
    ecosystem: cargo
    path: ./crates/cli

releaseOrder:
  - core
  - cli

Inputs Reference

Input Description Default
cargo-token crates.io API token -