Skip to content

Commit 9d5e1b0

Browse files
committed
Add automatic update of changelog.md file with every release
1 parent d9eb1aa commit 9d5e1b0

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,38 @@ jobs:
3636
git config --global user.email "github-actions[bot]@users.noreply.github.com"
3737
git config --global user.name "github-actions[bot]"
3838
39+
- name: Update CHANGELOG.md with release notes
40+
env:
41+
RELEASE_BODY: ${{ github.event.release.body }}
42+
RELEASE_TAG: ${{ github.event.release.tag_name }}
43+
RELEASE_DATE: ${{ github.event.release.published_at }}
44+
TARGET_BRANCH: ${{ github.event.release.target_commitish }}
45+
run: |
46+
python3 - <<'PYEOF'
47+
import os
48+
49+
tag = os.environ['RELEASE_TAG']
50+
body = os.environ['RELEASE_BODY'].strip()
51+
date = os.environ['RELEASE_DATE'][:10]
52+
53+
new_section = f"## [{tag}] - {date}\n\n{body}\n\n---\n\n"
54+
55+
with open('CHANGELOG.md', 'r') as f:
56+
content = f.read()
57+
58+
marker = '\n---\n'
59+
pos = content.index(marker) + len(marker)
60+
updated = content[:pos] + '\n' + new_section + content[pos:]
61+
62+
with open('CHANGELOG.md', 'w') as f:
63+
f.write(updated)
64+
65+
print(f"Added {tag} to CHANGELOG.md")
66+
PYEOF
67+
git add CHANGELOG.md
68+
git commit -m "Add release notes for ${RELEASE_TAG} to CHANGELOG.md [skip ci]"
69+
git push origin HEAD:"${TARGET_BRANCH}"
70+
3971
- name: Build and publish documentation
4072
run: |
4173
pip install mkdocs

0 commit comments

Comments
 (0)