Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions crate_release_strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ We use [cargo-release](https://github.com/crate-ci/cargo-release) to help us bum
`release.toml`:
```toml
pre-release-commit-message = "Release {{version}}"
dev-version = false
tag-message = "Release {{version}}"
tag-name = "{{version}}"
sign-commit = true
Expand All @@ -21,14 +20,31 @@ pre-release-replacements = [
]
```

If your crate consists of a `[workspace]` with multiple crates, but you only wish to publish the root crate or keep all crate versions in sync, add the following configuration to make sure `cargo-release` substitutes `{{version}}` in the templates above:

```toml
# cargo-release only allows using {{version}} in the commit title when creating one
# commit across all released packages in this workspace (we only release one package
# though), or by using the same version for all packages.
# https://github.com/crate-ci/cargo-release/issues/540#issuecomment-1328769105
# https://github.com/crate-ci/cargo-release/commit/3af94caa4b9bbee010a5cf3f196cc4afffbaf192
consolidate-commits = false
shared-version = true
```

With that, a developer performs a release on their local machine with:

```console
$ cargo install cargo-release
$ cargo release "<next version>"
```

(Only add `-x` if you are okay with the changes!)

#### Creating a release on GitHub

While [the CI process](###the-automated-ci-process) runs, click `Draft a new release` on the `releases` page on GitHub. Select the tag matching the version just pushed by `cargo-release` above, and click `Generate release notes` to automatically populate the title and description. Modify both as necessary. In particular, release notes convey user-facing changes: remove internal changes such as clippy fixes and other cleanups. When breaking changes are made or new features are added, spend an extra paragraph at the top detailing how users should migrate to or make use of the new release 🥳!

### The automated CI process

This process is complemented by a CI workflow to perform the actual `cargo publish` to https://crates.io, and makes it so that not every developer needs to have direct access to the crates account nor a token for it. This workflow is triggered by tag pushes only (but could also be invoked on every push to `main`, which is a no-op if the version wasn't bumped) and simply performs the publishing step using a secret token stored with GitHub:
Expand Down Expand Up @@ -61,4 +77,4 @@ jobs:

### Future improvements

The `cargo-release` process requires push access to `main` and push access for tags. Over time it'd be great if a `cargo-release` result (together with perhaps any other relevant changes) can be PR'd, and automatically released (+ pushing a new tag) directly frm the CI as soon as it is merged.
The `cargo-release` process requires push access to `main` and push access for tags. Over time it'd be great if a `cargo-release` result (together with perhaps any other relevant changes) can be PR'd, and automatically released (+ pushing a new tag) directly frm the CI as soon as it is merged.