ci: Publish snapshot feeds after verified asset publication

This commit is contained in:
Kevin Yue committed 2026-11-16 14:23:44 +08:00
1 parent 387d4cfa7a
commit b06d7e7672
7 files changed
+226 -26

No files matched your search

+23 -10
View File
@@ -1,33 +1,45 @@
#!/usr/bin/env python3
"""Retain one source pair per build run so retries cannot move branch refs."""
"""Retain one source and version identity per build run, including retries."""
import argparse
import json
import os
import re
import runpy
import subprocess
from pathlib import Path
def record(path, gp, gpgui, output):
def record(path, gp, gpgui, output, build_version):
if path.exists():
sources = json.loads(path.read_text())
identity = json.loads(path.read_text())
else:
sources = {
identity = {
name: subprocess.check_output(["git", "-C", str(root), "rev-parse", "HEAD"],
text=True, stderr=subprocess.DEVNULL).strip()
for name, root in (("gp_sha", gp), ("gpgui_sha", gpgui))
}
if set(sources) != {"gp_sha", "gpgui_sha"} or any(
cargo_version = runpy.run_path(str(Path(__file__).with_name("validate-release-version.py")))["cargo_version"]
version = cargo_version(gp)
if cargo_version(gpgui) != version:
raise ValueError("public and desktop product versions differ")
identity.update(version=version, build_version=build_version)
if set(identity) != {"gp_sha", "gpgui_sha", "version", "build_version"} or any(
not isinstance(value, str) or not re.fullmatch(r"[0-9a-f]{40}", value)
for value in sources.values()
for name, value in identity.items() if name.endswith("_sha")
):
raise ValueError("invalid retained build source refs")
if not isinstance(identity["version"], str) or not re.fullmatch(r"\d+\.\d+\.\d+", identity["version"]):
raise ValueError("invalid retained product version")
if not isinstance(identity["build_version"], str) or not re.fullmatch(
r"(0|[1-9]\d*)\.(0|[1-9]\d*)", identity["build_version"]
):
raise ValueError("invalid retained build version")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(sources, indent=2) + "\n")
path.write_text(json.dumps(identity, indent=2) + "\n")
with output.open("a") as stream:
for name, sha in sources.items():
stream.write(f"{name}={sha}\n")
for name, value in identity.items():
stream.write(f"{name}={value}\n")
def main():
@@ -35,9 +47,10 @@ def main():
parser.add_argument("path", type=Path)
parser.add_argument("--gp", type=Path, required=True)
parser.add_argument("--gpgui", type=Path, required=True)
parser.add_argument("--build-version", required=True)
args = parser.parse_args()
try:
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]))
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]), args.build_version)
except (OSError, ValueError, subprocess.CalledProcessError):
parser.exit(1, "Could not retain the selected build source refs.\n")