summaryrefslogtreecommitdiff
path: root/tools/deploy.py.in
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-07-26 19:15:06 +0200
committerxengineering <me@xengineering.eu>2025-07-26 19:15:06 +0200
commit11078651756014631166cb8f0bf2d8bce18e56d1 (patch)
treed2e7e262d5f7dbbec4a41b5d86c1955b73b6a1c2 /tools/deploy.py.in
parentd3e7f19f1f87b03e9a7c8a170b9c4351ac565268 (diff)
parent376a2f91964527bfb6b57661a9e81a4d5544f288 (diff)
downloadiot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.tar
iot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.tar.zst
iot-contact-11078651756014631166cb8f0bf2d8bce18e56d1.zip
Merge implementation of tar archive deployment
Deploying all build artifacts in a single tar archive file makes deployment easier. The bundle stays consistent, GPG signatures can later easily provided too, the archive and its top-level directory can have the same and long name and the further paths in the archive can stay short.
Diffstat (limited to 'tools/deploy.py.in')
-rwxr-xr-xtools/deploy.py.in57
1 files changed, 57 insertions, 0 deletions
diff --git a/tools/deploy.py.in b/tools/deploy.py.in
new file mode 100755
index 0000000..8eeecda
--- /dev/null
+++ b/tools/deploy.py.in
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+
+
+import argparse
+import subprocess
+import pathlib
+
+
+SCRIPT = pathlib.Path(__file__)
+BUILD_ROOT = SCRIPT.parent.parent.resolve()
+ARTIFACTS_DEFAULT = BUILD_ROOT / "@PROJECT_VERSION_STRING@.tar.zst"
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(
+ description="Use OpenSSH and rsync to deploy artifacts",
+ )
+
+ parser.add_argument(
+ "-a",
+ "--artifacts",
+ default=ARTIFACTS_DEFAULT,
+ help="local path to artifacts archive file",
+ )
+ parser.add_argument(
+ "-H", "--host", default="cloud", help="target `Host` name from ~/.ssh/config"
+ )
+ parser.add_argument(
+ "-p",
+ "--path",
+ default="/srv/http/deploy.xengineering.eu/public/git/iot-contact/",
+ help="remote path to destination folder on server",
+ )
+ parser.add_argument(
+ "-d",
+ "--dry-run",
+ action="store_true",
+ help="do not execute command and instead print it",
+ )
+
+ args = parser.parse_args()
+
+ command = [
+ "rsync",
+ "-av",
+ f"{str(pathlib.Path(args.artifacts).resolve())}",
+ f"{args.host}:{args.path}",
+ ]
+
+ if args.dry_run:
+ print(command)
+ else:
+ subprocess.run(command, shell=False, check=True)
+
+
+if __name__ == "__main__":
+ main()