aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
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)"