summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-17 16:19:02 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-17 16:19:02 +0200
commitcc6655134e155dd0879ecb8eb009271e17488834 (patch)
tree31dc6c6be64f03d02a1067644e04e904d7312167 /Makefile
parent7055723f8b79240ab2df1353eaaf3761f65414a9 (diff)
downloadcolitur-cc6655134e155dd0879ecb8eb009271e17488834.tar.gz
colitur-cc6655134e155dd0879ecb8eb009271e17488834.zip
feat(cli): --version, a CHANGELOG, and a release target
Groundwork for tagging. The project had no version anywhere: not in dune-project, not in the binary, no CHANGELOG, no tags. The version lives in two places -- dune-project, which generates colitur.opam, and a constant in bin/main.ml, which is what --version prints. Two rather than one because dune's watermarking only substitutes in a release tarball, so a binary built the ordinary way from a checkout would report a placeholder. The release target rewrites both and then re-checks both, and finally requires the freshly built binary to report the version it just wrote: a release that bumped one and not the other would ship a binary disagreeing with its own package metadata. --version is deliberately not embedded in the help text. cli.t pins help's first line, and a version there would mean editing a test expectation every release for no gain. The release target mirrors lectio's, refusals included: no release from a dirty tree, none without a CHANGELOG entry for that version, none whose version bump silently failed to apply, and `make check` -- the full 1583-9999 sweep, not the sampling suite -- must pass before the tag is created.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 25 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 75372ac..f90d32e 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ MANDIR := $(PREFIX)/share/man/man1
# over documenting the dune commands.
DUNE := opam exec --
-.PHONY: help build test check install uninstall reinstall clean fmt man doc
+.PHONY: help build test check install uninstall reinstall clean fmt man doc release
help: ## show this help
@grep -hE '^[a-z-]+:.*##' $(MAKEFILE_LIST) | sed -E 's/:.*## /\t/' | sort
@@ -53,3 +53,27 @@ fmt: ## format the OCaml sources
clean: ## remove build artifacts
$(DUNE) dune clean
+
+# Mirrors lectio's own release target, including its refusals: no release from
+# a dirty tree, no release without a CHANGELOG line, and no release whose
+# version bump silently failed to apply. The version lives in TWO places
+# (dune-project, which feeds colitur.opam, and bin/main.ml's own constant,
+# which is what --version prints), so both are rewritten and both are
+# re-checked -- a release that bumped one and not the other would ship a
+# binary disagreeing with its own package metadata.
+release: ## cut a release: make release VERSION=0.1.0 (add its CHANGELOG line first)
+ @test -n "$(VERSION)" || { echo "set VERSION=X.Y.Z" >&2; exit 2; }
+ @echo "$(VERSION)" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$$' || { echo "VERSION must be X.Y.Z" >&2; exit 2; }
+ @test -z "$$(git status --porcelain)" || { echo "working tree not clean; commit or stash first" >&2; exit 2; }
+ @grep -q '## \[$(VERSION)\]' CHANGELOG.md || { echo "add a one-line CHANGELOG.md entry under '## [$(VERSION)]' first" >&2; exit 2; }
+ @sed -i 's/^(version .*)$$/(version $(VERSION))/' dune-project
+ @sed -i 's/^let version = ".*"/let version = "$(VERSION)"/' bin/main.ml
+ @grep -q '^(version $(VERSION))$$' dune-project || { echo "dune-project version bump failed" >&2; exit 2; }
+ @grep -q '^let version = "$(VERSION)"' bin/main.ml || { echo "bin/main.ml version bump failed" >&2; exit 2; }
+ $(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 tag -a "v$(VERSION)" -m "colitur $(VERSION)"
+ @echo "tagged v$(VERSION). publish with: git push origin main v$(VERSION)"