Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions scripts/release_github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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/jcrist/msgspec/releases/new?{params}"
webbrowser.open_new_tab(url)


if __name__ == "__main__":
main()