|
1 | 1 | name: Create Release |
2 | 2 |
|
| 3 | +# This workflow automatically creates GitHub releases when the version file is updated |
| 4 | +# It extracts changelog information from README.md (preferred) or CHANGELOG.md (fallback) |
| 5 | +# Version information is read from the 'version' file in the repository root |
| 6 | + |
3 | 7 | on: |
4 | 8 | push: |
5 | 9 | branches: [ main ] |
@@ -45,94 +49,117 @@ jobs: |
45 | 49 | if: steps.check.outputs.changed == 'true' |
46 | 50 | run: | |
47 | 51 | VERSION="${{ steps.version.outputs.version }}" |
| 52 | + echo "Extracting changelog for version $VERSION from README.md" |
| 53 | + |
| 54 | + # Try to extract changelog from README.md for the current version |
| 55 | + if [ -f "README.md" ]; then |
| 56 | + # Extract the changelog section for the current version from README.md |
| 57 | + # Look for the version section pattern: ## 🎯 Version X.X.X Release |
| 58 | + CHANGELOG=$(awk -v version="$VERSION" ' |
| 59 | + BEGIN { found=0; collecting=0; content="" } |
| 60 | + |
| 61 | + # Match the version header pattern |
| 62 | + /^## 🎯 Version [0-9]+\.[0-9]+\.[0-9]+ Release/ { |
| 63 | + if ($0 ~ "Version " version " Release") { |
| 64 | + found=1 |
| 65 | + collecting=1 |
| 66 | + content = content $0 "\n" |
| 67 | + next |
| 68 | + } |
| 69 | + if (found && collecting) { |
| 70 | + # Stop collecting when we hit another version section |
| 71 | + collecting=0 |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + # Collect content until we hit another ## heading (but not ###) |
| 76 | + /^## / && !/^## 🎯 Version [0-9]+\.[0-9]+\.[0-9]+ Release/ { |
| 77 | + if (collecting) { |
| 78 | + collecting=0 |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + # Collect all lines while in the target version section |
| 83 | + collecting && !/^## 🎯 Version [0-9]+\.[0-9]+\.[0-9]+ Release/ { |
| 84 | + content = content $0 "\n" |
| 85 | + } |
| 86 | + |
| 87 | + END { |
| 88 | + if (found) { |
| 89 | + print content |
| 90 | + } else { |
| 91 | + print "" |
| 92 | + } |
| 93 | + } |
| 94 | + ' README.md) |
| 95 | + |
| 96 | + # If we found content in README.md, use it |
| 97 | + if [ -n "$CHANGELOG" ] && [ "$CHANGELOG" != " " ]; then |
| 98 | + echo "Found changelog in README.md for version $VERSION" |
| 99 | + # Add footer with full changelog link |
| 100 | + FOOTER="\n\n**Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/v$VERSION)" |
| 101 | + CHANGELOG="$CHANGELOG$FOOTER" |
| 102 | + else |
| 103 | + echo "No specific changelog found in README.md for version $VERSION, checking CHANGELOG.md" |
| 104 | + |
| 105 | + # Fallback: Try to extract from CHANGELOG.md if it exists |
| 106 | + if [ -f "CHANGELOG.md" ]; then |
| 107 | + CHANGELOG_MD=$(awk -v version="$VERSION" ' |
| 108 | + BEGIN { found=0; collecting=0; content="" } |
| 109 | + |
| 110 | + # Match version header in CHANGELOG.md: ## [X.X.X] - YYYY-MM-DD |
| 111 | + /^## \[/ { |
| 112 | + if ($0 ~ "\\[" version "\\]") { |
| 113 | + found=1 |
| 114 | + collecting=1 |
| 115 | + content = content $0 "\n" |
| 116 | + next |
| 117 | + } |
| 118 | + if (found && collecting) { |
| 119 | + collecting=0 |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + # Stop at next version section |
| 124 | + /^## \[/ && collecting { |
| 125 | + collecting=0 |
| 126 | + } |
| 127 | + |
| 128 | + # Collect content while in target version |
| 129 | + collecting { |
| 130 | + content = content $0 "\n" |
| 131 | + } |
| 132 | + |
| 133 | + END { |
| 134 | + if (found) { |
| 135 | + print content |
| 136 | + } |
| 137 | + } |
| 138 | + ' CHANGELOG.md) |
| 139 | + |
| 140 | + if [ -n "$CHANGELOG_MD" ]; then |
| 141 | + CHANGELOG="## 🚀 PiHoleVault v$VERSION\n\n$CHANGELOG_MD\n\n**Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/v$VERSION)" |
| 142 | + else |
| 143 | + # Final fallback: Generic changelog |
| 144 | + CHANGELOG="## 🚀 PiHoleVault v$VERSION\n\nAutomatically generated release from version file update.\n\n### Changes\n- Updated to version $VERSION\n- See commit history for detailed changes\n\n**Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/v$VERSION)" |
| 145 | + fi |
| 146 | + else |
| 147 | + # No CHANGELOG.md, use generic |
| 148 | + CHANGELOG="## 🚀 PiHoleVault v$VERSION\n\nAutomatically generated release from version file update.\n\n### Changes\n- Updated to version $VERSION\n- See commit history for detailed changes\n\n**Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/v$VERSION)" |
| 149 | + fi |
| 150 | + fi |
| 151 | + else |
| 152 | + echo "README.md not found, generating generic changelog" |
| 153 | + CHANGELOG="## 🚀 PiHoleVault v$VERSION\n\nAutomatically generated release from version file update.\n\n**Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/v$VERSION)" |
| 154 | + fi |
48 | 155 | |
49 | | - # Create a comprehensive changelog based on recent commits and version |
50 | | - case "$VERSION" in |
51 | | - "1.5.0") |
52 | | - CHANGELOG=$(cat << 'EOF' |
53 | | - ## 🚀 PiHoleVault v1.5.0 - Multi-Architecture Support |
54 | | - |
55 | | - This release introduces comprehensive multi-architecture support, enabling PiHoleVault to run natively on a wide range of devices and platforms. |
56 | | - |
57 | | - ### ✨ New Features |
58 | | - |
59 | | - - **🌍 Multi-Architecture Docker Images**: Native support for AMD64, ARM64, and ARMv7 architectures |
60 | | - - **🏗️ Enhanced Build System**: New Docker Buildx-based build pipeline with GitHub Actions integration |
61 | | - - **🛠️ Local Development Tools**: New `build-multiarch.sh` script for local multi-platform development and testing |
62 | | - - **📦 Automated CI/CD**: GitHub Actions automatically builds and pushes multi-architecture images to Docker Hub |
63 | | - - **🔄 Release Automation**: Automatic GitHub releases when version file is updated |
64 | | - |
65 | | - ### 🏗️ Architecture Support |
66 | | - |
67 | | - | Platform | Architecture | Compatible Devices | |
68 | | - |----------|-------------|-------------------| |
69 | | - | `linux/amd64` | x86_64 | Intel/AMD servers, desktop PCs | |
70 | | - | `linux/arm64` | aarch64 | Raspberry Pi 4+, Apple Silicon, AWS Graviton | |
71 | | - | `linux/arm/v7` | armv7l | Raspberry Pi 3, older ARM devices | |
72 | | - |
73 | | - ### 🔧 Technical Improvements |
74 | | - |
75 | | - - **📋 OCI Image Labels**: Added comprehensive metadata labels to Docker images |
76 | | - - **⚡ Build Optimization**: Improved cross-platform compilation with build cache optimization |
77 | | - - **🏷️ Version Synchronization**: Synchronized versions across all package.json files |
78 | | - - **📖 Enhanced Documentation**: Updated README with multi-architecture information and usage examples |
79 | | - - **🚨 Legacy Script Deprecation**: Updated legacy build scripts with proper migration guidance |
80 | | - |
81 | | - ### 🔄 Migration & Compatibility |
82 | | - |
83 | | - - **✅ Zero Breaking Changes**: Existing deployments continue to work seamlessly |
84 | | - - **🔄 Automatic Platform Detection**: Docker automatically selects the correct architecture |
85 | | - - **⚡ Performance Improvements**: ARM devices now use native images instead of emulation |
86 | | - - **📦 Single Image Tag**: Same `theinfamoustoto/piholevault:latest` works across all platforms |
87 | | - |
88 | | - ### 🛠️ Development Workflow |
89 | | - |
90 | | - **For Production Deployment:** |
91 | | - 1. Make code changes |
92 | | - 2. Test locally: `./build-multiarch.sh build` |
93 | | - 3. Push to Git: `git push origin main` |
94 | | - 4. GitHub Actions automatically builds and deploys multi-arch images |
95 | | - |
96 | | - **For Local Development:** |
97 | | - 1. Setup: `./build-multiarch.sh setup` |
98 | | - 2. Build & Test: `./build-multiarch.sh build` |
99 | | - |
100 | | - ### 📋 Verification |
101 | | - |
102 | | - To verify multi-architecture support: |
103 | | - ```bash |
104 | | - # Check available platforms |
105 | | - docker buildx imagetools inspect theinfamoustoto/piholevault:latest |
106 | | - |
107 | | - # Test specific platform |
108 | | - docker run --rm --platform=linux/arm64 theinfamoustoto/piholevault:latest echo "ARM64 works!" |
109 | | - ``` |
110 | | - |
111 | | - ### 🙏 Acknowledgments |
112 | | - |
113 | | - This release significantly expands PiHoleVault's compatibility and deployment options. Special thanks to the Docker Buildx team and GitHub Actions for making multi-architecture builds seamless. |
114 | | - |
115 | | - --- |
116 | | - |
117 | | - **Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/compare/v1.4.0...v1.5.0) |
118 | | - EOF |
119 | | - ) |
120 | | - ;; |
121 | | - *) |
122 | | - # Generic changelog for other versions |
123 | | - CHANGELOG="## Release $VERSION |
124 | | -
|
125 | | - Automatically generated release from version file update. |
126 | | -
|
127 | | - See commit history for detailed changes. |
128 | | - |
129 | | - **Full Changelog**: [View all changes](https://github.com/TheInfamousToTo/PiHoleVault/commits/$VERSION)" |
130 | | - ;; |
131 | | - esac |
| 156 | + # Debug output |
| 157 | + echo "Generated changelog preview:" |
| 158 | + echo "$CHANGELOG" | head -10 |
132 | 159 | |
133 | 160 | # Save changelog to output (GitHub Actions multiline string) |
134 | 161 | echo "changelog<<EOF" >> $GITHUB_OUTPUT |
135 | | - echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 162 | + printf "%b\n" "$CHANGELOG" >> $GITHUB_OUTPUT |
136 | 163 | echo "EOF" >> $GITHUB_OUTPUT |
137 | 164 | |
138 | 165 | - name: Check if tag exists |
|
0 commit comments