diff --git a/src/guide/README.md b/src/guide/README.md index 9f14d9e..dcfb33f 100644 --- a/src/guide/README.md +++ b/src/guide/README.md @@ -756,6 +756,54 @@ pre_bump_hooks = [ ``` ::: +### Bump hook recipes + +#### Cargo library projects + +A recipe for Cargo projects with a git-ignored `Cargo.lock` file, aka library projects. + +Prerequisites: + +- `cargo-edit` + +Hooks: + +```toml +pre_bump_hooks = [ + "cargo build --release", # verify the project builds + "cargo set-version {{version}}", # bump version in Cargo.toml +] +post_bump_hooks = [ + "git push", + "git push {{version}}", +] +``` + +#### Cargo executable projects + +A recipe for Cargo projects with a managed `Cargo.lock` file, aka executable projects. +Notably, the version bump is also included in the lockfile by running `cargo check` +and then staging the change before creating the bump commit. + +Prerequisites: + +- `cargo-edit` + +Hooks: + +```toml +pre_bump_hooks = [ + "cargo build --release", # verify the project builds + "cargo set-version {{version}}", # bump version in Cargo.toml + "cargo check --release", + "git add :/Cargo.lock", # stage version bump in Cargo.lock +] +post_bump_hooks = [ + "git push", + "git push {{version}}", +] +``` + ## Tag prefix It is common to use a tag prefix when creating version in your repository. This is described in the [SemVer specification