#!/usr/bin/env sh # Auto-set the next version from Conventional Commits (git-cliff), per D21. # Run after committing your feat:/fix: changes; it updates __init__.py + pyproject.toml. # Then update CHANGELOG.md, commit as `chore(release): vX.Y.Z`, and push (CI tags + releases). set -eu ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) cd "$ROOT" command -v git-cliff >/dev/null 2>&1 || { echo "git-cliff not found. Install: pip install git-cliff"; exit 1; } NEXT=$(git-cliff --bumped-version | sed 's/^v//') [ -n "$NEXT" ] || { echo "Could not compute the next version."; exit 1; } python3 - "$NEXT" <<'PY' import pathlib, re, sys version = sys.argv[1] init = pathlib.Path("src/rigdoctor/__init__.py") init.write_text(re.sub(r'__version__ = "[^"]+"', f'__version__ = "{version}"', init.read_text())) proj = pathlib.Path("pyproject.toml") proj.write_text(re.sub(r'(?m)^version = "[^"]+"', f'version = "{version}"', proj.read_text(), count=1)) PY echo "Set version to $NEXT." echo "Next: add a '## [$NEXT]' CHANGELOG section, then commit as 'chore(release): v$NEXT'."