From 1a233e0797e357613dabbd7e67f11c4b4c570f73 Mon Sep 17 00:00:00 2001 From: abrichr Date: Fri, 31 Jul 2026 16:28:56 +0200 Subject: [PATCH] ci: deduplicate native release builds --- pyproject.toml | 2 +- scripts/native_release.py | 15 +++++++++++++++ tests/test_native_release.py | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2471ceb..7305d25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -133,7 +133,7 @@ version_variables = ["engine/__init__.py:__version__"] commit_message = "chore: release {version}" major_on_zero = false allow_zero_version = true -build_command = "python -m ensurepip --upgrade && python -m pip install --disable-pip-version-check uv==0.11.29 && python scripts/check_release_consistency.py --sync && git add uv.lock && uv build --wheel --sdist && python scripts/check_release_consistency.py --require-dist && python scripts/check_source_boundary.py --require-dist && python scripts/verify_build_artifact.py python-distribution" +build_command = "python -m ensurepip --upgrade && python -m pip install --disable-pip-version-check uv==0.11.29 && python scripts/check_release_consistency.py --sync && python scripts/native_release.py sync-from-engine && git add uv.lock package.json package-lock.json src-tauri/Cargo.toml src-tauri/Cargo.lock src-tauri/tauri.conf.json && uv build --wheel --sdist && python scripts/check_release_consistency.py --require-dist && python scripts/check_source_boundary.py --require-dist && python scripts/verify_build_artifact.py python-distribution" [tool.semantic_release.branches.main] match = "main" diff --git a/scripts/native_release.py b/scripts/native_release.py index 862c3da..da2c7ad 100644 --- a/scripts/native_release.py +++ b/scripts/native_release.py @@ -131,6 +131,16 @@ def set_lock_versions(lock: dict) -> None: return native_versions(root) +def sync_native_version_from_engine(root: Path = ROOT) -> dict[str, str]: + """Set every native version source from the Python engine version.""" + + project = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8")) + version = project.get("project", {}).get("version") + if not isinstance(version, str) or not VERSION_PATTERN.fullmatch(version): + raise ValueError(f"invalid engine version in pyproject.toml: {version!r}") + return set_native_version(version, root) + + def superseded_notes(body: str, newer_tag: str, repo: str) -> str | None: """Return release notes marking ``body`` superseded by ``newer_tag``. @@ -437,6 +447,7 @@ def _parser() -> argparse.ArgumentParser: set_version_parser = subparsers.add_parser("set-version") set_version_parser.add_argument("version") + subparsers.add_parser("sync-from-engine") supersede_parser = subparsers.add_parser("supersede-notes") supersede_parser.add_argument("--newer-tag", required=True) @@ -484,6 +495,10 @@ def main() -> int: versions = set_native_version(args.version) for source, value in sorted(versions.items()): print(f"{source}: {value}") + elif args.command == "sync-from-engine": + versions = sync_native_version_from_engine() + for source, value in sorted(versions.items()): + print(f"{source}: {value}") elif args.command == "supersede-notes": try: candidate = native_tag_tuple(args.candidate_tag) diff --git a/tests/test_native_release.py b/tests/test_native_release.py index f267ad8..24a500c 100644 --- a/tests/test_native_release.py +++ b/tests/test_native_release.py @@ -14,6 +14,7 @@ set_native_version, stage_artifacts, superseded_notes, + sync_native_version_from_engine, validate_release_set, validate_sbom, validate_tag, @@ -360,6 +361,19 @@ def test_set_native_version_synchronizes_every_source_and_lockfile(tmp_path: Pat assert validate_tag("desktop-v0.5.0", tmp_path) == "desktop-v0.5.0" +def test_sync_native_version_from_engine_uses_python_release_version(tmp_path: Path) -> None: + _write_native_version_fixture(tmp_path, "0.1.1") + (tmp_path / "pyproject.toml").write_text( + '[project]\nname = "openadapt-desktop"\nversion = "0.5.0"\n', + encoding="utf-8", + ) + + versions = sync_native_version_from_engine(tmp_path) + + assert set(versions.values()) == {"0.5.0"} + assert native_version(tmp_path) == "0.5.0" + + def test_set_native_version_rejects_non_semver_input(tmp_path: Path) -> None: _write_native_version_fixture(tmp_path, "0.1.1") for bad in ("v0.5.0", "0.5", "0.5.0-rc.1", "0.5.0;rm -rf /"):