INNER CODE UNIT · Python
bump_version
aeturrell/coding-for-economists · version_bumper.py:6
def bump_version(
part: Literal["major", "minor", "patch"] = "patch",
dev_suffix: str | None = None,
) -> None:
file_path = "pyproject.toml"
with open(file_path, "r") as f:
content = f.read()
match = re.search(r'^version = "([^"]+)"', content, re.MULTILINE)
if not match:
raise RuntimeError("Could not find version in pyproject.toml")
base = re.match(r"(\d+)\.(\d+)\.(\d+)", match.group(1))
if not base:
raise RuntimeError(f"Unexpected version format: {match.group(1)}")
major, minor, patch_v = map(int, base.groups())