Skip to content

Commit c9be81f

Browse files
StopMotionCuberpedro-psb
authored andcommitted
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 <r.simons@fz-juelich.de>
1 parent 8adfa79 commit c9be81f

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
# This script is running with elevated privileges from the main branch against pull requests.
3+
#
4+
# It cleans the input from artifacts which are used by the pulp documentation internally,
5+
# but clutter for GitHub releases
6+
7+
import re
8+
import sys
9+
10+
RE_VERSION = re.compile(r"^## (\d+\.\d+\.\d+)")
11+
12+
13+
def main():
14+
plugin_name = sys.argv[1]
15+
version_str = ""
16+
for line in sys.stdin:
17+
if line.endswith("\n"):
18+
line = line[:-1]
19+
if line.startswith("#"):
20+
print(line.split(" {: #")[0])
21+
match = RE_VERSION.match(line)
22+
if match and version_str == "":
23+
version_str = match.group(1)
24+
docs_url = f"https://pulpproject.org/{plugin_name}/changes/#{version_str}"
25+
print("")
26+
print("> [!NOTE]")
27+
print(f"> Changes are also available on [Pulp docs]({docs_url})")
28+
else:
29+
print(line)
30+
31+
32+
if __name__ == "__main__":
33+
main()

‎templates/github/.github/workflows/publish.yml.j2‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
run: |
155155
# The last commit before the release commit contains the release CHANGES fragments
156156
git checkout "${TAG_NAME}~"
157-
NOTES=$(towncrier build --draft --version $TAG_NAME)
157+
NOTES=$(towncrier build --draft --version $TAG_NAME | .ci/scripts/clean_gh_release_notes.py {{ plugin_name }})
158158
echo "body<<EOF" >> $GITHUB_OUTPUT
159159
echo "$NOTES" >> $GITHUB_OUTPUT
160160
echo "EOF" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)