From b63174b6ca7166a27aefdc62a548b0600e4d49ae Mon Sep 17 00:00:00 2001 From: folkengine Date: Fri, 1 May 2026 19:11:40 -0700 Subject: [PATCH] dynamic pyproject version and make release target - pyproject.toml: switch to dynamic = ["version"] so maturin reads the version from Cargo.toml at build time, eliminating the drift that left pkpython pinned at 0.1.0 on PyPI while Cargo advanced. - Makefile: add `make version` (prints Cargo.toml version) and `make release` (preflights clean tree, missing CHANGELOG entry, duplicate tag; then annotate-tags HEAD and pushes to origin to fire publish.yml). --- Makefile | 19 ++++++++++++++++++- pyproject.toml | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1a21286..abd9cb1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: setup build test demo the-hand calc gto fmt clippy clean ayce default help +.PHONY: setup build test demo the-hand calc gto fmt clippy clean ayce default help version release VENV := .venv PYTHON := $(VENV)/bin/python @@ -24,6 +24,8 @@ help: @echo " make clippy - Run clippy linter" @echo " make clean - Remove build artifacts and venv" @echo " make ayce - Run fmt, build, test, and demo" + @echo " make version - Print the crate version from Cargo.toml" + @echo " make release - Tag HEAD as v and push (drives publish.yml)" @echo " make help - Display this help message" @echo "" @@ -75,3 +77,18 @@ clean: # All You Can Eat - Run all checks ayce: fmt build test demo + +# Print the crate version from Cargo.toml +version: + @awk -F'"' '/^version/{print $$2; exit}' Cargo.toml + +# Cut a release: verify, annotate-tag from Cargo.toml's version, push to origin. +# The pushed tag is what fires .github/workflows/publish.yml. +release: + @v=$$(awk -F'"' '/^version/{print $$2; exit}' Cargo.toml); \ + if [ -z "$$v" ]; then echo "could not parse version from Cargo.toml"; exit 1; fi; \ + if ! git diff --quiet HEAD; then echo "working tree has uncommitted changes; commit or stash first"; exit 1; fi; \ + if git rev-parse "v$$v" >/dev/null 2>&1; then echo "tag v$$v already exists"; exit 1; fi; \ + if [ -f CHANGELOG.md ] && ! grep -q "^## \[$$v\]" CHANGELOG.md; then echo "CHANGELOG.md has no entry for $$v"; exit 1; fi; \ + echo "Tagging v$$v on $$(git rev-parse --short HEAD) and pushing to origin..."; \ + git tag -a "v$$v" -m "Release v$$v" && git push origin "v$$v" diff --git a/pyproject.toml b/pyproject.toml index 87d9ac0..0619c4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "pkpython" -version = "0.1.0" +dynamic = ["version"] description = "Python bindings for pkcore, a high-performance poker analysis library" readme = "README.md" license = { text = "GPL-3.0-or-later" }