From b603847a53f259657c936c26478cc6b4e47f2a12 Mon Sep 17 00:00:00 2001 From: Ruben Simons Date: Wed, 4 Feb 2026 15:06:20 +0100 Subject: [PATCH] Clean github release notes The changelog generates markup intended for the documentation build enginee (mkdocs). For the github (or any markdown viwer), this pollutes the document. This adds a script to clean that up before publishing on github. Co-authored-by: Ruben Simons --- .../.ci/scripts/clean_gh_release_notes.py | 33 +++++++++++++++++++ .../github/.github/workflows/publish.yml.j2 | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 templates/github/.ci/scripts/clean_gh_release_notes.py 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..2bf5f4c2 --- /dev/null +++ b/templates/github/.ci/scripts/clean_gh_release_notes.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# This script is running with elevated privileges from the main branch against pull requests. +# +# It cleans the input from artifacts which are used by the pulp documentation internally, +# but clutter for GitHub releases + +import sys + +NOTE = """ +> [!NOTE] +> Official changes are available on [Pulp docs]({docs_url})\ +""" + + +def main(): + plugin_name = sys.argv[1] + version_str = sys.argv[2] + docs_url = f"https://pulpproject.org/{plugin_name}/changes/#{version_str}" + note_added = False + for line in sys.stdin: + if line.endswith("\n"): + line = line[:-1] + if line.startswith("#"): + print(line.split(" {: #")[0]) + if not note_added and version_str in line: + print(NOTE.format(docs_url=docs_url)) + note_added = True + 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..526c2b2c 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 {{ plugin_name }} $TAG_NAME) echo "body<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT