Skip to content

Commit d2ddca2

Browse files
authored
CI: extract release notes from changelog and add them to release (#267)
* chore: add release notes generation script * ci: use generated release notes in releases
1 parent 81de06d commit d2ddca2

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

.github/generate_release_notes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import re
2+
3+
def main() -> None:
4+
"""Generate release notes for the latest GitHub release."""
5+
6+
with open("CHANGELOG.md", encoding="utf-8") as file:
7+
changelog = file.read()
8+
9+
first_section = re.search(r"^### ", changelog, re.MULTILINE)
10+
if first_section is None:
11+
raise RuntimeError("Could not find the first changelog section.")
12+
13+
next_release = re.search(r"^## ", changelog[first_section.start():], re.MULTILINE)
14+
15+
if next_release is None:
16+
raise RuntimeError("Could not find the next release heading.")
17+
18+
latest_changes = changelog[first_section.start() : first_section.start() + next_release.start()].strip()
19+
20+
release_notes = f"""A fast code formatter for GDScript in Godot 4.
21+
22+
## Changelog
23+
24+
{latest_changes}
25+
26+
Learn more about the formatter in the [GDScript Formatter documentation](https://www.gdquest.com/library/gdscript_formatter/)
27+
"""
28+
29+
print(release_notes)
30+
31+
if __name__ == "__main__":
32+
main()

.github/workflows/release.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,12 @@ jobs:
122122
path: artifacts
123123
merge-multiple: true
124124

125+
- name: Generate release notes
126+
run: python .github/generate_release_notes.py > release-notes.md
127+
125128
- name: Create Release
126129
run: |
127-
gh release create "${{ github.ref_name }}" \
128-
--verify-tag \
129-
--draft \
130-
--title "GDScript formatter ${{ github.ref_name }}" \
131-
--notes "A fast code formatter for GDScript in Godot 4.
132-
133-
You can learn how to install, use, configure, and integrate the formatter into your workflow on this page:
134-
135-
https://www.gdquest.com/library/gdscript_formatter/"
130+
gh release create "${{ github.ref_name }}" --verify-tag --draft --title "GDScript formatter ${{ github.ref_name }}" --notes-file release-notes.md
136131
137132
gh release upload "${{ github.ref_name }}" artifacts/*.zip
138133
gh release edit "${{ github.ref_name }}" --draft=false

0 commit comments

Comments
 (0)