Skip to content

Commit

Permalink
[ci] Make changelog generation working again (#7058)
Browse files Browse the repository at this point in the history
Issue: #6114 

### Brief Summary
  • Loading branch information
feisuzhu authored Jan 5, 2023
1 parent 09eeba3 commit 3305acc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ jobs:
if: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: 3.9
Expand All @@ -350,14 +353,8 @@ jobs:
id: changelog
run: |
pip3 install gitpython
content=$(python3 misc/make_changelog.py)
echo $content
# Escape multiline strings:
# https://renehernandez.io/snippets/multiline-strings-as-a-job-output-in-github-actions/
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "content=$content" >> $GITHUB_OUTPUT
python3 misc/make_changelog.py > CHANGELOG.md
cat CHANGELOG.md
- name: Create tag
run: |
Expand All @@ -369,5 +366,6 @@ jobs:
- name: Publish release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.content }}
body_path: CHANGELOG.md
generate_release_notes: true
tag_name: ${{ github.event.inputs.version }}
9 changes: 1 addition & 8 deletions misc/make_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def load_pr_tags():
def find_latest_tag_commit(tags):
for tag in reversed(tags):
s = re.match(r'v\s*([\d.]+)', tag.name)
print(f'Latest version tag is: {tag.name}')
print(f'Latest version tag is: {tag.name}', file=sys.stderr)
if s is not None:
return tag.commit

Expand All @@ -43,7 +43,6 @@ def format(c):
return f'{c.summary} (by **{c.author}**)'

notable_changes = {}
all_changes = []

details = load_pr_tags()

Expand Down Expand Up @@ -75,18 +74,12 @@ def format(c):
f'** Warning: tag {tag.lower()} undefined in the "details" dict. Please include the tag into "details", unless the tag is a typo.'
)

all_changes.append(format(c))

res = 'Highlights:\n'
for tag in sorted(notable_changes.keys()):
res += f' - **{details[tag]}**\n'
for item in notable_changes[tag]:
res += f' - {item}\n'

res += '\nFull changelog:\n'
for c in all_changes:
res += f' - {c}\n'

return res


Expand Down

0 comments on commit 3305acc

Please sign in to comment.