()
| 29 | |
| 30 | |
| 31 | def main() -> None: |
| 32 | tag = os.environ["GITHUB_EVENT_INPUTS_TAG"] |
| 33 | repo = os.environ["GITHUB_REPOSITORY"] |
| 34 | dist = Path("dist") |
| 35 | checksums = dist / "SHA256SUMS" |
| 36 | |
| 37 | if not checksums.exists(): |
| 38 | raise SystemExit("SHA256SUMS not found in dist/") |
| 39 | |
| 40 | # Parse filenames and checksums directly from SHA256SUMS to avoid downloading |
| 41 | # all release artifacts (tens of GB). |
| 42 | entries: list[tuple[str, str]] = [] |
| 43 | for line in checksums.read_text().splitlines(): |
| 44 | line = line.strip() |
| 45 | if not line: |
| 46 | continue |
| 47 | checksum, filename = line.split(maxsplit=1) |
| 48 | filename = filename.lstrip("*") |
| 49 | entries.append((filename, checksum)) |
| 50 | |
| 51 | versions: dict[str, list[dict[str, str]]] = defaultdict(list) |
| 52 | for filename, checksum in sorted(entries): |
| 53 | match = FILENAME_RE.match(filename) |
| 54 | if match is None: |
| 55 | continue |
| 56 | python_version = match.group("py") |
| 57 | build_version = match.group("tag") |
| 58 | version = f"{python_version}+{build_version}" |
| 59 | build = match.group("build") |
| 60 | flavor = match.group("flavor") |
| 61 | variant_parts: list[str] = [] |
| 62 | if build: |
| 63 | variant_parts.extend(build.split("+")) |
| 64 | if flavor: |
| 65 | variant_parts.append(flavor) |
| 66 | variant = "+".join(variant_parts) if variant_parts else "" |
| 67 | |
| 68 | url_prefix = f"https://github.com/{repo}/releases/download/{tag}/" |
| 69 | url = url_prefix + quote(filename, safe="") |
| 70 | archive_format = "tar.zst" if filename.endswith(".tar.zst") else "tar.gz" |
| 71 | |
| 72 | artifact = { |
| 73 | "platform": match.group("triple"), |
| 74 | "variant": variant, |
| 75 | "url": url, |
| 76 | "archive_format": archive_format, |
| 77 | "sha256": checksum, |
| 78 | } |
| 79 | versions[version].append(artifact) |
| 80 | |
| 81 | payload_versions: list[dict[str, object]] = [] |
| 82 | now = datetime.now(timezone.utc).isoformat() |
| 83 | for version, artifacts in sorted(versions.items(), reverse=True): |
| 84 | artifacts.sort( |
| 85 | key=lambda artifact: (artifact["platform"], artifact.get("variant", "")) |
| 86 | ) |
| 87 | payload_versions.append( |
| 88 | { |
no outgoing calls
no test coverage detected