54 lines
1.4 KiB
Python
Executable File
54 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Sign one canonical JWeBot release record with an OpenSSH publisher key."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path[:0] = [
|
|
str(ROOT / "packages" / "jwebot-sdk" / "src"),
|
|
str(ROOT / "packages" / "jwebot-kernel" / "src"),
|
|
]
|
|
|
|
from jwebot_kernel import ReleaseError, sign_release_record # noqa: E402
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("release", type=Path)
|
|
parser.add_argument("--artifact", type=Path)
|
|
parser.add_argument("--private-key", type=Path, required=True)
|
|
parser.add_argument("--publisher", required=True)
|
|
parser.add_argument("--output", type=Path)
|
|
args = parser.parse_args()
|
|
try:
|
|
signature_path, signature = sign_release_record(
|
|
args.release,
|
|
args.private_key,
|
|
args.publisher,
|
|
artifact=args.artifact,
|
|
output=args.output,
|
|
)
|
|
except ReleaseError as error:
|
|
parser.error(str(error))
|
|
print(
|
|
json.dumps(
|
|
{
|
|
**signature.to_mapping(),
|
|
"signature_path": str(signature_path),
|
|
},
|
|
ensure_ascii=False,
|
|
sort_keys=True,
|
|
)
|
|
)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|