-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathrelease_github.py
More file actions
35 lines (28 loc) · 931 Bytes
/
release_github.py
File metadata and controls
35 lines (28 loc) · 931 Bytes
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
import re
import webbrowser
from pathlib import Path
from urllib.parse import urlencode
def main():
changelog_path = Path(__file__).parents[1] / "docs" / "changelog.md"
changelog = changelog_path.read_text(encoding="utf-8")
match = re.search(
r"^##\s+Version\s+(?P<version>\S+)[^\n]*\n+(?P<notes>.*?)(?=^##\s+Version|\Z)",
changelog,
re.DOTALL | re.MULTILINE,
)
if not match:
msg = f"Unable to parse changelog at {changelog_path}"
raise RuntimeError(msg)
version = match.group("version").strip()
notes = match.group("notes").strip()
params = urlencode(
{
"title": f"Version {version}",
"tag": version,
"body": re.sub(r"\{pr\}`(\d+)`", r"#\1", notes),
}
)
url = f"https://github.com/msgspec/msgspec/releases/new?{params}"
webbrowser.open_new_tab(url)
if __name__ == "__main__":
main()