summaryrefslogtreecommitdiff
path: root/scripts/release/repo_release.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/release/repo_release.py')
-rw-r--r--scripts/release/repo_release.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/release/repo_release.py b/scripts/release/repo_release.py
new file mode 100644
index 0000000..d50e458
--- /dev/null
+++ b/scripts/release/repo_release.py
@@ -0,0 +1,64 @@
+"""
+scripts/release/repo_release.py
+
+Run after every `pyinstaller labui.spec` build, from anywhere (paths are
+made absolute below before the working directory changes). Packages the
+freshly built dist/LabUI bundle as a new signed tufup target.
+
+Prerequisites:
+ - repo_init.py has been run once already (./repository and ./keystore exist)
+ - core/version.py has been bumped to the new version
+ - dist/LabUI/ exists (pyinstaller labui.spec has just been run)
+
+After this completes, see README.md in this directory for how to publish
+the updated ./repository/metadata and ./repository/targets files to the
+"updates" GitHub Release.
+"""
+
+import os
+import sys
+from pathlib import Path
+
+_THIS_DIR = Path(__file__).resolve().parent
+_REPO_ROOT = _THIS_DIR.parent.parent
+_DIST_DIR = _REPO_ROOT / "dist" / "LabUI"
+
+# Import core.version before changing cwd — needs the repo root on sys.path,
+# which won't be true anymore once we chdir into scripts/release below.
+sys.path.insert(0, str(_REPO_ROOT))
+from core.version import __version__ as APP_VERSION
+
+from tufup.repo import Repository
+
+# tufup's config file / relative repo_dir / keys_dir all resolve against cwd
+# (same reasoning as repo_init.py) — pin it here too, for the same reason.
+os.chdir(_THIS_DIR)
+
+
+def main():
+ if not _DIST_DIR.is_dir():
+ raise SystemExit(
+ f"{_DIST_DIR} not found — run `pyinstaller labui.spec` from the "
+ f"repo root first."
+ )
+
+ repo = Repository.from_config()
+
+ changelog = input(f"One-line changelog for v{APP_VERSION} (optional): ").strip()
+ custom_metadata = {"changelog": changelog} if changelog else None
+
+ repo.add_bundle(
+ new_bundle_dir=_DIST_DIR,
+ new_version=APP_VERSION,
+ skip_patch=True, # no binary delta patching for now — full archive only
+ custom_metadata=custom_metadata,
+ )
+ repo.publish_changes(private_key_dirs=[Path("keystore")])
+
+ print(f"Signed and published v{APP_VERSION} to ./repository")
+ print("Next: upload ./repository/metadata/* and ./repository/targets/* "
+ "to the 'updates' GitHub Release — see README.md in this directory.")
+
+
+if __name__ == "__main__":
+ main()