Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release workflow opens PR for changelog against master branch
closes: #416
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Release workflow opens PR against master with the latest changelog. |
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
51 changes: 51 additions & 0 deletions
51
templates/github/.github/workflows/scripts/stage-changelog-for-master.py.j2
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,51 @@ | ||
{% include 'header.j2' %} | ||
|
||
import argparse | ||
import os | ||
import textwrap | ||
|
||
from git import Repo | ||
|
||
|
||
helper = textwrap.dedent( | ||
"""\ | ||
Stage the changelog for a release on master branch. | ||
|
||
Example: | ||
$ python .github/workflows/scripts/stage-changelog-for-master.py 3.4.0 | ||
|
||
""" | ||
) | ||
|
||
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=helper) | ||
|
||
parser.add_argument( | ||
"release_version", | ||
type=str, | ||
help="The version string for the release.", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
release_version_arg = args.release_version | ||
|
||
release_path = os.path.dirname(os.path.abspath(__file__)) | ||
plugin_path = release_path.split("/.github")[0] | ||
|
||
print(f"\n\nRepo path: {plugin_path}") | ||
repo = Repo(plugin_path) | ||
|
||
changelog_commit = None | ||
# Look for a commit with the requested release version | ||
for commit in repo.iter_commits(): | ||
if f"Building changelog for {release_version_arg}\n" in commit.message: | ||
changelog_commit = commit | ||
break | ||
|
||
if not changelog_commit: | ||
raise RuntimeError("Changelog commit for {release_version_arg} was not found.") | ||
|
||
git = repo.git | ||
git.checkout("origin/master") | ||
git.cherry_pick(changelog_commit.hexsha) | ||
git.reset("origin/master") |