Cargo subcommand `release`: everything about releasing a rust crate.

Overview

cargo release

Features

  • Ensure you are in a good state for release, including:
    • Right branch
    • Up-to-date with remote
    • Clean tree
  • Supports workspaces using cargo's native flags, like --workspace, --exclude and --package
    • Updates dependent crates in workspace when changing version
    • Change detection to help guide in what crates might not need a release
    • Optionally share commits
  • Handles cargo publish, tagging, and pushing
  • Pre-release search and replace for custom version updates, including
    • Updating changelogs
    • Update tags in Dockerfiles
  • Pre-release hook for extra customization, including

Install

Current release: 0.18.7

cargo install cargo-release

Usage

cargo release [level]

  • See the reference for more on level, other CLI arguments, and configuration file format.
  • See also the FAQ for help in figuring out how to adapt cargo-release to your workflow.

Prerequisite

  • Your project should be managed by git.

Dry run

By default, cargo-release runs in dry-run mode so you can safely run it and verify what it will do.

  • Increase the logging level with each additional -v to get more details
  • Speed up dry-run by skipping cargo-publishs verify step with --no-verify

Once you are ready, pass the --execute flag.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Wait between releases of workspace crates/Retry on failure

    Wait between releases of workspace crates/Retry on failure

    I just released a workspace, and cargo release failed to verify a tarball. The tarball was valid though, it was just that one of its dependencies was uploaded to crates.io only seconds before, which was apparently not enough for crates.io to process the dependency. Running publish on the same crate again after a few more seconds worked totally fine.

    The same effect occurred when doing a release completely manually without cargo release. Again, waiting a few seconds between releasing the two crates that depend on each other fixed the problem.

    Therefore I propose to not abort if a tarball fails to verify, but instead to wait a few seconds and try again.

    opened by sebschmi 46
  • Support Workspace Releases

    Support Workspace Releases

    In workspace projects, it is often desired to create coordinated releases with all package versions bumped at the same time. This includes upgrading versions in dependent crates. It would be great to have some sort of workspace flag, that performs all upgrades in a single commit (and tag).


    Maintainer Notes

    Steps

    • [x] Make core functionality independent of CWD
    • [x] Properly update lock file in a workspace
    • [x] #77 Verify / update corresponding version for path dependencies
    • [ ] Create clap-cargo to at least contain workspace flags, making the processing of cargo-metadata reusable for other plugins
    • [ ] #93 Figure out config semantics
    • [ ] Support processing workspaces
    enhancement 
    opened by jan-auer 17
  • Pre-release versioning incompatible with [patch]

    Pre-release versioning incompatible with [patch]

    Hey there,

    I'm not sure whether this is strictly an issue, but it took me some time to work out and seems like a bit of a pain.

    When cargo release X is run the version is bumped, the crate is published, then the version is again bumped to a development version. As cargo expects patch versions to match, this final bump means that you can no longer use [patch] overrides against the currently published library version for testing (without reverting the crate version in the patched crate's Cargo.toml).

    This results in errors like:

    warning: Patch `rr-mux v0.4.1-alpha.0 (/home/ryan/projects/rr-mux)` was not used in the crate graph.
    

    Where the project cargo.toml contains:

    [dependencies]
    rr-mux = "0.4.0"
    ...
    
    [patch.crates-io]
    rr-mux = { path = "../rr-mux" }
    

    One fix is to always run cargo release with --no-dev-version to avoid the problem.

    My suggestion would be that that the second development version bump should be opt in, I didn't expect it to happen, but, either way there's now some documentation for anyone else who has the same problem.

    opened by ryankurte 16
  • pre-release-commit-message template replacements don't seem to work

    pre-release-commit-message template replacements don't seem to work

    Hi there!

    I'm trying to adapt cargo-release to work for nextest. The nextest workspace consists of several crates, each with their own independent versioning.

    If I'd like to update one of nextest's crates, I'd like to be able to do:

    cargo release -p nextest-filtering 0.2.2 --execute
    

    and have a commit be created with the requisite version bumps and the message:

    [nextest-filtering] version 0.2.2
    

    and a signed tag created on this commit called nextest-filtering-0.2.2 with message:

    nextest-filtering version 0.2.2
    

    Here's my first attempt at configuring that, based on the reference:

    https://github.com/nextest-rs/nextest/blob/main/release.toml

    However, when I run:

    cargo release -p nextest-filtering 0.2.2 --execute
    

    the commit that gets created is:

    commit 49aaac68f9fae149b957ed79508e3551cd20d816 (HEAD -> main)
    Author: Rain <[email protected]>
    Date:   Fri Oct 14 12:23:50 2022 -0700
    
        [{{crate_name}} version {{version}}
    

    which indicates that template replacements aren't working.

    Any idea how to make them work?

    % cargo release --version
    cargo-release 0.21.4
    
    opened by sunshowers 15
  • `{{version}}` Should not include version metadata

    `{{version}}` Should not include version metadata

    Cargo supports having metadata in it's version numbers: https://doc.rust-lang.org/cargo/reference/resolver.html#version-metadata

    In the https://github.com/gfx-rs/rspirv/ crate we're using this to specify which upstream SPIR-V headers we're compiling against while keeping our own releases compatible with SemVer. However, cargo dependencies can't contain metadata information.

    So for example; a package has version of 0.1.0+1.54 for example, in it's Cargo.toml file, the version should still be listed as 0.1.0.

    Right now when we're using cargo release we specify the version number like so cargo release -- 0.1.0+1.54, however this populates the {{version}} regex replacement attribute with 0.1.0+1.54 which isn't valid in a lot of cases. Ideally it should strip everything after the + sign and emit that (or alternatively there ought to be a {{version_no_metadata}}.

    bug 
    opened by Jasper-Bekkers 14
  • workspace: when setting post-release, dependents not updated

    workspace: when setting post-release, dependents not updated

    With your help in the previous issue, I could cut a 0.5.0 release of chars, thanks for that! Unfortunately, the process failed when it was bumping the dev versions for the two crates:

    :;    cargo release minor --verbose
    [2020-03-20T13:38:50Z DEBUG] Files changed in chars_data since chars_data-v0.4.1: [
            "/Users/asf/Hacks/chars/chars_data/chars_data/Cargo.toml",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/entities/LICENSE",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/entities/README.md",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/entities/entities.json",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/entities/retrieve.sh",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/unicode/NameAliases.txt",
            "/Users/asf/Hacks/chars/chars_data/chars_data/data/unicode/UnicodeData.txt",
            "/Users/asf/Hacks/chars/chars_data/chars_data/src/ascii.rs",
            "/Users/asf/Hacks/chars/chars_data/chars_data/src/fst_generator.rs",
            "/Users/asf/Hacks/chars/chars_data/chars_data/src/unicode.rs",
        ]
    [2020-03-20T13:38:50Z DEBUG] Files changed in chars since v0.4.1: [
            "/Users/asf/Hacks/chars/chars/chars/Cargo.toml",
            "/Users/asf/Hacks/chars/chars/chars/release.toml",
            "/Users/asf/Hacks/chars/chars/chars/src/display.rs",
            "/Users/asf/Hacks/chars/chars/chars/src/unicode/mod.rs",
            "/Users/asf/Hacks/chars/chars/chars/tests/human_names.rs",
        ]
        ]
    Release
    Release
      chars_data 0.5.0
      chars 0.5.0
    ? [y/N]
    y
    [2020-03-20T13:38:53Z INFO ] Update chars_data to version 0.5.0
    [2020-03-20T13:38:53Z INFO ] Fixing chars's dependency on chars_data to `^0.5.0` (from `^0.4.1-dev`)
    [2020-03-20T13:38:53Z INFO ] Update chars to version 0.5.0
    [2020-03-20T13:38:54Z DEBUG] Substituting values for /Users/asf/Hacks/chars/chars/../CHANGELOG.md
    [2020-03-20T13:38:54Z DEBUG] Substituting values for /Users/asf/Hacks/chars/chars/../CHANGELOG.md
    [2020-03-20T13:38:54Z DEBUG] Substituting values for /Users/asf/Hacks/chars/chars/../CHANGELOG.md
    [master 08543b9] Release {{version}} ๐ŸŽ‰๐ŸŽ‰
     4 files changed, 8 insertions(+), 6 deletions(-)
    [2020-03-20T13:38:54Z INFO ] Running cargo publish on chars_data
        Updating crates.io index
       Packaging chars_data v0.5.0 (/Users/asf/Hacks/chars/chars_data)
       Verifying chars_data v0.5.0 (/Users/asf/Hacks/chars/chars_data)
       Compiling memchr v2.3.3
       Compiling fst v0.4.0
       Compiling lazy_static v1.4.0
       Compiling regex-syntax v0.6.17
       Compiling unicode-width v0.1.7
       Compiling quick-error v1.2.3
       Compiling unicode_names2 v0.4.0
       Compiling thread_local v1.0.1
       Compiling getopts v0.2.21
       Compiling aho-corasick v0.7.10
       Compiling regex v1.3.5
       Compiling regex v1.3.5
       Compiling chars_data v0.5.0 (/Users/asf/Hacks/chars/target/package/chars_data-0.5.0)
        Finished dev [unoptimized + debuginfo] target(s) in 24.07s
       Uploading chars_data v0.5.0 (/Users/asf/Hacks/chars/chars_data)
    [2020-03-20T13:39:47Z INFO ] Waiting for publish to complete...
    [2020-03-20T13:39:50Z INFO ] Running cargo publish on chars
        Updating crates.io index
       Packaging chars v0.5.0 (/Users/asf/Hacks/chars/chars)
       Verifying chars v0.5.0 (/Users/asf/Hacks/chars/chars)
      Downloaded chars_data v0.5.0
       Compiling memchr v2.3.3
       Compiling fst v0.4.0
       Compiling lazy_static v1.4.0
       Compiling unicode-width v0.1.7
       Compiling regex-syntax v0.6.17
       Compiling unicode_names2 v0.4.0
       Compiling quick-error v1.2.3
       Compiling byteorder v1.3.4
       Compiling thread_local v1.0.1
       Compiling getopts v0.2.21
       Compiling aho-corasick v0.7.10
       Compiling regex v1.3.5
       Compiling chars_data v0.5.0
       Compiling chars v0.5.0 (/Users/asf/Hacks/chars/target/package/chars-0.5.0)
        Finished dev [unoptimized + debuginfo] target(s) in 45.72s
       Uploading chars v0.5.0 (/Users/asf/Hacks/chars/chars)
    [2020-03-20T13:40:38Z INFO ] Waiting for publish to complete...
    [2020-03-20T13:40:44Z DEBUG] Creating git tag chars_data-v0.5.0
    [2020-03-20T13:40:44Z DEBUG] Creating git tag v0.5.0
    [2020-03-20T13:40:44Z INFO ] Starting chars_data's next development iteration 0.5.1-dev
    [2020-03-20T13:40:44Z WARN ] Fatal: Invalid TOML file format: Error during execution of `cargo metadata`: error: no matching package named `chars_data` found
        location searched: /Users/asf/Hacks/chars/chars_data
        prerelease package needs to be specified explicitly
        chars_data = { version = "0.5.1-dev" }
        required by package `chars v0.5.0 (/Users/asf/Hacks/chars/chars)
    

    So, looks like what's happening in that stage is:

    1. It bumps the version of chars_data to 0.5.1-dev
    2. It tries to bump the dependency in chars on chars_data to 0.5.1-dev
    3. at that point, cargo refuses to find dev release version dependencies with no exact match -> error

    I think I saw a cargo bug to that effect before, but I can't find it at the moment. I wonder if you can even do that bump with any in-flight versions of files. I imagine that the process might have to be:

    1. Bump the version of chars_data to 0.5.1-dev but keep the previous Cargo.toml in place (save the update to a temp file, probably?)
    2. Bump the dependency version in all dependent crates while cargo metadata still agrees, but also keep those old Cargo.toml files in place
    3. Move all the temp files into place
    bug 
    opened by antifuchs 14
  • Allow to set the time waited between two cargo publishs

    Allow to set the time waited between two cargo publishs

    This adds a command line parameter --publish-grace-sleep that defines how long we wait between two invocations of cargo publish. The default value is 5.

    opened by sebschmi 12
  • Verify / update corresponding version for path dependencies

    Verify / update corresponding version for path dependencies

    In a workspace, I need to define my dependencies as dep = { path = "../dep", version = "0.1.0" } but I forget (until cargo publish) to update the versions for my path dependencies (and it is really annoying).

    I think building this into cargo-release would be a big help.

    I view this as a subset of the work for #66. While that is for releasing an entire workspace, this will help with releasing parts of a workspace (and is needed for the entire workspace).

    Configuration

    • What to do on path dependency
      • verify
      • bump to latest (has to check crates.io because local path dependency has probably been bumped post-publish)
      • bump to semver compatible version
    enhancement 
    opened by epage 12
  • Releasing a workspace does not update local path dependencies

    Releasing a workspace does not update local path dependencies

    I have a workspace with multiple crates that depend on each other, with the dependency specified via a path. Before release, I had the following dependencies of the genome-graph crate:

    [dependencies]
    bigraph = {path = "../bigraph", version = "0.1.0-alpha.4"}
    compact-genome = {path = "../compact-genome", version = "0.1.0-alpha.4"}
    num-traits = "0.2"
    bio = "0.31"
    error-chain = "0.12"
    

    The version of bigraph in the workspace was 0.1.0-alpha.4. I then executed cargo release alpha on the workspace root, which bumped the versions of all crates and released them as expected. But it did NOT bump the versions in the [dependencies] sections. As a result, the released genome-graph crate has version 0.1.0-alpha.5, but still points to bigraph version 0.1.0-alpha.4, which is wrong.

    How do I get cargo-release to bump also the versions in the declaractions of [dependencies]?

    opened by sebschmi 11
  • The tool attempts to release many crates too rapidly

    The tool attempts to release many crates too rapidly

    error: failed to publish to registry at https://crates.io
    
    Caused by:
      the remote server responded with an error (status 429 Too Many Requests): You have published too many crates in a short period of time. Please try again after Thu, 30 Jun 2022 15:07:44 GMT or email [email protected] to have your limit increased.
    
    bug 
    opened by alexschrod 10
  • Error detecting clean working directory

    Error detecting clean working directory

    $ HEAD_OUTPUT=$(git diff HEAD --exit-code --name-only)
    $ echo Head Output=$HEAD_OUTPUT
    Head Output=
    $ LS_OUTPUT=$(git ls-files --exclude-standard --others)
    $ echo LS Output=$LS_OUTPUT
    LS Output=
    $ RUST_LOG=trace cargo release --no-confirm --no-dev-version --tag-name "{{crate_name}}-{{prev_version}}" -vv patch
    [2019-12-18T18:51:27Z WARN ] Uncommitted changes detected, please commit before release.
    

    Git status also indicates a clean working directory. Not sure what it is error'ing on.

    opened by dbcfd 10
  • cargo-release doesn't prevent publishing a package when it has unpublished registry dependencies

    cargo-release doesn't prevent publishing a package when it has unpublished registry dependencies

    If I run cargo release in the root of: https://github.com/kornelski/cavif-rs commit b2f707ce08bf758048cb967998df92d8dd3d2c7c

    https://github.com/kornelski/cavif-rs/tree/b2f707ce08bf758048cb967998df92d8dd3d2c7c/

    it chooses not to publish workspace's leaf dependency first (ravif), and then the root crate fails validation (cavif), because its dependency isn't published yet.

    $ cargo release
    warning: disabled by user, skipping ravif which has files changed since v1.4.0: [
        "./cavif/ravif/Cargo.toml",
        "./cavif/ravif/src/av1encoder.rs",
        "./cavif/ravif/src/dirtyalpha.rs",
        "./cavif/ravif/src/error.rs",
        "./cavif/ravif/src/lib.rs",
    ]
    warning: disabled by user, skipping ravif v0.9.3 despite being unpublished
      Publishing cavif
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   ./cavif/ravif/Cargo.toml
    workspace: ./cavif/Cargo.toml
        Updating crates.io index
       Packaging cavif v1.4.1 (./cavif)
    error: failed to prepare local package for uploading
    
    Caused by:
      failed to select a version for the requirement `ravif = "^0.9.2"`
      candidate versions found which didn't match: 0.9.1, 0.9.0, 0.8.9, ...
      location searched: crates.io index
      required by package `cavif v1.4.1 (./cavif)`
    

    I don't see why cargo-release thinks the dependency is "disabled by user".

    Using cargo-release 0.24.0 and rustc 1.65

    bug 
    opened by kornelski 4
  • Verification builds fail fetching dev dependency that isn't published yet

    Verification builds fail fetching dev dependency that isn't published yet

    I am publishing https://github.com/n0-computer/iroh using [email protected] but unfortunately it determines an incorrect order and aborts half way through: iroh-resolver is attempted to be published before iroh-store, which fails due to their dependency.

    bug 
    opened by dignifiedquire 4
  • Dry-run should warn of insufficient publishing permissions

    Dry-run should warn of insufficient publishing permissions

    Hey there!

    Earlier this week I was trying to release a series of crates from the ink! repository. I was able to successfully perform a dry run, but when I went to actually publish the release I ran into a permissions issue.

    Turns out I wasn't an owner of one of the crates and so I wasn't allowed to publish it.

    It would be great to have cargo-release print out a warning as part of the dry-run if you don't have sufficient permissions to publish a crate.

    Tested with [email protected].

    enhancement 
    opened by HCastano 1
  • Add an option to not error if nothing to publish (for idempotent operations)?

    Add an option to not error if nothing to publish (for idempotent operations)?

    Hi there --

    I noticed that cargo-release 0.22 changed things so that it's now an error if there's nothing to publish: https://github.com/crate-ci/cargo-release/commit/4783fda710e3f4543472c5aabb38cdfbc920930e

    I'm wondering if it would be possible to have a flag which makes it so that it no longer errors if there's nothing to publish. My use case is that I'm releasing a bunch of independently versioned crates and I'd like to move towards using cargo-release in CI to do the publishing. To avoid race conditions, I'd like the publish step of each crate to publish everything that can be published, to avoid race conditions between different release jobs. This is effectively an idempotent operation, which shouldn't fail if there's nothing to publish.

    Alternatively, I could potentially say that if the exit code is 2, treat it as success. Does the exit code 2 always mean "nothing to publish" as part of the documented command-line interface?

    Thanks!

    opened by sunshowers 7
  • Publish crates in parallel

    Publish crates in parallel

    For larger workspaces, this should offer some good savings, especially to overcome slow downs from waiting for crates to be published when nothing wait on them.

    We should look into using jobserver support in cargo to limit the parallel builds.

    enhancement 
    opened by epage 0
Releases(v0.24.2)
Owner
null
Cargo subcommand for running cargo without dev-dependencies.

cargo-no-dev-deps Cargo subcommand for running cargo without dev-dependencies. This is an extraction of the --no-dev-deps flag of cargo-hack to be use

Taiki Endo 5 Jan 12, 2023
a cargo subcommand for counting lines of code in Rust projects

cargo-count Linux: A cargo subcommand for displaying line counts of source code in projects, including a niave unsafe counter for Rust source files. T

Kevin K. 125 Dec 1, 2022
A very simple third-party cargo subcommand to execute a custom command

cargo-x A very simple third-party cargo subcommand to execute a custom command Usage install cargo-x cargo install cargo-x or upgrade cargo install -

ๅˆ˜ๅ†ฒ 9 Dec 26, 2022
Cargo script subcommand

cargo-script cargo-script is a Cargo subcommand designed to let people quickly and easily run Rust "scripts" which can make use of Cargo's package eco

Daniel Keep 643 Jan 3, 2023
A cargo subcommand for checking and applying updates to installed executables

cargo-update A cargo subcommand for checking and applying updates to installed executables Documentation Manpage Installation Firstly, ensure you have

ะฝะฐะฑ 827 Jan 4, 2023
A cargo subcommand that displays ghidra function output through the use of the rizin rz-ghidra project.

cargo-rz-ghidra A cargo subcommand that displays ghidra function output through the use of the rizin rz-ghidra project. Install cargo install --git ht

wcampbell 4 Nov 5, 2022
Cargo subcommand to easily run targets/examples

cargo-select Cargo subcommand to easily run targets/examples/tests Fuzzy match against targets, examples or tests in current rust project. cargo-selec

null 13 Sep 15, 2022
Cargo-about - ๐Ÿ“œ Cargo plugin to generate list of all licenses for a crate ๐Ÿฆ€

?? cargo-about Cargo plugin for generating a license listing for all dependencies of a crate See the book ?? for in-depth documentation. Please Note:

Embark 281 Jan 1, 2023
A port of everything to Rust ๐Ÿฆ€

everything.rs Do you ever feel like washing your hands after a coding session, disgusted at having to use essential Unix utilities with not the tinies

null 8 Apr 17, 2023
fas stand for Find all stuff and it's a go app that simplify the find command and allow you to easily search everything you nedd

fas fas stands for Find all stuff and it's a rust app that simplify the find command and allow you to easily search everything you need. Note: current

M4jrT0m 1 Dec 24, 2021
Incredible.dev is an AI Coding Co-worker which can code, fix, document, deploy, test your APIs. One agent to rule everything API.

Incredible.dev Early Github preview, documentation and instruction to run coming soon in a week! Here are some highlights: AI agents that can code, fi

Incredible 27 Jun 27, 2024
Local-first task manager/bug tracker that stores everything right in the git repository and can sync issues from/to GitHub.

git-task Local-first task manager/bug tracker within your git repository which can import issues from GitHub. Installation Build a binary, then add it

null 15 Sep 28, 2024
Cargo-eval - A cargo plugin to quickly evaluate some Rust source code.

cargo eval A cargo plugin to quickly evaluate some Rust source code. Installation $ cargo install --git https://github.com/timClicks/cargo-eval.git Us

Tim McNamara 9 Dec 21, 2022
Integrate a Rust project with semantic-release

semantic-release-cargo semantic-release-cargo integrates a cargo-based Rust project with semantic-release. This solves two use cases: publishing to cr

null 5 Jan 16, 2023
Rust-powered CLI tool designed to simplify and streamline the release process with help of ChatGPT

$ releasecraftsman ????โ€โ™‚๏ธ?? Automate Your Release Process with Precision and Ease. ?? Features Generate well-crafted release notes using GPT-3.5 and

Tornike Gomareli 7 Sep 21, 2023
๐Ÿš€ JavaScript driver for ScyllaDB, harnessing Rust's power through napi-rs for top performance. Pre-release stage. ๐Ÿงช๐Ÿ”ง

?? JavaScript driver for ScyllaDB. Pre-release stage. ???? โš ๏ธ Disclaimer โš ๏ธ This repository and the associated npm package are currently in a ?? pre-r

Daniel Boll 16 Oct 21, 2023
A cargo plugin to shrink cargo's output

cargo single-line A simple cargo plugin that shrinks the visible cargo output to a single line (okay, in the best case scenario). In principle, the pl

Denis 5 Oct 30, 2022
(Pre-Release Software) Secure, Encrypted, P2P chat written atop Warp, IPFS, LibP2P, Dioxus and many more awesome projects and protocols.

Uplink Privacy First, Modular, P2P messaging client built atop Warp. Uplink is written in pure Rust with a UI in Dioxus (which is also written in Rust

Satellite 13 Jan 25, 2023
A gui tool written in Dioxus to make it easy to release a workspace of crates to crates.io

Easy-Release: a visual tool for releasing workspaces of libraries A work-in-progress GUI for releasing a large workspace of crates manually, but easil

Jon Kelley 13 Jan 18, 2023