Skip to content

Commit 58b8427

Browse files
committed
move logic to python
1 parent 34c1544 commit 58b8427

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

.github/scripts/parse_changelog.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""Parse CHANGELOG.md and extract the latest version and release notes."""
33

4-
import json
4+
import os
55
import re
66
import sys
77

@@ -38,9 +38,20 @@ def parse_changelog(filepath="CHANGELOG.md"):
3838
else:
3939
body = remaining.strip()
4040

41-
return {"version": version, "tag": f"v{version}", "date": date, "body": body}
41+
# Write release body to file for gh command
42+
with open("release_body.txt", "w") as f:
43+
f.write(body)
44+
45+
# Write to GitHub Actions output
46+
github_output = os.getenv("GITHUB_OUTPUT")
47+
if github_output:
48+
with open(github_output, "a") as f:
49+
f.write(f"version={version}\n")
50+
f.write(f"tag=v{version}\n")
51+
52+
print(f"Parsed version {version} (tag: v{version})")
53+
print(f"Release body: {len(body)} characters")
4254

4355

4456
if __name__ == "__main__":
45-
result = parse_changelog()
46-
print(json.dumps(result))
57+
parse_changelog()

.github/workflows/auto-release.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
# paths:
8-
# - 'CHANGELOG.md'
7+
paths:
8+
- 'CHANGELOG.md'
99

1010
jobs:
1111
create-release:
@@ -21,11 +21,7 @@ jobs:
2121

2222
- name: Parse Changelog
2323
id: changelog
24-
run: |
25-
RESULT=$(python3 .github/scripts/parse_changelog.py)
26-
echo "version=$(echo "$RESULT" | jq -r '.version')" >> $GITHUB_OUTPUT
27-
echo "tag=$(echo "$RESULT" | jq -r '.tag')" >> $GITHUB_OUTPUT
28-
echo "body=$(echo "$RESULT" | jq -r '.body')" >> $GITHUB_OUTPUT
24+
run: python3 .github/scripts/parse_changelog.py
2925

3026
- name: Check if release exists
3127
id: check_release
@@ -49,11 +45,10 @@ jobs:
4945
run: |
5046
TAG="${{ steps.changelog.outputs.tag }}"
5147
VERSION="${{ steps.changelog.outputs.version }}"
52-
BODY="${{ steps.changelog.outputs.body }}"
5348
5449
gh release create "$TAG" \
5550
--title "Release $VERSION" \
56-
--notes "$BODY" \
51+
--notes-file release_body.txt \
5752
--verify-tag
5853
5954
- name: Skip Release

0 commit comments

Comments
 (0)