diff --git a/pyproject.toml b/pyproject.toml index 2ab5295..68d81aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,11 +104,12 @@ follow_imports = "skip" # # Version is mirrored here (rather than read dynamically) because Briefcase resolves PEP621 # `dynamic = ["version"]` by running the PEP517 build backend in an isolated env, which is wasteful -# in CI. Bump both this string and src/searchmob_desktop/version.py together at release time. +# in CI. Bump both this string and src/searchmob_desktop/version.py together at release time; +# `tests/test_version_consistency.py` fails the build if they ever drift apart. [tool.briefcase] project_name = "SearchMob Desktop" bundle = "com.flintwave" -version = "26.06.05" +version = "26.06.06" url = "https://github.com/FlintWave/SearchMob-Desktop" author = "FlintWave" author_email = "flintwave@tuta.com" diff --git a/tests/test_version_consistency.py b/tests/test_version_consistency.py new file mode 100644 index 0000000..7f5868e --- /dev/null +++ b/tests/test_version_consistency.py @@ -0,0 +1,27 @@ +"""The app version lives in two places that MUST agree: `src/searchmob_desktop/version.py` (the +single source of truth, read by hatchling and the in-app update check) and the `[tool.briefcase]` +`version` in `pyproject.toml` (mirrored there because Briefcase resolves a PEP 621 dynamic version +by running the build backend in an isolated env, which is wasteful in CI). + +If they drift, the installers Briefcase builds carry a different version than the app reports, so a +release can ship packages labelled with the previous version and Linux package managers refuse the +upgrade. This test fails the build when that happens, so the two can never silently diverge again. +""" + +from __future__ import annotations + +import tomllib +from pathlib import Path + +from searchmob_desktop.version import __version__ + +_PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml" + + +def test_briefcase_version_matches_version_py() -> None: + data = tomllib.loads(_PYPROJECT.read_text(encoding="utf-8")) + briefcase_version = data["tool"]["briefcase"]["version"] + assert briefcase_version == __version__, ( + f"pyproject [tool.briefcase] version {briefcase_version!r} != " + f"version.py {__version__!r}; bump both together at release time." + )