From ef62b57a08d4486f2f382780af7b8a59fd06eeff Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Tue, 1 Sep 2026 19:26:22 +0200 Subject: [PATCH] fix(release): skip the changelog hook during a dry run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `just release-plan` is documented as a preview that writes nothing, but cargo-release runs pre-release hooks during a dry run too. The hook wrote CHANGELOG.md and `git add`ed it, so the clean-tree check in `just release` then refused to run — the repo's own two-step release workflow could not be followed as written. Guard the hook on DRY_RUN, which cargo-release 1.1.5 exports to the hook environment (verified by dumping `env` from a throwaway hook; it also sets CRATE_NAME, PREV_VERSION and NEW_VERSION). The clean-tree check itself is left alone: it is load-bearing, because publishing is irreversible. Closes #36 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014b6wy2q8rnFK8U8GPJVQNU --- release.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/release.toml b/release.toml index 9fcce4e..f15374a 100644 --- a/release.toml +++ b/release.toml @@ -3,4 +3,12 @@ publish = true # Hold off pushing until tags and publish have both succeeded; `just release` # pushes last. push = false -pre-release-hook = ["sh", "-c", "git cliff -o CHANGELOG.md --tag {{version}} && git add CHANGELOG.md"] +# Regenerate the changelog and stage it so it lands in the release commit. +# +# Guarded on DRY_RUN because cargo-release runs pre-release hooks during a dry +# run too (verified against cargo-release 1.1.5, which exports DRY_RUN=true, +# CRATE_NAME, PREV_VERSION and NEW_VERSION to the hook). Without the guard, +# `just release-plan` — documented as a preview that writes nothing — writes and +# `git add`s CHANGELOG.md, and the clean-tree check in `just release` then +# refuses to run. That check is load-bearing: publishing is irreversible. +pre-release-hook = ["sh", "-c", '[ "$DRY_RUN" = "true" ] || (git cliff -o CHANGELOG.md --tag {{version}} && git add CHANGELOG.md)']