-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pseudo auto-generated notes for the 2.x+ release branch (#339)
* an initial test * For now manually generate * re-gen file + some pre-commit fixes * add releases.md to exclude list * fix exclude * Fix long title * add releases.md to exclude for eol fixer * Add extra instructions for releases - manual addition for now * Add gh handles as links * fix pre-commit * Update environment.yml * how about this? * remove unused variable * type the one function * fix mypy * Try fixing pre-commit * this should match?
- Loading branch information
Showing
7 changed files
with
513 additions
and
1 deletion.
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,47 @@ | ||
import os | ||
import pathlib | ||
import re | ||
|
||
from github import Github | ||
|
||
|
||
def gen_release_notes(filename: str) -> None: | ||
git = Github(os.environ["GITHUB_TOKEN"]) | ||
repo = git.get_repo("MDAnalysis/mdanalysis") | ||
|
||
parent_directory = pathlib.Path(__file__).parent.parent | ||
parent_directory.mkdir(exist_ok=True, parents=True) | ||
filename = parent_directory / filename # type: ignore | ||
|
||
filetext = "# MDAnalysis Release Notes\n\n\n" | ||
|
||
# Should be ordered | ||
for release in repo.get_releases(): | ||
# MDAnalysis releases always follow a tag pattern of *-release_version | ||
version = release.tag_name.split("-")[1] | ||
|
||
# Only write out version 2.x+ since those are the only ones that | ||
# we can guarantee similarly written notes for | ||
if int(version.split(".")[0]) < 2: | ||
continue | ||
|
||
if release.body.startswith("###"): | ||
filetext += release.body[1:] | ||
else: | ||
filetext += release.body | ||
|
||
filetext += "\n\n" | ||
|
||
# replace all @ starting handles with github links | ||
# \b doesn't work so we're using \s and getting extra whitespace | ||
handles = set(re.findall(r"\s@\w+", filetext)) | ||
for entry in handles: | ||
new_word = f" [{entry[1:]}](https://github.com/{entry[2:]})" | ||
filetext = filetext.replace(entry, new_word) | ||
|
||
with open(filename, "w") as f: | ||
f.write(filetext) | ||
|
||
|
||
if __name__ == "__main__": | ||
gen_release_notes("releases.md") |
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