Answer architecture round 1: 0 🔴, 7 🟡; build with the gate's Go, guard single-version channels on older tags, record the Cloudsmith tie, and return the tag from publish()

This commit is contained in:
2026-10-13 17:35:21 +02:00
committed by Lillem4n
parent e67c858d41
commit cc7d4fb972
10 changed files with 135 additions and 43 deletions
+16 -9
View File
@@ -26,23 +26,24 @@ def request(path: str, data: dict | None = None):
return json.load(resp)
def main() -> int:
def publish() -> tuple[int, str | None]:
"""Publish the release, returning the exit code and the tag it published, if any."""
with open("CHANGELOG.md", encoding="utf-8") as f:
top = HEADING.search(f.read())
if top is None:
print("CHANGELOG.md has no `## [...]` heading", file=sys.stderr)
return 1
return 1, None
version, body = top.group(1), top.group(2).strip()
if version == "Unreleased":
print("top heading is Unreleased; nothing to publish")
return 0
return 0, None
if not re.fullmatch(r"\d+\.\d+\.\d+", version):
print(f"top heading `[{version}]` is neither Unreleased nor X.Y.Z", file=sys.stderr)
return 1
return 1, None
tag = f"v{version}"
try:
print(f"{tag} already published: {request(f'releases/tags/{tag}')['html_url']}")
return 0
return 0, None
except urllib.error.HTTPError as e:
if e.code != 404:
raise
@@ -53,15 +54,21 @@ def main() -> int:
at = request(f"git/tags/{at['sha']}")["object"]
if at["sha"] != sha:
print(f"{tag} exists at {at['sha']}, not {sha}; the version is burnt, bump the heading", file=sys.stderr)
return 1
return 1, None
except urllib.error.HTTPError as e:
if e.code != 404:
raise
release = request("releases", {"body": body, "name": tag, "tag_name": tag, "target_commitish": sha})
print(release["html_url"])
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
f.write(f"tag={tag}\n")
return 0
return 0, tag
def main() -> int:
code, tag = publish()
if tag:
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
f.write(f"tag={tag}\n")
return code
if __name__ == "__main__":