File: release_github.py

package info (click to toggle)
python-msgspec 0.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,416 kB
  • sloc: javascript: 23,944; ansic: 20,940; python: 19,752; makefile: 26; sh: 23
file content (35 lines) | stat: -rw-r--r-- 930 bytes parent folder | download
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/jcrist/msgspec/releases/new?{params}"
    webbrowser.open_new_tab(url)


if __name__ == "__main__":
    main()