Skip to content

Commit b603847

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 b603847

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 sys
8+
9+
NOTE = """
10+
> [!NOTE]
11+
> Official changes are available on [Pulp docs]({docs_url})\
12+
"""
13+
14+
15+
def main():
16+
plugin_name = sys.argv[1]
17+
version_str = sys.argv[2]
18+
docs_url = f"https://pulpproject.org/{plugin_name}/changes/#{version_str}"
19+
note_added = False
20+
for line in sys.stdin:
21+
if line.endswith("\n"):
22+
line = line[:-1]
23+
if line.startswith("#"):
24+
print(line.split(" {: #")[0])
25+
if not note_added and version_str in line:
26+
print(NOTE.format(docs_url=docs_url))
27+
note_added = True
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 }} $TAG_NAME)
158158
echo "body<<EOF" >> $GITHUB_OUTPUT
159159
echo "$NOTES" >> $GITHUB_OUTPUT
160160
echo "EOF" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)