|
45 | 45 | push: |
46 | 46 | tags: |
47 | 47 | - 'v*.*.*' # Matches v1.2.3 |
| 48 | + workflow_dispatch: |
| 49 | + inputs: |
| 50 | + version: |
| 51 | + description: 'Version to release (e.g., 0.1.0). Leave empty to use package.json version.' |
| 52 | + required: false |
| 53 | + type: string |
48 | 54 |
|
49 | 55 | jobs: |
50 | 56 | release: |
@@ -82,15 +88,25 @@ jobs: |
82 | 88 | working-directory: packages/opennextjs-mcp |
83 | 89 | run: pnpm build |
84 | 90 |
|
85 | | - - name: Extract version from tag |
| 91 | + - name: Extract version from tag or input |
86 | 92 | id: version |
87 | 93 | run: | |
88 | | - # Extract version from tag (e.g., v1.0.0 → 1.0.0) |
89 | | - TAG_NAME="${{ github.ref_name }}" |
90 | | - VERSION="${TAG_NAME#v}" |
| 94 | + # For workflow_dispatch, use input version or package.json version |
| 95 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 96 | + if [ -n "${{ github.event.inputs.version }}" ]; then |
| 97 | + VERSION="${{ github.event.inputs.version }}" |
| 98 | + else |
| 99 | + # Read from CLI package.json |
| 100 | + VERSION=$(node -p "require('./packages/opennextjs-cli/package.json').version") |
| 101 | + fi |
| 102 | + else |
| 103 | + # Extract version from tag (e.g., v1.0.0 → 1.0.0) |
| 104 | + TAG_NAME="${{ github.ref_name }}" |
| 105 | + VERSION="${TAG_NAME#v}" |
| 106 | + fi |
91 | 107 | |
92 | 108 | echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
93 | | - echo "Tag version: $VERSION" |
| 109 | + echo "Version: $VERSION" |
94 | 110 |
|
95 | 111 | - name: Verify CLI package.json version matches tag |
96 | 112 | working-directory: packages/opennextjs-cli |
@@ -130,35 +146,95 @@ jobs: |
130 | 146 | sudo apt-get update && sudo apt-get install -y git-cliff || \ |
131 | 147 | echo "⚠️ git-cliff installation failed, will skip changelog generation" >&2 |
132 | 148 |
|
133 | | - - name: Generate changelog |
| 149 | + - name: Generate package-specific changelog sections |
134 | 150 | env: |
135 | 151 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
136 | 152 | run: | |
137 | 153 | set -e |
138 | 154 | |
139 | 155 | TAG_VERSION="${{ steps.version.outputs.VERSION }}" |
| 156 | + TAG="v$TAG_VERSION" |
| 157 | + |
| 158 | + # Generate CLI changelog section (only commits affecting packages/opennextjs-cli/**) |
| 159 | + echo "📝 Generating CLI changelog section..." |
| 160 | + git-cliff \ |
| 161 | + --config cliff.toml \ |
| 162 | + --include-path "packages/opennextjs-cli/**" \ |
| 163 | + --tag "$TAG" \ |
| 164 | + --latest \ |
| 165 | + --unreleased \ |
| 166 | + --output /tmp/cli-changelog.md \ |
| 167 | + --verbose || \ |
| 168 | + echo "⚠️ CLI changelog generation failed" >&2 |
140 | 169 | |
141 | | - # Generate changelog with git-cliff (writes to root CHANGELOG.md) |
| 170 | + # Generate MCP changelog section (only commits affecting packages/opennextjs-mcp/**) |
| 171 | + echo "📝 Generating MCP changelog section..." |
142 | 172 | git-cliff \ |
143 | 173 | --config cliff.toml \ |
144 | | - --tag "v$TAG_VERSION" \ |
| 174 | + --include-path "packages/opennextjs-mcp/**" \ |
| 175 | + --tag "$TAG" \ |
| 176 | + --latest \ |
| 177 | + --unreleased \ |
| 178 | + --output /tmp/mcp-changelog.md \ |
145 | 179 | --verbose || \ |
146 | | - echo "⚠️ Changelog generation failed, will continue without it" >&2 |
| 180 | + echo "⚠️ MCP changelog generation failed" >&2 |
| 181 | + |
| 182 | + # Combine changelog sections |
| 183 | + echo "📝 Combining changelog sections..." |
| 184 | + |
| 185 | + # Start with version header |
| 186 | + echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md |
| 187 | + echo "" >> /tmp/changelog-section.md |
| 188 | + |
| 189 | + # Extract CLI section (skip header, get body) |
| 190 | + if [ -f /tmp/cli-changelog.md ] && [ -s /tmp/cli-changelog.md ]; then |
| 191 | + echo "### @jsonbored/opennextjs-cli" >> /tmp/changelog-section.md |
| 192 | + echo "" >> /tmp/changelog-section.md |
| 193 | + # Skip the header and version line, get the body |
| 194 | + tail -n +2 /tmp/cli-changelog.md | sed '/^## \[/,$d' >> /tmp/changelog-section.md || true |
| 195 | + echo "" >> /tmp/changelog-section.md |
| 196 | + fi |
147 | 197 | |
148 | | - # Extract changelog section for this version |
| 198 | + # Extract MCP section (skip header, get body) |
| 199 | + if [ -f /tmp/mcp-changelog.md ] && [ -s /tmp/mcp-changelog.md ]; then |
| 200 | + echo "### @jsonbored/opennextjs-mcp" >> /tmp/changelog-section.md |
| 201 | + echo "" >> /tmp/changelog-section.md |
| 202 | + # Skip the header and version line, get the body |
| 203 | + tail -n +2 /tmp/mcp-changelog.md | sed '/^## \[/,$d' >> /tmp/changelog-section.md || true |
| 204 | + echo "" >> /tmp/changelog-section.md |
| 205 | + fi |
| 206 | + |
| 207 | + # If no package-specific sections, create a generic one |
| 208 | + if [ ! -s /tmp/cli-changelog.md ] && [ ! -s /tmp/mcp-changelog.md ]; then |
| 209 | + echo "Initial release of OpenNext.js CLI and MCP server packages." >> /tmp/changelog-section.md |
| 210 | + echo "" >> /tmp/changelog-section.md |
| 211 | + fi |
| 212 | + |
| 213 | + # Update main CHANGELOG.md (prepend new section) |
149 | 214 | if [ -f CHANGELOG.md ]; then |
150 | | - # Extract the section for this version |
151 | | - awk "/^## \\[$TAG_VERSION\\]/,/^## \\[/ {if (/^## \\[/ && !/^## \\[$TAG_VERSION\\]/) exit; print}" CHANGELOG.md > /tmp/changelog-section.md || \ |
152 | | - echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md |
| 215 | + # Prepend new section to existing changelog |
| 216 | + cat /tmp/changelog-section.md CHANGELOG.md > /tmp/combined-changelog.md |
| 217 | + mv /tmp/combined-changelog.md CHANGELOG.md |
153 | 218 | else |
154 | | - echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md |
155 | | - echo "" >> /tmp/changelog-section.md |
156 | | - echo "Release $TAG_VERSION" >> /tmp/changelog-section.md |
| 219 | + # Create new changelog with header |
| 220 | + cat > CHANGELOG.md << 'EOF' |
| 221 | +# Changelog |
| 222 | + |
| 223 | +All notable changes to this project will be documented in this file. |
| 224 | + |
| 225 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 226 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 227 | + |
| 228 | +EOF |
| 229 | + cat /tmp/changelog-section.md >> CHANGELOG.md |
157 | 230 | fi |
158 | 231 |
|
| 232 | + # Set changelog section for GitHub release |
159 | 233 | echo "CHANGELOG_SECTION<<EOF" >> $GITHUB_ENV |
160 | 234 | cat /tmp/changelog-section.md >> $GITHUB_ENV |
161 | 235 | echo "EOF" >> $GITHUB_ENV |
| 236 | + |
| 237 | + echo "✅ Changelog generated successfully" |
162 | 238 |
|
163 | 239 | - name: Publish CLI to npm (try OIDC first) |
164 | 240 | id: publish-cli-oidc |
|
0 commit comments