From 0f370612994eb215906f3ea5bb28a5a5b99b02cb Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 26 Sep 2025 17:01:39 -0400 Subject: [PATCH] Refactor release notes generation in CI workflow - Updated the GitHub Actions workflow to utilize a dedicated Python script for extracting changelog information based on the release version. - Removed the previous inline changelog generation logic, streamlining the process and improving maintainability. - Added a new script, `extract_changelog.py`, to handle changelog extraction from the documentation, ensuring accurate release notes for each version. --- .github/workflows/release.yml | 62 ++--------------------- scripts/extract_changelog.py | 94 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 57 deletions(-) create mode 100755 scripts/extract_changelog.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 40b464bc..6c50e9b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,64 +31,12 @@ jobs: - name: Generate release notes id: release_notes run: | - # Generate changelog from commits since last tag - LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") - if [ -z "$LAST_TAG" ]; then - CHANGES=$(git log --pretty=format:"- %s" HEAD) - else - CHANGES=$(git log --pretty=format:"- %s" ${LAST_TAG}..HEAD) - fi + # Extract release version from tag + VERSION="${{ github.ref_name || github.event.inputs.tag }}" + VERSION_NUM=$(echo "$VERSION" | sed 's/^v//') - cat > release_notes.md << EOF - # Yaze v0.3.0 Release Notes - - ## New Features - - **Asar 65816 Assembler Integration**: Full cross-platform support for ROM patching with assembly code - - **Symbol Extraction**: Extract symbol names and opcodes from assembly files - - **ZSCustomOverworld v3 Support**: Enhanced overworld editing capabilities - - **Message Editing**: Improved text editing interface - - **GUI Docking**: Enhanced docking system for better workflow - - **Modern CMake Build System**: Updated to CMake 3.16+ with improved cross-platform support - - ## Improvements - - Enhanced cross-platform compatibility (Windows, macOS, Linux) - - Modernized CI/CD pipeline with comprehensive testing - - Improved error handling and logging - - Better memory management and performance optimizations - - ## Bug Fixes - - Fixed Asar integration issues across different platforms - - Resolved build system inconsistencies - - Improved stability and reliability - - ## Technical Changes - $CHANGES - - ## Download Instructions - - ### Windows - - Download \`yaze-windows-x64.zip\` for 64-bit Windows - - Download \`yaze-windows-x86.zip\` for 32-bit Windows - - Extract and run \`yaze.exe\` - - ### macOS - - Download \`yaze-macos.dmg\` - - Mount the DMG and drag Yaze to Applications - - You may need to allow the app in System Preferences > Security & Privacy - - ### Linux - - Download \`yaze-linux-x64.tar.gz\` - - Extract: \`tar -xzf yaze-linux-x64.tar.gz\` - - Run: \`./yaze\` - - ## System Requirements - - **Windows**: Windows 10 or later (64-bit recommended) - - **macOS**: macOS 10.15 (Catalina) or later - - **Linux**: Ubuntu 20.04 or equivalent, with X11 or Wayland - - ## Support - For issues and questions, please visit our [GitHub Issues](https://github.com/scawful/yaze/issues) page. - EOF + # Generate release notes using the dedicated script + python3 scripts/extract_changelog.py "$VERSION_NUM" > release_notes.md - name: Create Release id: create_release diff --git a/scripts/extract_changelog.py b/scripts/extract_changelog.py new file mode 100755 index 00000000..472de8c0 --- /dev/null +++ b/scripts/extract_changelog.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +""" +Extract changelog section for a specific version from docs/C1-changelog.md +Usage: python3 extract_changelog.py +Example: python3 extract_changelog.py 0.3.0 +""" + +import re +import sys +import os + +def extract_version_changelog(version_num, changelog_file): + """Extract changelog section for specific version""" + try: + with open(changelog_file, 'r') as f: + content = f.read() + + # Find the section for this version + version_pattern = rf"## {re.escape(version_num)}\s*\([^)]+\)" + next_version_pattern = r"## \d+\.\d+\.\d+\s*\([^)]+\)" + + # Find start of current version section + version_match = re.search(version_pattern, content) + if not version_match: + return f"Changelog section not found for version {version_num}." + + start_pos = version_match.end() + + # Find start of next version section + remaining_content = content[start_pos:] + next_match = re.search(next_version_pattern, remaining_content) + + if next_match: + end_pos = start_pos + next_match.start() + section_content = content[start_pos:end_pos].strip() + else: + section_content = remaining_content.strip() + + return section_content + + except Exception as e: + return f"Error reading changelog: {str(e)}" + +def main(): + if len(sys.argv) != 2: + print("Usage: python3 extract_changelog.py ") + sys.exit(1) + + version_num = sys.argv[1] + changelog_file = "docs/C1-changelog.md" + + # Check if changelog file exists + if not os.path.exists(changelog_file): + print(f"Error: Changelog file {changelog_file} not found") + sys.exit(1) + + # Extract changelog content + changelog_content = extract_version_changelog(version_num, changelog_file) + + # Generate full release notes + release_notes = f"""# Yaze v{version_num} Release Notes + +{changelog_content} + +## Download Instructions + +### Windows +- Download `yaze-windows-x64.zip` for 64-bit Windows +- Download `yaze-windows-x86.zip` for 32-bit Windows +- Extract and run `yaze.exe` + +### macOS +- Download `yaze-macos.dmg` +- Mount the DMG and drag Yaze to Applications +- You may need to allow the app in System Preferences > Security & Privacy + +### Linux +- Download `yaze-linux-x64.tar.gz` +- Extract: `tar -xzf yaze-linux-x64.tar.gz` +- Run: `./yaze` + +## System Requirements +- **Windows**: Windows 10 or later (64-bit recommended) +- **macOS**: macOS 10.15 (Catalina) or later +- **Linux**: Ubuntu 20.04 or equivalent, with X11 or Wayland + +## Support +For issues and questions, please visit our [GitHub Issues](https://github.com/scawful/yaze/issues) page. +""" + + print(release_notes) + +if __name__ == "__main__": + main()