diff --git a/templates/github/.ci/scripts/clean_gh_release_notes.py b/templates/github/.ci/scripts/clean_gh_release_notes.py new file mode 100755 index 00000000..f575df79 --- /dev/null +++ b/templates/github/.ci/scripts/clean_gh_release_notes.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +# This script is running with elevated privileges from the main branch against pull requests. + +# This script cleans the input from artifacts which are used by the pulp documentation internally, but clutter for GitHub releases +import re +import sys + +RE_VERSION = re.compile(r"^## (\d+\.\d+\.\d+)") + +def main(): + # Print disclaimer: + version_str = "" + for line in sys.stdin: + if line.endswith("\n"): + line = line[:-1] + if line.startswith("#"): + print(line.split(" {: #")[0]) + match = RE_VERSION.match(line) + if match and version_str == "": + version_str = match.group(1) + print("") + print("> [!NOTE]") + print(f"> Changes are also available on [Pulp docs](https://pulpproject.org/pulpcore/changes/#{version_str})") + else: + print(line) + + +if __name__ == "__main__": + main() diff --git a/templates/github/.github/workflows/publish.yml.j2 b/templates/github/.github/workflows/publish.yml.j2 index 4171bcf4..e146cb9d 100644 --- a/templates/github/.github/workflows/publish.yml.j2 +++ b/templates/github/.github/workflows/publish.yml.j2 @@ -154,7 +154,7 @@ jobs: run: | # The last commit before the release commit contains the release CHANGES fragments git checkout "${TAG_NAME}~" - NOTES=$(towncrier build --draft --version $TAG_NAME) + NOTES=$(towncrier build --draft --version $TAG_NAME | .ci/scripts/clean_gh_release_notes.py) echo "body<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT