Skip to content

Commit

Permalink
Add a script to generate release notes
Browse files Browse the repository at this point in the history
Add a simple script for generating release notes from the pull requests.
The script fetches the pull requests between two (release) tags and
prints the titles in a Markdown format that can be copied to the
release notes.
  • Loading branch information
japauliina authored and mhieta committed Nov 10, 2023
1 parent d3fc86f commit 6c6efa6
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ipython
PyGithub
42 changes: 40 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@ asttokens==2.4.0
# via stack-data
backcall==0.2.0
# via ipython
certifi==2023.7.22
# via requests
cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
# via requests
cryptography==41.0.5
# via pyjwt
decorator==5.1.1
# via ipython
deprecated==1.2.14
# via pygithub
executing==2.0.0
# via stack-data
idna==3.4
# via requests
ipython==8.12.3
# via -r requirements-dev.in
jedi==0.19.1
Expand All @@ -30,17 +44,41 @@ ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
# via stack-data
pycparser==2.21
# via cffi
pygithub==2.1.1
# via -r requirements-dev.in
pygments==2.16.1
# via ipython
pyjwt[crypto]==2.8.0
# via
# pygithub
# pyjwt
pynacl==1.5.0
# via pygithub
python-dateutil==2.8.2
# via pygithub
requests==2.31.0
# via pygithub
six==1.16.0
# via asttokens
# via
# asttokens
# python-dateutil
stack-data==0.6.3
# via ipython
traitlets==5.11.2
# via
# ipython
# matplotlib-inline
typing-extensions==4.8.0
# via ipython
# via
# ipython
# pygithub
urllib3==2.0.7
# via
# pygithub
# requests
wcwidth==0.2.8
# via prompt-toolkit
wrapt==1.16.0
# via deprecated
54 changes: 54 additions & 0 deletions scripts/release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys

from github import Github

repo_owner = "City-of-Helsinki"
repo_name = "smbackend"


def print_section(title, items):
if items:
print(f"## {title}")
for item in items:
print(f"- {item.title} [(#{item.number})]({item.issue_url})")


def create_release_notes(start_tag, end_tag):
"""
Fetch the pull request titles between two tags and print them in a Markdown format.
"""
g = Github()
repo = g.get_repo(f"{repo_owner}/{repo_name}")
commits = list(repo.compare(start_tag, end_tag).commits)

prs = []
features = []
fixes = []
improvements = []
other = []

for commit in commits:
for p in commit.get_pulls():
if p not in prs:
prs.append(p)
branch = p.head.ref
if "feature" in branch:
features.append(p)
elif "fix" in branch:
fixes.append(p)
elif "improvement" in branch:
improvements.append(p)
else:
other.append(p)

print(f"# Release Notes - {end_tag}")
print_section("Features", features)
print_section("Fixes", fixes)
print_section("Improvements", improvements)
print_section("Other", other)


if __name__ == "__main__":
start_tag = sys.argv[1]
end_tag = sys.argv[2]
create_release_notes(start_tag, end_tag)

0 comments on commit 6c6efa6

Please sign in to comment.