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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions scripts/native_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_native_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
set_native_version,
stage_artifacts,
superseded_notes,
sync_native_version_from_engine,
validate_release_set,
validate_sbom,
validate_tag,
Expand Down Expand Up @@ -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 /"):
Expand Down
Loading