-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to generate release notes
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
1 parent
d3fc86f
commit 6c6efa6
Showing
3 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ipython | ||
PyGithub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |