-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrelease.py
More file actions
executable file
·128 lines (108 loc) · 3.94 KB
/
Copy pathrelease.py
File metadata and controls
executable file
·128 lines (108 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python3
"""Generate release metadata (versions.json and release notes) for clang-tools-static-binaries.
Usage:
python3 release.py --tag 2026.06.04-a1b2c3d4
This script is called from the CI workflow (.github/workflows/build.yml) in the
``draft-release`` job to produce:
* ``versions.json`` – machine-readable metadata about this release.
* ``release-notes.md`` – human-readable Markdown table of included LLVM versions.
"""
import argparse
import json
import sys
from datetime import datetime, timezone
from pathlib import Path
# Allow importing build.py from the repo root (same directory as this script).
sys.path.insert(0, str(Path(__file__).resolve().parent))
import build
def generate_versions_json(tag: str, output_dir: str = ".") -> Path:
"""Write ``versions.json`` to *output_dir* and return its path.
The generated JSON contains the build timestamp, release tag, a
mapping of LLVM release names (keys) to source tarball identifiers
(values), the full list of shipped tools (with minimum LLVM version
constraints), and the supported platforms. This is the single source
of truth for all downstream channels (pip, asdf, homebrew, scoop, etc.).
"""
all_tools = build.TOOLS
tools_info: dict[str, dict] = {}
for tool in all_tools:
info: dict[str, object] = {}
if tool == "clang-include-cleaner":
info["min_llvm_version"] = build.INCLUDE_CLEANER_MIN_VERSION
if tool == "clang-scan-deps":
info["min_llvm_version"] = build.CLANG_SCAN_DEPS_MIN_VERSION
tools_info[tool] = info
platforms = [
"linux-amd64",
"linux-arm64",
"macos-amd64",
"macos-arm64",
"windows-amd64",
"windows-arm64",
]
data = {
"built_at": datetime.now(timezone.utc).isoformat(),
"release_tag": tag,
"llvm_versions": build.RELEASES,
"tools": tools_info,
"platforms": platforms,
}
out_path = Path(output_dir) / "versions.json"
out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
print(
f"Created {out_path} ({len(build.RELEASES)} versions, "
f"{len(tools_info)} tools, {len(platforms)} platforms)"
)
return out_path
def generate_release_notes(output_dir: str = ".") -> Path:
"""Write ``release-notes.md`` to *output_dir* and return its path.
The notes include a Markdown table of every LLVM version and its
corresponding source tarball, plus the list of supported platforms.
"""
lines = [
"## LLVM Versions in this release",
"",
"| Version | Source |",
"|---------|--------|",
]
# Sort by major version number for readability.
for ver, src in sorted(
build.RELEASES.items(),
key=lambda x: int(x[0].split(".")[0]),
reverse=True,
):
lines.append(f"| {ver} | `{src}` |")
lines += [
"",
"## Platforms",
"",
"Linux x86-64 / Linux ARM64 / macOS x86-64 / macOS ARM64 / Windows x86-64 / Windows ARM64",
]
out_path = Path(output_dir) / "release-notes.md"
out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
print(f"Created {out_path}")
return out_path
def main() -> None:
parser = argparse.ArgumentParser(
description="Generate versions.json and release-notes.md for a release."
)
parser.add_argument(
"--tag",
required=True,
metavar="TAG",
help="Release tag (e.g. 2026.06.04-a1b2c3d4).",
)
parser.add_argument(
"--output-dir",
"-o",
default=".",
metavar="DIR",
help="Directory to write output files (default: current directory).",
)
args = parser.parse_args()
generate_versions_json(args.tag, args.output_dir)
generate_release_notes(args.output_dir)
if __name__ == "__main__":
main()