mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:59:43 +01:00
Linux nightly packaging by @dylanmtaylor, with the per-app Nightly flavor commits stacked on his branch. gate test shard 1/5 (and the Sonar scan that reads its coverage) fails on crates/ui-egui/src/doc_windows/tests.rs `a_document_made_current_in_presentation_mode_comes_to_the_front_after_it`, which main fails too (CI run 45581083304); this PR touches no ui-egui code. Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Nightly metadata: run from a private owned build cwd with a staged template.
|
|
|
|
All file arguments must stay beneath that cwd; this is not native/signing acceptance.
|
|
"""
|
|
import argparse
|
|
import datetime
|
|
import os
|
|
from pathlib import Path
|
|
import plistlib
|
|
import re
|
|
import sys
|
|
|
|
# The shared helper location is fixed by this script, not by CLI file arguments.
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
from nightly_paths import OwnedBuildRoot
|
|
|
|
MAX_TEMPLATE_BYTES = 256 * 1024
|
|
|
|
IDENTIFIER = "ai.storyteller.vectorcraft.nightly"
|
|
ASSOCIATIONS = ("CFBundleDocumentTypes", "CFBundleURLTypes", "UTExportedTypeDeclarations", "UTImportedTypeDeclarations")
|
|
VERSION = re.compile(r"([0-9]+\.[0-9]+\.[0-9]+)-nightly\.([0-9]{8})\.[0-9]+\.[0-9]+\.g([0-9a-f]{12})\Z")
|
|
|
|
|
|
def render(template: bytes, version: str, commit: str) -> bytes:
|
|
match = VERSION.fullmatch(version)
|
|
if not match or not re.fullmatch(r"[0-9a-f]{40}", commit) or match[3] != commit[:12]:
|
|
raise ValueError("exact prepared Nightly version and matching source commit are required")
|
|
datetime.datetime.strptime(match[2], "%Y%m%d")
|
|
data = plistlib.loads(template)
|
|
if not isinstance(data, dict) or data.get("CFBundlePackageType") != "APPL":
|
|
raise ValueError("expected the app-owned application plist template")
|
|
for key in ASSOCIATIONS:
|
|
data.pop(key, None)
|
|
data.update(
|
|
CFBundleDisplayName="VectorCraft Nightly",
|
|
CFBundleName="VectorCraft Nightly",
|
|
CFBundleIdentifier=IDENTIFIER,
|
|
CFBundleExecutable="VectorCraft",
|
|
CFBundleIconFile="vectorcraft-nightly",
|
|
CFBundleShortVersionString=match[1],
|
|
CFBundleVersion=match[1],
|
|
VectorCraftVersion=version,
|
|
VectorCraftBuildCommit=commit,
|
|
)
|
|
return plistlib.dumps(data, fmt=plistlib.FMT_XML, sort_keys=False)
|
|
|
|
|
|
def write_plist(template: Path, destination: Path, version: str, commit: str) -> None:
|
|
with OwnedBuildRoot() as root:
|
|
content = render(root.read_bytes(template, MAX_TEMPLATE_BYTES), version, commit)
|
|
with root.create(destination) as stream:
|
|
stream.write(content)
|
|
stream.flush()
|
|
os.fsync(stream.fileno())
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--template", type=Path, required=True)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
parser.add_argument("--version", required=True)
|
|
parser.add_argument("--source-commit", required=True)
|
|
args = parser.parse_args()
|
|
write_plist(args.template, args.output, args.version, args.source_commit)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|