From f2a0660a9b60b70af32f1157dc78cdfcb298c9f7 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 17 Aug 2026 16:21:02 +0200 Subject: fix(make): release must not abort when the version bump is a no-op Cutting a version whose files already carry it -- which is how the first tag went, and what any re-run after a failed gate looks like -- leaves nothing staged, and git commit aborts the target on "nothing to commit" despite everything being in order. The commit is now conditional on something actually being staged, and an existing tag is refused explicitly rather than surfacing as a bare git error. --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f90d32e..1d14437 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,14 @@ release: ## cut a release: make release VERSION=0.1.0 (add its CHANGELOG line f $(MAKE) check @test "$$($(DUNE) dune exec --no-build colitur -- --version)" = "$(VERSION)" || \ { echo "the built binary does not report $(VERSION)" >&2; exit 2; } - git add dune-project colitur.opam bin/main.ml CHANGELOG.md - git commit -m "release: v$(VERSION)" + @git add dune-project colitur.opam bin/main.ml CHANGELOG.md + @# Only commit if the bump actually changed something. Re-running release + @# after a failed gate -- or cutting a version whose files are already + @# correct, which is exactly how the first tag went -- leaves nothing + @# staged, and `git commit` would abort the whole target on "nothing to + @# commit" despite everything being in order. + @git diff --cached --quiet || git commit -m "release: v$(VERSION)" + @git rev-parse -q --verify "refs/tags/v$(VERSION)" >/dev/null && \ + { echo "tag v$(VERSION) already exists; delete it first to re-cut" >&2; exit 2; } || true git tag -a "v$(VERSION)" -m "colitur $(VERSION)" @echo "tagged v$(VERSION). publish with: git push origin main v$(VERSION)" -- cgit v1.3