diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
| commit | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch) | |
| tree | 1269efa852935b183daae4bb33a58d1b4d2ffb53 /.github/scripts/release-policy.py | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to '.github/scripts/release-policy.py')
| -rw-r--r-- | .github/scripts/release-policy.py | 463 |
1 files changed, 441 insertions, 22 deletions
diff --git a/.github/scripts/release-policy.py b/.github/scripts/release-policy.py index ec7abe09..b2e160ce 100644 --- a/.github/scripts/release-policy.py +++ b/.github/scripts/release-policy.py @@ -7,33 +7,381 @@ import argparse import hashlib import json import re +import subprocess import sys import tarfile import zipfile +from collections.abc import Callable from pathlib import Path -VERSION_RE = re.compile(r"^(?P<numeric>\d+\.\d+\.\d+)(?:-rc(?P<rc>[1-9]\d*))?$") +VERSION_RE = re.compile(r"^(?P<numeric>\d+\.\d+\.\d+)(?:-(?P<label>beta|rc)(?P<number>[1-9]\d*))?$") +RELEASE_BRANCH_RE = re.compile(r"^release/(?P<major>\d+)\.(?P<minor>\d+)$") +OBJECT_ID_RE = re.compile(r"^(?:[0-9a-f]{40}|[0-9a-f]{64})$") MACOS_MODES = ("validation", "distribution") WINDOWS_MODES = ("signpath", "unsigned") +CHANNEL_RANK = {"BETA": 0, "RC": 1, "GA": 2} +BETA_TAG_PATTERN = "v*-beta*" +RELEASE_TARGETS = ("arm64-macOS", "x86_64-macOS", "linux-x86_64", "linux-aarch64", "linux-armhf", "windows-x86_64") +RELEASE_TARBALLS_FILE = Path(__file__).resolve().parents[2] / "CMake" / "release-tarballs.txt" +# Artifact name endings that already mean another kind of release asset. +RESERVED_ASSET_KINDS = ("deb", "rpm", "installer", "signed", "unsigned", "src") def classify(version: str) -> dict[str, str]: match = VERSION_RE.fullmatch(version) if not match: - raise ValueError("version must be X.Y.Z or X.Y.Z-rcN") - rc = match.group("rc") or "" + raise ValueError("version must be X.Y.Z, X.Y.Z-betaN, or X.Y.Z-rcN") + label = match.group("label") numeric = match.group("numeric") major, minor, _ = numeric.split(".") return { "version": version, "numeric": numeric, - "channel": "RC" if rc else "GA", - "rc_number": rc, + "channel": label.upper() if label else "GA", + "prerelease_number": match.group("number") or "", "release_branch": f"release/{major}.{minor}", } +def release_order(identity: dict[str, str]) -> tuple[int, ...]: + return ( + *(int(part) for part in identity["numeric"].split(".")), + CHANNEL_RANK[identity["channel"]], + int(identity["prerelease_number"] or 0), + ) + + +def parse_public_ref_listing(output: str) -> tuple[dict[str, str], str]: + refs: dict[str, str] = {} + peeled_tags: dict[str, str] = {} + records = [] + for line in output.splitlines(): + fields = line.split() + if len(fields) != 2 or not OBJECT_ID_RE.fullmatch(fields[0]): + raise ValueError("public git ref listing is malformed") + object_id, name = fields + records.append(f"{object_id} {name}") + if name.endswith("^{}"): + tag = name[:-3] + if tag.startswith("refs/tags/v"): + peeled_tags[tag] = object_id + elif ( + name == "refs/heads/master" + or name.startswith("refs/heads/release/") + or name.startswith("refs/tags/v") + ): + refs[name] = object_id + refs.update(peeled_tags) + digest = hashlib.sha256("\n".join(sorted(records)).encode("utf-8")).hexdigest() + return refs, digest + + +def public_release_line_policy(version: str, refs: dict[str, str]) -> dict[str, object]: + identity = classify(version) + ga_versions: list[tuple[int, int, int]] = [] + line_tags: list[tuple[tuple[int, ...], str, str]] = [] + release_branch_count = 0 + for name, sha in refs.items(): + if name.startswith("refs/heads/release/"): + branch = name.removeprefix("refs/heads/") + match = RELEASE_BRANCH_RE.fullmatch(branch) + if not match: + raise ValueError(f"public release branch is malformed: {branch}") + release_branch_count += 1 + elif name.startswith("refs/tags/v"): + tag_version = name.removeprefix("refs/tags/v") + try: + tag_identity = classify(tag_version) + except ValueError as error: + raise ValueError(f"public version tag is malformed: {name}") from error + numeric_version = tuple(int(part) for part in tag_identity["numeric"].split(".")) + line_tags.append((release_order(tag_identity), name.removeprefix("refs/tags/"), sha)) + if tag_identity["channel"] == "GA": + ga_versions.append(numeric_version) + if not ga_versions: + raise ValueError( + "cannot determine the newest GA line: no immutable public vX.Y.Z GA tags exist" + ) + candidate_version = tuple(int(part) for part in identity["numeric"].split(".")) + candidate_line = candidate_version[:2] + newest_version = max(ga_versions) + candidate_line_versions = [ + ga_version for ga_version in ga_versions if ga_version[:2] == candidate_line + ] + highest_candidate_line_version = ( + max(candidate_line_versions) if candidate_line_versions else None + ) + candidate_line_tags = [tag for tag in line_tags if tag[0][:2] == candidate_line] + latest_candidate_line_tag = max(candidate_line_tags, default=None) + newest_line = newest_version[:2] + return { + "candidate_line": f"{candidate_line[0]}.{candidate_line[1]}", + "newest_ga_line": f"{newest_line[0]}.{newest_line[1]}", + "ga_line_is_newest": candidate_line >= newest_line, + "newest_ga_version": ".".join(str(part) for part in newest_version), + "highest_ga_version_on_candidate_line": ( + ".".join(str(part) for part in highest_candidate_line_version) + if highest_candidate_line_version + else None + ), + "latest_public_tag_on_candidate_line": ( + latest_candidate_line_tag[1] if latest_candidate_line_tag else None + ), + "latest_public_tag_sha_on_candidate_line": ( + latest_candidate_line_tag[2] if latest_candidate_line_tag else None + ), + "ga_release_is_latest": ( + identity["channel"] == "GA" and candidate_version >= newest_version + ), + "legacy_tag_only": release_branch_count == 0, + } + + +def plan_public_promotion( + version: str, + sha: str, + refs: dict[str, str], + is_ancestor: Callable[[str, str], bool], +) -> dict[str, object]: + if not OBJECT_ID_RE.fullmatch(sha): + raise ValueError("candidate SHA must be a full lowercase Git object ID") + identity = classify(version) + line_policy = public_release_line_policy(version, refs) + public_tag = f"v{version}" + tag_ref = f"refs/tags/{public_tag}" + branch_ref = f"refs/heads/{identity['release_branch']}" + current_tag = refs.get(tag_ref) + current_branch = refs.get(branch_ref) + if current_tag and current_tag != sha: + raise ValueError(f"public {public_tag} already points to {current_tag}; tags are never moved") + if current_branch and not is_ancestor(current_branch, sha): + raise ValueError( + f"public {identity['release_branch']} at {current_branch} is not an ancestor of {sha}; " + "refusing a non-fast-forward update" + ) + if not current_branch and line_policy["latest_public_tag_sha_on_candidate_line"]: + tag_sha = line_policy["latest_public_tag_sha_on_candidate_line"] + if not is_ancestor(tag_sha, sha): + tag = line_policy["latest_public_tag_on_candidate_line"] + raise ValueError( + f"public {identity['release_branch']} is missing and its latest public tag " + f"{tag} at {tag_sha} is not an ancestor of {sha}; " + "refusing a disconnected branch initialization" + ) + + highest_candidate_line_version = line_policy["highest_ga_version_on_candidate_line"] + if ( + identity["channel"] == "GA" + and highest_candidate_line_version + and tuple(int(part) for part in identity["numeric"].split(".")) + < tuple(int(part) for part in highest_candidate_line_version.split(".")) + ): + raise ValueError( + f"public GA tags already reach {highest_candidate_line_version} on this line; " + "a lower GA version cannot advance it" + ) + latest_line_tag = line_policy["latest_public_tag_on_candidate_line"] + if ( + not current_tag + and latest_line_tag + and release_order(identity) <= release_order(classify(latest_line_tag.removeprefix("v"))) + ): + raise ValueError( + f"{latest_line_tag} is the latest public tag on this line; {public_tag} must sort above it" + ) + + advance_master = identity["channel"] == "GA" and line_policy["ga_line_is_newest"] + current_master = refs.get("refs/heads/master") + if advance_master: + if not current_master: + raise ValueError("public master is missing; cannot fast-forward the newest GA line") + if not is_ancestor(current_master, sha): + raise ValueError( + f"public master at {current_master} is not an ancestor of {sha}; " + "review and complete the private release history bridge before GA promotion" + ) + + updates = [branch_ref] + if not current_tag: + updates.append(tag_ref) + if advance_master: + updates.append("refs/heads/master") + return { + **line_policy, + "version": version, + "channel": identity["channel"], + "sha": sha, + "public_tag": public_tag, + "release_branch": identity["release_branch"], + "prior_release_branch": current_branch, + "prior_master": current_master, + "tag_exists": current_tag == sha, + "advance_master": advance_master, + "updates": updates, + } + + +def git_output( + arguments: list[str], error_context: str, *, cwd: Path | None = None +) -> str: + result = subprocess.run(["git", *arguments], capture_output=True, text=True, cwd=cwd) + if result.returncode: + detail = result.stderr.strip() or result.stdout.strip() + raise ValueError(f"{error_context}: {detail}") + return result.stdout.strip() + + +def git_is_ancestor(ancestor: str, descendant: str, *, cwd: Path | None = None) -> bool: + result = subprocess.run( + ["git", "merge-base", "--is-ancestor", ancestor, descendant], + capture_output=True, + text=True, + cwd=cwd, + ) + if result.returncode not in (0, 1): + detail = result.stderr.strip() or result.stdout.strip() + raise ValueError(f"unable to verify public commit ancestry: {detail}") + return result.returncode == 0 + + +def public_refs(remote: str, *, cwd: Path | None = None) -> tuple[dict[str, str], str]: + listing = git_output( + [ + "ls-remote", + remote, + "refs/heads/master", + "refs/heads/release/*", + "refs/tags/v*", + ], + "unable to read public release refs", + cwd=cwd, + ) + return parse_public_ref_listing(listing) + + +def inspect_public_promotion( + version: str, sha: str, remote: str, *, cwd: Path | None = None +) -> dict[str, object]: + refs, digest = public_refs(remote, cwd=cwd) + identity = classify(version) + refs_to_fetch = ["refs/heads/master", f"refs/heads/{identity['release_branch']}"] + if f"refs/heads/{identity['release_branch']}" not in refs: + line_policy = public_release_line_policy(version, refs) + latest_tag = line_policy["latest_public_tag_on_candidate_line"] + if latest_tag: + refs_to_fetch.append(f"refs/tags/{latest_tag}") + for name in refs_to_fetch: + if name in refs: + git_output( + ["fetch", "--no-tags", remote, name], + f"unable to fetch {name}", + cwd=cwd, + ) + plan = plan_public_promotion( + version, + sha, + refs, + lambda ancestor, descendant: git_is_ancestor(ancestor, descendant, cwd=cwd), + ) + plan["public_refs_digest"] = digest + return plan + + +def push_public_ref_updates( + remote: str, plan: dict[str, object], *, cwd: Path | None = None +) -> None: + refspecs = [f"{plan['sha']}:{ref}" for ref in plan["updates"]] + result = subprocess.run( + ["git", "push", "--atomic", remote, *refspecs], + capture_output=True, + text=True, + cwd=cwd, + ) + if result.returncode: + detail = result.stderr.strip() or result.stdout.strip() + raise ValueError(f"atomic public ref update failed; no refs were changed: {detail}") + + +def promote_public_source( + version: str, + sha: str, + remote: str, + expected_refs_digest: str, + *, + cwd: Path | None = None, +) -> dict[str, object]: + plan = inspect_public_promotion(version, sha, remote, cwd=cwd) + if plan["public_refs_digest"] != expected_refs_digest: + raise ValueError("public release refs changed after validation; rerun validation before promotion") + push_public_ref_updates(remote, plan, cwd=cwd) + return plan + + +def inspect_public_release_line( + version: str, remote: str, *, cwd: Path | None = None +) -> dict[str, object]: + refs, digest = public_refs(remote, cwd=cwd) + return { + **public_release_line_policy(version, refs), + "public_refs_digest": digest, + } + + +def publication_environment(channel: str) -> str: + return "beta-release" if channel == "BETA" else "public-release" + + +def validate_publication_environment( + environment: object, channel: str = "GA", deployment_policies: object = None +) -> None: + name = publication_environment(channel) + if not isinstance(environment, dict) or environment.get("name") != name: + raise ValueError(f"{name} environment response is malformed") + rules = environment.get("protection_rules") + if not isinstance(rules, list): + raise ValueError(f"{name} environment has no protection_rules list") + reviewer_rules = [ + rule for rule in rules + if isinstance(rule, dict) and rule.get("type") == "required_reviewers" + ] + if channel == "BETA": + if reviewer_rules: + raise ValueError("beta-release environment must not require reviewers") + if environment.get("deployment_branch_policy") != { + "protected_branches": False, "custom_branch_policies": True + }: + raise ValueError("beta-release environment must restrict deployments to custom deployment patterns") + policies = deployment_policies.get("branch_policies") if isinstance(deployment_policies, dict) else None + if ( + not isinstance(policies, list) + or len(policies) != 1 + or not isinstance(policies[0], dict) + or (policies[0].get("name"), policies[0].get("type")) != (BETA_TAG_PATTERN, "tag") + ): + raise ValueError(f"beta-release environment must admit exactly the {BETA_TAG_PATTERN} tag pattern") + return + if len(reviewer_rules) != 1: + raise ValueError("public-release environment must have one required-reviewers rule") + rule = reviewer_rules[0] + if rule.get("prevent_self_review") is not False: + raise ValueError("public-release required-reviewers rule must allow self-review") + reviewers = rule.get("reviewers") + if not isinstance(reviewers, list) or not reviewers: + raise ValueError("public-release required-reviewers rule must list eligible reviewers") + for reviewer in reviewers: + identity = reviewer.get("reviewer") if isinstance(reviewer, dict) else None + reviewer_type = reviewer.get("type") if isinstance(reviewer, dict) else None + if ( + not isinstance(reviewer_type, str) + or reviewer_type not in {"User", "Team"} + or not isinstance(identity, dict) + or type(identity.get("id")) is not int + or identity["id"] <= 0 + ): + raise ValueError("public-release required-reviewers rule contains a malformed reviewer") + + def parse_state(contents: str, *, expected_revision: str | None = None) -> dict[str, str]: state = {} for line in contents.splitlines(): @@ -41,21 +389,23 @@ def parse_state(contents: str, *, expected_revision: str | None = None) -> dict[ if not separator or key in state: raise ValueError("release-state.txt must contain unique key=value lines") state[key] = value - required_keys = {"version", "channel", "rc", "revision"} + required_keys = {"version", "channel", "prerelease", "revision"} if not required_keys <= set(state) or set(state) - required_keys - {"windows_signing"}: - raise ValueError("release-state.txt must define version, channel, rc, revision, and optionally windows_signing") + raise ValueError("release-state.txt must define version, channel, prerelease, revision, and optionally windows_signing") state.setdefault("windows_signing", "signpath") if state["windows_signing"] not in WINDOWS_MODES: raise ValueError("release-state.txt windows_signing must be signpath or unsigned") - if state["channel"] not in {"DEVEL", "RC", "GA"}: - raise ValueError("release-state.txt channel must be DEVEL, RC, or GA") + if state["channel"] not in {"DEVEL", "BETA", "RC", "GA"}: + raise ValueError("release-state.txt channel must be DEVEL, BETA, RC, or GA") + if state["channel"] == "BETA" and state["windows_signing"] != "unsigned": + raise ValueError("BETA release state requires windows_signing=unsigned") if not re.fullmatch(r"\d+\.\d+\.\d+", state["version"]): raise ValueError("release-state.txt version must be X.Y.Z") - if state["channel"] == "RC": - if not re.fullmatch(r"[1-9]\d*", state["rc"]): - raise ValueError("RC release state requires a positive RC number") - elif state["rc"]: - raise ValueError("DEVEL and GA release states require an empty RC number") + if state["channel"] in {"BETA", "RC"}: + if not re.fullmatch(r"[1-9]\d*", state["prerelease"]): + raise ValueError("BETA and RC release states require a positive prerelease number") + elif state["prerelease"]: + raise ValueError("DEVEL and GA release states require an empty prerelease number") required_revision = expected_revision or "$Format:%H$" if state["revision"].lower() != required_revision.lower(): raise ValueError(f"release-state.txt revision must be {required_revision}") @@ -77,8 +427,8 @@ def validate_source(root: Path, version: str) -> dict[str, str]: errors.append(f"release-state version {state['version']} does not match {identity['numeric']}") if state["channel"] != identity["channel"]: errors.append(f"release channel {state['channel']} does not match {identity['channel']}") - if state["rc"] != identity["rc_number"]: - errors.append(f"RC number {state['rc'] or '<empty>'} does not match {identity['rc_number'] or '<empty>'}") + if state["prerelease"] != identity["prerelease_number"]: + errors.append(f"prerelease number {state['prerelease'] or '<empty>'} does not match {identity['prerelease_number'] or '<empty>'}") if errors: raise ValueError("; ".join(errors)) identity["windows_signing"] = state["windows_signing"] @@ -111,10 +461,30 @@ def validate_archive(path: Path, version: str, commit: str) -> None: raise ValueError("source archive must not contain .git metadata") identity = classify(version) state = parse_state(release_state_contents, expected_revision=commit) - if state["version"] != identity["numeric"] or state["channel"] != identity["channel"] or state["rc"] != identity["rc_number"]: + if state["version"] != identity["numeric"] or state["channel"] != identity["channel"] or state["prerelease"] != identity["prerelease_number"]: raise ValueError("source archive release identity does not match its tag") +def tarball_groups(path: Path = RELEASE_TARBALLS_FILE) -> list[str]: + groups = [] + for line in path.read_text(encoding="utf-8").splitlines(): + fields = line.split() + if not fields or fields[0].startswith("#"): + continue + if len(fields) < 2: + raise ValueError(f"release tarball {fields[0]} names no programs in {path.name}") + if not re.fullmatch(r"[a-z0-9]+", fields[0]) or fields[0] in RESERVED_ASSET_KINDS: + raise ValueError(f"release tarball name {fields[0]} cannot name a release asset") + groups.append(fields[0]) + if not groups or len(groups) != len(set(groups)): + raise ValueError(f"{path.name} must name each release tarball once") + return groups + + +def release_tarballs(version: str) -> list[str]: + return [f"wsjtx-{version}-{target}-{group}" for target in RELEASE_TARGETS for group in tarball_groups()] + + def expected_assets(version: str, distribution: bool) -> list[str]: mac_suffix = "macOS.pkg" if distribution else "macOS-unsigned.pkg" return [ @@ -124,6 +494,7 @@ def expected_assets(version: str, distribution: bool) -> list[str]: f"wsjtx-{version}-linux-aarch64-AppImage", f"wsjtx-{version}-linux-armhf-AppImage", f"wsjtx-{version}-windows-x86_64-installer-signed" if distribution else f"wsjtx-{version}-windows-x86_64-installer", + *release_tarballs(version), ] @@ -140,16 +511,23 @@ def public_expected_assets(version: str, macos_mode: str, windows_mode: str = "s f"wsjtx-{version}-linux-aarch64-AppImage", f"wsjtx-{version}-linux-armhf-AppImage", f"wsjtx-{version}-windows-x86_64-installer{'-signed' if windows_mode == 'signpath' else ''}", + *release_tarballs(version), ] +def asset_suffix(artifact: str) -> str: + if artifact.rsplit("-", 1)[-1] in tarball_groups(): + return ".tar.gz" + return ".pkg" if "macOS" in artifact else ".AppImage" if "linux" in artifact else ".exe" + + def collect_asset_files(root: Path, expected: list[str]) -> list[Path]: files: list[Path] = [] for artifact in expected: directory = root / artifact if not directory.is_dir(): raise ValueError(f"missing artifact directory: {artifact}") - suffix = ".pkg" if "macOS" in artifact else ".AppImage" if "linux" in artifact else ".exe" + suffix = asset_suffix(artifact) matches = sorted(path for path in directory.rglob(f"*{suffix}") if path.is_file()) if len(matches) != 1: raise ValueError(f"{artifact} must contain exactly one {suffix} file; found {len(matches)}") @@ -171,13 +549,14 @@ def find_asset_files(root: Path, version: str, distribution: bool) -> list[Path] def find_public_asset_files( root: Path, version: str, macos_mode: str, windows_mode: str = "signpath" ) -> list[Path]: - files = collect_asset_files(root, public_expected_assets(version, macos_mode, windows_mode)) + expected = public_expected_assets(version, macos_mode, windows_mode) + files = collect_asset_files(root, expected) if macos_mode == "distribution": unsigned = sorted(root.rglob("*-unsigned.pkg")) if unsigned: raise ValueError(f"unsigned macOS packages cannot be published: {unsigned[0]}") if windows_mode == "unsigned": - installer = files[-1] + installer = files[expected.index(f"wsjtx-{version}-windows-x86_64-installer")] if installer.name != f"wsjtx-{version}-win64.exe": raise ValueError(f"unexpected unsigned Windows installer: {installer.name}") if (root / f"wsjtx-{version}-windows-x86_64-installer-signed").exists(): @@ -290,10 +669,13 @@ def write_manifest(args: argparse.Namespace) -> None: for arch, digest in digests.items(): if not re.fullmatch(r"sha256:[0-9a-f]{64}", digest): raise ValueError(f"Linux {arch} builder digest is not an immutable sha256 digest") + beta = classify(args.version)["channel"] == "BETA" + if beta and args.macos_mode != "validation": + raise ValueError("BETA releases publish the validated unsigned macOS packages") files = release_files(root, args.version, args.macos_mode, args.windows_mode) replaceable_macos = ( {f"wsjtx-{args.version}-{arch}-macOS.pkg" for arch in ("arm64", "x86_64")} - if args.macos_mode == "validation" + if args.macos_mode == "validation" and not beta else set() ) entries = [ @@ -309,7 +691,7 @@ def write_manifest(args: argparse.Namespace) -> None: "workflow_run": args.run_id, "linux_builders": digests, "macos_signing": { - "mode": "manual" if args.macos_mode == "validation" else "distribution", + "mode": "unsigned" if beta else "manual" if args.macos_mode == "validation" else "distribution", "replaceable_assets": sorted(replaceable_macos), }, "windows_signing": {"mode": args.windows_mode}, @@ -329,6 +711,22 @@ def main() -> int: subparsers = parser.add_subparsers(dest="command", required=True) classify_parser = subparsers.add_parser("classify") classify_parser.add_argument("version") + line_parser = subparsers.add_parser("public-release-line") + line_parser.add_argument("version") + line_parser.add_argument("--remote", required=True) + plan_parser = subparsers.add_parser("plan-public-promotion") + plan_parser.add_argument("version") + plan_parser.add_argument("--sha", required=True) + plan_parser.add_argument("--remote", required=True) + promote_parser = subparsers.add_parser("promote-public-source") + promote_parser.add_argument("version") + promote_parser.add_argument("--sha", required=True) + promote_parser.add_argument("--remote", required=True) + promote_parser.add_argument("--expected-refs-digest", required=True) + environment_parser = subparsers.add_parser("validate-publication-environment") + environment_parser.add_argument("environment_json") + environment_parser.add_argument("--channel", choices=sorted(CHANNEL_RANK), required=True) + environment_parser.add_argument("--deployment-policies") state_parser = subparsers.add_parser("read-state") state_parser.add_argument("--root", default=".") validate_parser = subparsers.add_parser("validate-source") @@ -372,6 +770,27 @@ def main() -> int: try: if args.command == "classify": print(json.dumps(classify(args.version))) + elif args.command == "public-release-line": + print(json.dumps(inspect_public_release_line(args.version, args.remote))) + elif args.command == "plan-public-promotion": + print(json.dumps(inspect_public_promotion(args.version, args.sha, args.remote))) + elif args.command == "promote-public-source": + print(json.dumps(promote_public_source( + args.version, args.sha, args.remote, args.expected_refs_digest + ))) + elif args.command == "validate-publication-environment": + policies = ( + json.loads(Path(args.deployment_policies).read_text(encoding="utf-8")) + if args.deployment_policies + else None + ) + validate_publication_environment( + json.loads(Path(args.environment_json).read_text(encoding="utf-8")), args.channel, policies + ) + if args.channel == "BETA": + print(f"Validated beta-release: no reviewer, deployments only from {BETA_TAG_PATTERN} tags") + else: + print("Validated public-release required-reviewer protection") elif args.command == "read-state": print(json.dumps(read_state(Path(args.root)))) elif args.command == "validate-source": |
