#!/usr/bin/env python3 """Publish one independent Marqdo stdlib/extension component release. This is the single implementation of the component release transaction used by every active library repository (marqdo#96 M1). It is intentionally self-contained: a component repository only needs Python 3, git, gzip and curl (or the bootstrap in ``.woodpecker/publish.yml``) and never checks out the root repository or a sibling component. Artifact -------- The published asset is a deterministic archive of *only* the reviewed release paths of the exact tagged commit (``git archive`` of that commit + ``gzip -n``), never the working tree, tests, caches or ``.git``. Packaging twice must produce the same sha256; that property is checked on every run. Evidence -------- ``release-evidence.json`` follows the ecosystem-wide schema already verified by ``scripts/reconcile-releases.py``:: repository, component_id, tag, source_sha, ci: {pipeline_number, url, source_sha}, assets: [{name, size, target, sha256}], dependencies: [{id, source_sha[, asset_sha256]}] No parallel stdlib/ext release manifest is introduced. The same-SHA Woodpecker pipeline of the ``ci`` workflow is discovered through the public read-only API; a tag is never published without a successful same-SHA component CI. Publish transaction ------------------- Gitea Release is used as the immutable asset store: create/reuse a *draft*, upload the payload assets first and ``release-evidence.json`` last, re-read every byte and compare sha256, then make the release public. Published releases are never deleted or overwritten. Re-running with identical bytes is idempotent; different bytes for the same tag fail closed. Commands -------- release.py check --repository cflmy/marqdo-std-text --component-id std-text \ --kind stdlib --allow modules --allow README.md release.py publish --repository cflmy/marqdo-std-text --component-id std-text \ --kind stdlib --allow modules --allow README.md \ --tag v0.1.0 --dependency cli,, Environment for ``publish``: ``GITEA_PUBLISH_TOKEN`` holds the protected publishing token; ordinary push/PR lanes never receive it. """ from __future__ import annotations import argparse import hashlib import io import json import mimetypes import os import re import subprocess import sys import tarfile import tempfile import urllib.error import urllib.parse import urllib.request import uuid from pathlib import Path FORGE = "https://git.cflmy.cn" CI = "https://ci.cflmy.cn" INDEX = "release-evidence.json" WORKFLOW = "ci" SHA_RE = re.compile(r"[0-9a-f]{40}") DIGEST_RE = re.compile(r"[0-9a-f]{64}") VERSION_RE = re.compile( r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)" r"(-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?" ) BASENAME_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._+-]{0,254}") MAX_INDEX_BYTES = 1024 * 1024 MAX_ASSET_BYTES = 1024 * 1024 * 1024 MAX_DEPENDENCIES = 256 ALLOWED_EVENTS = {"push", "pull_request", "manual"} KIND_SUFFIX = {"stdlib": "-source.tar.gz", "extension": "-package.tar.gz"} class ReleaseError(Exception): """A release precondition, artifact or transaction failed.""" def require(condition: object, message: str) -> None: if not condition: raise ReleaseError(message) def sha256_bytes(data: bytes) -> str: return hashlib.sha256(data).hexdigest() def sha256_file(path: Path) -> str: digest = hashlib.sha256() with path.open("rb") as handle: for chunk in iter(lambda: handle.read(1024 * 1024), b""): digest.update(chunk) return digest.hexdigest() def git(root: Path, *args: str, binary: bool = False): result = subprocess.run( ["git", "-C", str(root), *args], capture_output=True ) if result.returncode != 0: raise ReleaseError( f"git {' '.join(args)} failed: {result.stderr.decode(errors='replace').strip()}" ) return result.stdout if binary else result.stdout.decode().strip() def resolved_head(root: Path) -> str: value = git(root, "rev-parse", "HEAD") require(SHA_RE.fullmatch(value) is not None, "HEAD is not a full commit SHA") return value def safe_relative(entry: str) -> bool: if not entry or entry.startswith(("/", "\\")): return False parts = Path(entry).parts return not any(part in (".", "..") for part in parts) def validate_version(tag: str) -> str: require(tag.startswith("v"), f"tag {tag!r} must start with 'v'") version = tag[1:] require(VERSION_RE.fullmatch(version) is not None, f"invalid release version {version!r}") return version def artifact_name(repository: str, version: str, kind: str) -> str: name = repository.split("/", 1)[-1] require(BASENAME_RE.fullmatch(name) is not None, "repository name is not a safe basename") return f"{name}-{version}{KIND_SUFFIX[kind]}" def archive_bytes(root: Path, source_sha: str, prefix: str, allow: list[str]) -> bytes: """Return a deterministic tarball of the allowlisted paths at one commit.""" for entry in allow: require(safe_relative(entry), f"unsafe release path: {entry!r}") existing = git(root, "ls-tree", "-r", "--name-only", source_sha, "--", *allow) require(existing != "", "release paths match no file at the tagged commit") producer = subprocess.Popen( ["git", "-C", str(root), "archive", "--format=tar", f"--prefix={prefix}/", source_sha, "--", *allow], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) compressor = subprocess.Popen( ["gzip", "-n"], stdin=producer.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) assert producer.stdout is not None producer.stdout.close() payload, gzip_error = compressor.communicate() producer_error = producer.stderr.read() if producer.stderr is not None else b"" producer_code = producer.wait() if producer.stderr is not None: producer.stderr.close() require(producer_code == 0, f"git archive failed: {producer_error.decode(errors='replace').strip()}") require(compressor.returncode == 0, f"gzip failed: {gzip_error.decode(errors='replace').strip()}") require(payload.startswith(b"\x1f\x8b\x08\x00\x00\x00\x00\x00"), "archive is not a reproducible gzip stream") return payload def check_members(payload: bytes, prefix: str, allow: list[str]) -> None: """Refuse an archive that escapes the reviewed paths or carries metadata.""" with tarfile.open(fileobj=io.BytesIO(payload), mode="r:gz") as archive: members = archive.getmembers() require(members, "archive is empty") forbidden = {"", ".", ".."} allowed_prefixes = tuple(f"{prefix}/{entry.rstrip('/')}" for entry in allow) for member in members: name = member.name require(not name.startswith(("/", "\\")), f"absolute archive path: {name}") parts = name.split("/") require(not any(part in forbidden for part in parts[1:]), f"traversal archive path: {name}") require(name == prefix or name == f"{prefix}/" or any(name == allowed or name.startswith(f"{allowed}/") for allowed in allowed_prefixes), f"archive path escapes the released paths: {name}") require(member.isfile() or member.isdir(), f"unexpected archive member: {name}") require(not member.issym() and not member.islnk(), f"link in archive: {name}") def package_assets( root: Path, source_sha: str, repository: str, component_id: str, version: str, kind: str, allow: list[str], out_dir: Path, ) -> dict: require(SHA_RE.fullmatch(source_sha) is not None, "source SHA must be 40 lowercase hex") require(component_id != "" and "/" not in component_id, "invalid component id") name = artifact_name(repository, version, kind) archive = out_dir / name checksum = out_dir / f"{name}.sha256" prefix = f"{repository.split('/', 1)[-1]}-{version}" first = archive_bytes(root, source_sha, prefix, allow) second = archive_bytes(root, source_sha, prefix, allow) require(first == second, "packaging the same commit twice produced different bytes") check_members(first, prefix, allow) require(len(first) > 0, "archive is empty") archive.write_bytes(first) digest = sha256_bytes(first) checksum.write_text(f"{digest} {name}\n", encoding="utf-8") return { "archive": archive, "checksum": checksum, "name": name, "size": len(first), "sha256": digest, "prefix": prefix, "source_sha": source_sha, } def parse_dependency(raw: str) -> dict: fields: dict[str, str] = {} for part in raw.split(","): require("=" in part, f"invalid dependency field: {raw!r}") key, value = part.split("=", 1) fields[key.strip()] = value.strip() component = fields.get("id", "") source_sha = fields.get("source_sha", "") require(component != "" and "/" not in component, f"invalid dependency id: {raw!r}") require(SHA_RE.fullmatch(source_sha) is not None, f"dependency {component} needs a full source_sha: {raw!r}") record = {"id": component, "source_sha": source_sha} asset = fields.get("asset_sha256") if asset: require(DIGEST_RE.fullmatch(asset) is not None, f"dependency {component} has an invalid asset_sha256") record["asset_sha256"] = asset return record def api_request(url: str, token: str, *, method: str = "GET", payload: dict | None = None, raw: bytes | None = None, content_type: str = "application/json", headers: dict | None = None): request_headers = {"Accept": "application/json"} if token: request_headers["Authorization"] = f"token {token}" if headers: request_headers.update(headers) data = raw if payload is not None: data = json.dumps(payload).encode() request_headers["Content-Type"] = content_type elif raw is not None: request_headers["Content-Type"] = content_type request = urllib.request.Request(url, data=data, headers=request_headers, method=method) try: with urllib.request.urlopen(request, timeout=120) as response: return response.status, response.read(), dict(response.headers) except urllib.error.HTTPError as error: return error.code, error.read(), dict(error.headers) def read_json(url: str, token: str = "") -> object: status, body, _ = api_request(url, token) require(status == 200, f"GET {url} returned HTTP {status}") try: return json.loads(body) except ValueError as error: raise ReleaseError(f"GET {url} did not return JSON: {error}") from error def ci_repository(repository: str, token: str) -> int: forge = read_json(f"{FORGE}/api/v1/repos/{repository}", token) ci = read_json(f"{CI}/api/repos/lookup/{repository}") require(isinstance(forge, dict) and type(forge.get("id")) is int, "Gitea does not identify the canonical repository") require(isinstance(ci, dict) and ci.get("full_name") == repository and type(ci.get("id")) is int and ci["id"] > 0 and ci.get("forge_remote_id") == str(forge["id"]), "Woodpecker does not identify the canonical repository") return ci["id"] def discover_ci(repository: str, source_sha: str, workflow: str, token: str) -> dict: """Find the successful component CI pipeline for the exact release SHA.""" require(SHA_RE.fullmatch(source_sha) is not None, "release SHA must be a full commit") repo_id = ci_repository(repository, token) pipelines: list[dict] = [] for page in range(1, 5): listing = read_json(f"{CI}/api/repos/{repo_id}/pipelines?per_page=50&page={page}") require(isinstance(listing, list), "Woodpecker pipeline listing is malformed") pipelines.extend(item for item in listing if isinstance(item, dict)) if len(listing) < 50: break candidates = [ item for item in pipelines if item.get("commit") == source_sha and item.get("status") == "success" and item.get("event") in ALLOWED_EVENTS ] require(candidates, f"no successful same-SHA Woodpecker pipeline for {source_sha}") number = candidates[0].get("number") require(type(number) is int and number > 0, "invalid pipeline number") detail = read_json(f"{CI}/api/repos/{repo_id}/pipelines/{number}") require(isinstance(detail, dict) and detail.get("number") == number and detail.get("commit") == source_sha and detail.get("status") == "success", "Woodpecker pipeline identity changed while verifying") require(any( isinstance(item, dict) and item.get("name") == workflow and item.get("state") == "success" and any(isinstance(step, dict) and step.get("type") == "commands" and step.get("state") == "success" for step in item.get("children", [])) for item in detail.get("workflows", []) ), f"same-SHA pipeline {number} has no successful {workflow!r} workflow") return { "pipeline_number": number, "url": f"{CI}/repos/{repo_id}/pipeline/{number}", "source_sha": source_sha, } def build_evidence(*, repository: str, component_id: str, tag: str, source_sha: str, ci: dict, assets: list[dict], dependencies: list[dict]) -> dict: require(component_id != "" and "/" not in component_id, "invalid component id") require(tag != "" and " " not in tag, "invalid tag") names: set[str] = set() records = [] for asset in assets: name = asset["name"] require(BASENAME_RE.fullmatch(name) is not None, f"unsafe asset name: {name!r}") require(name != INDEX, "release-evidence.json must not describe itself") require(name not in names, f"duplicate asset: {name}") require(type(asset["size"]) is int and asset["size"] > 0, f"empty asset: {name}") require(DIGEST_RE.fullmatch(asset["sha256"]) is not None, f"invalid digest: {name}") names.add(name) records.append({"name": name, "size": asset["size"], "target": "source", "sha256": asset["sha256"]}) require(records, "a release needs at least one payload asset") require(len(records) <= 127, "too many release assets") seen: set[str] = set() deps = [] for dependency in dependencies: require(dependency["id"] not in seen, f"duplicate dependency: {dependency['id']}") require(dependency["id"] != component_id, "a component cannot depend on itself") require(len(deps) < MAX_DEPENDENCIES, "too many release dependencies") seen.add(dependency["id"]) record = {"id": dependency["id"], "source_sha": dependency["source_sha"]} if "asset_sha256" in dependency: record["asset_sha256"] = dependency["asset_sha256"] deps.append(record) return { "repository": repository, "component_id": component_id, "tag": tag, "source_sha": source_sha, "ci": ci, "assets": records, "dependencies": deps, } def write_evidence(evidence: dict, out: Path) -> Path: payload = json.dumps(evidence, indent=2, sort_keys=True, ensure_ascii=False) + "\n" require(len(payload.encode()) <= MAX_INDEX_BYTES, "release-evidence.json exceeds 1 MiB") out.write_text(payload, encoding="utf-8") return out # --------------------------------------------------------------------------- # Gitea release transaction # --------------------------------------------------------------------------- def release_api(repository: str, tag: str) -> str: return f"{FORGE}/api/v1/repos/{repository}/releases" def find_release(repository: str, tag: str, token: str) -> dict | None: encoded = urllib.parse.quote(tag, safe="") status, body, _ = api_request(f"{release_api(repository, tag)}/tags/{encoded}", token) if status == 404: return None require(status == 200, f"release lookup for {tag} returned HTTP {status}") try: release = json.loads(body) except ValueError as error: raise ReleaseError(f"release lookup for {tag} is not JSON: {error}") from error require(isinstance(release, dict) and type(release.get("id")) is int, f"release lookup for {tag} is malformed") return release def release_assets(repository: str, tag: str, token: str) -> dict: """Return name -> release asset record, verifying canonical download URLs.""" release = find_release(repository, tag, token) require(release is not None, f"release {tag} is missing after publish") assets: dict[str, dict] = {} for asset in release.get("assets") or []: name = asset.get("name") require(isinstance(name, str) and BASENAME_RE.fullmatch(name) is not None, "release carries an unsafe asset name") expected = f"{FORGE}/{repository}/releases/download/{urllib.parse.quote(tag, safe='')}/{urllib.parse.quote(name, safe='')}" require(asset.get("browser_download_url") == expected, f"asset {name} has a non-canonical download URL") require(name not in assets, f"duplicate release asset {name}") assets[name] = asset return assets def download_verified(asset: dict, token: str) -> bytes: request = urllib.request.Request(asset["browser_download_url"], headers={"Authorization": f"token {token}"}) try: with urllib.request.urlopen(request, timeout=120) as response: data = response.read(MAX_ASSET_BYTES + 1) except urllib.error.HTTPError as error: raise ReleaseError( f"asset download {asset['name']} returned HTTP {error.code}") from error require(len(data) <= MAX_ASSET_BYTES, f"asset {asset['name']} exceeds the size limit") require(len(data) == int(asset.get("size") or -1), f"asset {asset['name']} size differs from its release record") return data def published_matches(repository: str, tag: str, expected: list[dict], token: str) -> bool: try: assets = release_assets(repository, tag, token) except ReleaseError: return False if set(assets) != {item["name"] for item in expected}: return False for item in expected: data = download_verified(assets[item["name"]], token) if sha256_bytes(data) != item["sha256"]: return False return True def create_draft(repository: str, tag: str, body: str, target: str, prerelease: bool, token: str) -> dict: payload = {"tag_name": tag, "name": tag, "body": body, "draft": True, "prerelease": prerelease, "target_commitish": target} status, response, _ = api_request( release_api(repository, tag), token, method="POST", payload=payload) require(status in (200, 201), f"creating draft release {tag} returned HTTP {status}: {response[:200]!r}") release = json.loads(response) require(isinstance(release, dict) and type(release.get("id")) is int, "draft release response is malformed") return release def patch_release(repository: str, release_id: int, payload: dict, token: str) -> dict: status, response, _ = api_request( f"{release_api(repository, '')}/{release_id}", token, method="PATCH", payload=payload) require(status == 200, f"updating release {release_id} returned HTTP {status}") release = json.loads(response) require(isinstance(release, dict), "release update response is malformed") return release def upload_asset(repository: str, release_id: int, path: Path, token: str) -> dict: name = path.name existing = read_json(f"{release_api(repository, '')}/{release_id}/assets", token) require(isinstance(existing, list), "release asset listing is malformed") for asset in existing: if asset.get("name") == name: raise ReleaseError(f"asset {name} already exists on release {release_id}; " "refusing to overwrite") boundary = f"----marqdo{uuid.uuid4().hex}" content_type = mimetypes.guess_type(name)[0] or "application/octet-stream" body = bytearray() body.extend(f"--{boundary}\r\n".encode()) body.extend(f'Content-Disposition: form-data; name="attachment"; filename="{name}"\r\n'.encode()) body.extend(f"Content-Type: {content_type}\r\n\r\n".encode()) body.extend(path.read_bytes()) body.extend(f"\r\n--{boundary}--\r\n".encode()) status, response, _ = api_request( f"{release_api(repository, '')}/{release_id}/assets?" f"name={urllib.parse.quote(name, safe='')}", token, method="POST", raw=bytes(body), content_type=f"multipart/form-data; boundary={boundary}") require(status in (200, 201), f"uploading {name} returned HTTP {status}: {response[:200]!r}") asset = json.loads(response) require(isinstance(asset, dict) and asset.get("name") == name, f"upload response for {name} is malformed") return asset def publish_release(*, repository: str, tag: str, source_sha: str, body: str, prerelease: bool, assets: list[Path], token: str) -> dict: require(token, "GITEA_PUBLISH_TOKEN is required to publish") require(assets, "no assets to publish") index_assets = [path for path in assets if path.name == INDEX] payload_assets = [path for path in assets if path.name != INDEX] require(len(index_assets) == 1, "exactly one release-evidence.json is required") ordered = payload_assets + index_assets expected = [{"name": path.name, "size": path.stat().st_size, "sha256": sha256_file(path)} for path in ordered] existing = find_release(repository, tag, token) if existing is not None and not existing.get("draft"): if published_matches(repository, tag, expected, token): return {"status": "idempotent", "release_id": existing["id"], "tag": tag, "url": existing.get("html_url"), "assets": expected} raise ReleaseError( f"published release {tag} already exists with different bytes; refusing to overwrite") if existing is not None: release = patch_release(repository, int(existing["id"]), { "name": tag, "body": body, "draft": True, "prerelease": prerelease, "target_commitish": source_sha}, token) else: release = create_draft(repository, tag, body, source_sha, prerelease, token) release_id = int(release["id"]) remote = {asset.get("name") for asset in read_json( f"{release_api(repository, '')}/{release_id}/assets", token)} for path in ordered: if path.name in remote: continue upload_asset(repository, release_id, path, token) if not published_matches(repository, tag, expected, token): raise ReleaseError("draft release assets did not round-trip byte for byte") published = patch_release(repository, release_id, { "draft": False, "prerelease": prerelease, "name": tag, "body": body}, token) require(published.get("draft") is False, "release remained a draft after publishing") if not published_matches(repository, tag, expected, token): raise ReleaseError("published release assets did not round-trip byte for byte") final = find_release(repository, tag, token) require(final is not None and final.get("draft") is False, "published release cannot be re-read") return {"status": "published", "release_id": final["id"], "tag": tag, "url": final.get("html_url"), "assets": expected} def default_body(*, repository: str, component_id: str, kind: str, tag: str, source_sha: str, ci: dict, assets: list[dict], dependencies: list[dict]) -> str: lines = [ f"Independent {kind} component release for `{component_id}` (`{repository}`) `{tag}`.", "", f"- Component: `{component_id}` ({kind})", f"- Source commit: `{source_sha}`", f"- Same-SHA component CI: {ci['url']}", f"- Assets: " + ", ".join( f"`{item['name']}` ({item['size']} bytes, sha256 `{item['sha256']}`)" for item in assets), f"- Tested dependencies: " + ( ", ".join(f"`{item['id']}@{item['source_sha'][:12]}`" for item in dependencies) or "none"), "", "This is a component release. Root recommendation/acceptance and consumer " "updates are separate facts tracked by the ecosystem reconcile flow; " "installing it does not grant permissions or update any runtime.", ] return "\n".join(lines) + "\n" # --------------------------------------------------------------------------- # CLI # --------------------------------------------------------------------------- def common_parser(parser: argparse.ArgumentParser) -> None: parser.add_argument("--root", default=".", help="component repository root") parser.add_argument("--repository", required=True, help="owner/name on the authoritative forge") parser.add_argument("--component-id", required=True) parser.add_argument("--kind", choices=sorted(KIND_SUFFIX), required=True) parser.add_argument("--allow", action="append", default=[], required=True, help="released path relative to the repository root (repeatable)") parser.add_argument("--source-sha", default=None, help="exact commit to release (default: HEAD)") parser.add_argument("--out-dir", default=None, help="output directory for the packaged assets") def command_check(args) -> int: root = Path(args.root).resolve() source_sha = resolved_head(root) out_dir = Path(tempfile.mkdtemp(prefix="mq-release-check-")) result = package_assets(root, source_sha, args.repository, args.component_id, "0.0.0", args.kind, list(args.allow), out_dir) print(json.dumps({ "status": "PASS", "component_id": args.component_id, "repository": args.repository, "kind": args.kind, "source_sha": source_sha, "artifact": {key: result[key] for key in ("name", "size", "sha256")}, "released_paths": sorted(args.allow), }, ensure_ascii=False, indent=2)) return 0 def command_publish(args) -> int: token = os.environ.get("GITEA_PUBLISH_TOKEN", "") require(token, "GITEA_PUBLISH_TOKEN is required to publish") require(args.tag, "publish requires --tag") version = validate_version(args.tag) prerelease = "-" in version root = Path(args.root).resolve() source_sha = args.source_sha or resolved_head(root) require(resolved_head(root) == source_sha, "publish must run on the exact checked-out release commit") status = subprocess.run( ["git", "-C", str(root), "rev-parse", "-q", "--verify", f"refs/tags/{args.tag}"], capture_output=True) if status.returncode == 0: require(status.stdout.decode().strip() == source_sha, f"tag {args.tag} does not point at the released commit") dependencies = [parse_dependency(item) for item in args.dependency] out_dir = Path(args.out_dir) if args.out_dir else Path(tempfile.mkdtemp(prefix="mq-release-")) out_dir.mkdir(parents=True, exist_ok=True) payload = package_assets(root, source_sha, args.repository, args.component_id, version, args.kind, list(args.allow), out_dir) ci = discover_ci(args.repository, source_sha, WORKFLOW, token) evidence = build_evidence( repository=args.repository, component_id=args.component_id, tag=args.tag, source_sha=source_sha, ci=ci, assets=[{"name": payload["name"], "size": payload["size"], "sha256": payload["sha256"]}, {"name": f"{payload['name']}.sha256", "size": payload["checksum"].stat().st_size, "sha256": sha256_file(payload["checksum"])}], dependencies=dependencies) evidence_path = write_evidence(evidence, out_dir / INDEX) body = args.body or default_body( repository=args.repository, component_id=args.component_id, kind=args.kind, tag=args.tag, source_sha=source_sha, ci=ci, assets=evidence["assets"], dependencies=evidence["dependencies"]) if args.note: body = body.rstrip("\n") + "\n\n" + "\n".join(f"- {note}" for note in args.note) + "\n" result = publish_release( repository=args.repository, tag=args.tag, source_sha=source_sha, body=body, prerelease=prerelease, assets=[payload["archive"], payload["checksum"], evidence_path], token=token) print(json.dumps({ "status": result["status"], "repository": args.repository, "component_id": args.component_id, "tag": args.tag, "version": version, "channel": "prerelease" if prerelease else "stable", "source_sha": source_sha, "ci": ci, "url": result.get("url"), "assets": [{"name": item["name"], "size": item["size"], "sha256": item["sha256"]} for item in result["assets"]], "dependencies": evidence["dependencies"], }, ensure_ascii=False, indent=2)) return 0 def main(argv: list[str]) -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) commands = parser.add_subparsers(dest="command", required=True) check = commands.add_parser( "check", help="package the exact commit twice and verify the artifact in CI") common_parser(check) publish = commands.add_parser( "publish", help="package, evidence and publish one immutable Gitea release") common_parser(publish) publish.add_argument("--tag", required=True, help="release tag, e.g. v0.1.0") publish.add_argument("--dependency", action="append", default=[], help="tested dependency: id=,source_sha=[,asset_sha256=]") publish.add_argument("--body", default="", help="release body (default: generated)") publish.add_argument("--note", action="append", default=[], help="extra fact appended to the generated release body (repeatable)") args = parser.parse_args(argv) try: if args.command == "check": return command_check(args) return command_publish(args) except ReleaseError as error: print(f"component-release: FAIL: {error}", file=sys.stderr) return 1 if __name__ == "__main__": raise SystemExit(main(sys.argv[1:]))