Skip to content

Commit a235d0c

Browse files
authored
Prepare GitHub release (#952)
1 parent 27afa70 commit a235d0c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

scripts/release_github.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import re
2+
import webbrowser
3+
from pathlib import Path
4+
from urllib.parse import urlencode
5+
6+
7+
def main():
8+
changelog_path = Path(__file__).parents[1] / "docs" / "changelog.md"
9+
changelog = changelog_path.read_text(encoding="utf-8")
10+
11+
match = re.search(
12+
r"^##\s+Version\s+(?P<version>\S+)[^\n]*\n+(?P<notes>.*?)(?=^##\s+Version|\Z)",
13+
changelog,
14+
re.DOTALL | re.MULTILINE,
15+
)
16+
if not match:
17+
msg = f"Unable to parse changelog at {changelog_path}"
18+
raise RuntimeError(msg)
19+
20+
version = match.group("version").strip()
21+
notes = match.group("notes").strip()
22+
params = urlencode(
23+
{
24+
"title": f"Version {version}",
25+
"tag": version,
26+
"body": re.sub(r"\{pr\}`(\d+)`", r"#\1", notes),
27+
}
28+
)
29+
30+
url = f"https://github.com/jcrist/msgspec/releases/new?{params}"
31+
webbrowser.open_new_tab(url)
32+
33+
34+
if __name__ == "__main__":
35+
main()

0 commit comments

Comments
 (0)