Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/check_version_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
from pathlib import Path
import subprocess
import sys
import tomllib
import tomli


ROOT = Path(__file__).resolve().parents[1]


def pyproject_version() -> str:
pyproject_path = ROOT / "pyproject.toml"
with pyproject_path.open("rb") as f:
data = tomllib.load(f)
data = tomli.load(f)
return data["tool"]["poetry"]["version"]


def latest_tag() -> str | None:
def latest_tag() -> str:
try:
tag = subprocess.check_output(
["git", "describe", "--tags", "--abbrev=0"], cwd=ROOT, text=True
).strip()
return tag.lstrip("v")
except subprocess.CalledProcessError:
return None
return "0.0.0"


def main() -> int:
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test(c: Context) -> None:


@task
def check_version(c: Context) -> None:
def checkversion(c: Context) -> None:
"""Validate that ``pyproject.toml`` matches the latest git tag.
This task runs the ``scripts/check_version_match.py`` helper using Poetry
Expand Down
Loading