69 lines
1.8 KiB
Python
Executable File
69 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Publish only after the public Manager installation path is verified."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import getpass
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from tools.verify_manager_install import verify_manager_install
|
|
|
|
|
|
def publish_release(
|
|
source: Path,
|
|
*,
|
|
comfy: str,
|
|
token: str,
|
|
changelog: str,
|
|
) -> None:
|
|
verify_manager_install(source)
|
|
subprocess.run([comfy, "node", "validate"], cwd=source, check=True)
|
|
env = dict(os.environ)
|
|
env["COMFY_NODE_CHANGELOG"] = changelog
|
|
subprocess.run(
|
|
[comfy, "node", "publish"],
|
|
cwd=source,
|
|
env=env,
|
|
input=f"{token}\n",
|
|
text=True,
|
|
check=True,
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"--source",
|
|
type=Path,
|
|
default=Path(__file__).resolve().parents[1],
|
|
help="tagged release repository",
|
|
)
|
|
parser.add_argument("--changelog", required=True)
|
|
parser.add_argument("--comfy", default=shutil.which("comfy") or "comfy")
|
|
args = parser.parse_args()
|
|
token = getpass.getpass("Comfy Registry API key: ").strip()
|
|
if not token:
|
|
print("REGISTRY RELEASE FAILED: API key is empty", file=sys.stderr)
|
|
return 1
|
|
try:
|
|
publish_release(
|
|
args.source.resolve(),
|
|
comfy=args.comfy,
|
|
token=token,
|
|
changelog=args.changelog,
|
|
)
|
|
except (OSError, subprocess.CalledProcessError, RuntimeError) as exc:
|
|
print(f"REGISTRY RELEASE FAILED: {exc}", file=sys.stderr)
|
|
return 1
|
|
print("REGISTRY RELEASE PASSED THE MANAGER INSTALL GATE AND WAS UPLOADED")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|