|
53 | 53 | # Try to extract changelog from CHANGELOG.md first |
54 | 54 | if [ -f "CHANGELOG.md" ]; then |
55 | 55 | # Look for the version section in CHANGELOG.md |
56 | | - python3 << 'EOF' > release_notes.md |
57 | | -import re |
58 | | -import sys |
59 | | - |
60 | | -def extract_version_changelog(version): |
61 | | - try: |
62 | | - with open('CHANGELOG.md', 'r', encoding='utf-8') as f: |
63 | | - content = f.read() |
64 | | - |
65 | | - # Look for version section (matches [X.X.X] or [Unreleased]) |
66 | | - version_pattern = rf'\[{re.escape(version)}\].*?(?=\n## |\n\[|$)' |
67 | | - match = re.search(version_pattern, content, re.DOTALL | re.MULTILINE) |
68 | | - |
69 | | - if match: |
70 | | - # Extract the content and clean it up |
71 | | - section = match.group(0) |
72 | | - # Remove the version header line |
73 | | - lines = section.split('\n')[1:] |
74 | | - # Remove empty lines at the start |
75 | | - while lines and not lines[0].strip(): |
76 | | - lines.pop(0) |
77 | | - changelog_content = '\n'.join(lines).strip() |
78 | | - |
79 | | - if changelog_content: |
80 | | - print(changelog_content) |
81 | | - return True |
82 | | - |
83 | | - return False |
84 | | - except Exception as e: |
85 | | - print(f"Error reading CHANGELOG.md: {e}", file=sys.stderr) |
86 | | - return False |
87 | | - |
88 | | -# Try to get version-specific changelog |
89 | | -version = sys.argv[1] if len(sys.argv) > 1 else "0.0.0" |
90 | | -if not extract_version_changelog(version): |
91 | | - # If no specific version found, check for [Unreleased] |
92 | | - if not extract_version_changelog("Unreleased"): |
93 | | - print("## What's Changed\n\nSee CHANGELOG.md for detailed changes.") |
94 | | -EOF |
95 | 56 | python3 << 'EOF' "$VERSION" > release_notes.md |
96 | 57 | import re |
97 | 58 | import sys |
|
0 commit comments