@@ -125,10 +125,8 @@ jobs:
125125 - name : Generate release notes from CHANGELOG
126126 id : release_notes
127127 run : |
128- # Extract release notes from CHANGELOG.md for this version
129128 VERSION="${{ steps.tag_version.outputs.version }}"
130129
131- # Try to extract changelog section for this version
132130 if [ -f "CHANGELOG.md" ]; then
133131 # Extract content between [version] and next version or end of file
134132 awk "/^## \[$VERSION\]/,/^## \[/ {if (!/^## \[$VERSION\]/ && !/^## \[/) print}" CHANGELOG.md > /tmp/release_notes.md || true
@@ -140,31 +138,30 @@ jobs:
140138 echo "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details." >> /tmp/release_notes.md
141139 fi
142140
143- # Add header
144- echo "## 🎉 Release $VERSION" > /tmp/release_body.md
145- echo "" >> /tmp/release_body.md
146- cat /tmp/release_notes.md >> /tmp/release_body.md
147- echo "" >> /tmp/release_body.md
148- echo "---" >> /tmp/release_body.md
149- echo "" >> /tmp/release_body.md
150- # Get the previous tag for comparison
151- PREV_TAG=$(git describe --tags --abbrev=0 ${{ github.ref }}^ 2>/dev/null || echo "")
152- if [ -n "$PREV_TAG" ]; then
153- echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREV_TAG...${{ github.ref }}" >> /tmp/release_body.md
154- else
155- echo "**Full Changelog**: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref }}" >> /tmp/release_body.md
156- fi
141+ # Build release body
142+ {
143+ echo "## 🎉 Release $VERSION"
144+ echo ""
145+ cat /tmp/release_notes.md
146+ echo ""
147+ echo "---"
148+ echo ""
149+ # Get the previous tag for comparison
150+ PREV_TAG=$(git describe --tags --abbrev=0 "${{ steps.tag_version.outputs.tag_name }}^" 2>/dev/null || echo "")
151+ if [ -n "$PREV_TAG" ]; then
152+ echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREV_TAG...${{ steps.tag_version.outputs.tag_name }}"
153+ else
154+ echo "**Full Changelog**: https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.tag_name }}"
155+ fi
156+ } > /tmp/release_body.md
157157 else
158- echo "## 🎉 Release $VERSION" > /tmp/release_body.md
159- echo "" >> /tmp/release_body.md
160- echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.ref }}" >> /tmp/release_body.md
158+ {
159+ echo "## 🎉 Release $VERSION"
160+ echo ""
161+ echo "**Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.tag_version.outputs.tag_name }}"
162+ } > /tmp/release_body.md
161163 fi
162164
163- # Output for GitHub Actions
164- echo "body<<EOF" >> $GITHUB_OUTPUT
165- cat /tmp/release_body.md >> $GITHUB_OUTPUT
166- echo "EOF" >> $GITHUB_OUTPUT
167-
168165 - name : Create GitHub Release
169166 uses : softprops/action-gh-release@v2
170167 with :
@@ -188,10 +185,46 @@ jobs:
188185 id : deployment
189186 uses : actions/deploy-pages@v4
190187
191- - name : Upload build artifacts (optional)
188+ - name : Sync package.json version to main branch
189+ if : success()
190+ continue-on-error : true # Don't fail the workflow if this step fails
191+ run : |
192+ VERSION="${{ steps.tag_version.outputs.version }}"
193+
194+ # Configure git
195+ git config --local user.email "action@github.com"
196+ git config --local user.name "GitHub Action"
197+
198+ # Fetch main branch and check it out
199+ git fetch origin main
200+ git checkout main
201+
202+ # Check if package.json needs updating
203+ CURRENT_VERSION=$(node -p "require('./package.json').version")
204+ if [ "$CURRENT_VERSION" = "$VERSION" ]; then
205+ echo "✅ package.json already has version $VERSION, no commit needed"
206+ exit 0
207+ fi
208+
209+ # Update package.json version
210+ node -e "
211+ const fs = require('fs');
212+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
213+ pkg.version = '$VERSION';
214+ fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
215+ console.log('Updated package.json version to', '$VERSION');
216+ "
217+
218+ # Commit and push
219+ git add package.json
220+ git commit -m "chore: update version to $VERSION [skip ci]"
221+ git push origin main
222+ echo "✅ Committed and pushed updated package.json to main"
223+
224+ - name : Upload build artifacts
225+ if : success()
192226 uses : actions/upload-artifact@v4
193227 with :
194228 name : build-artifacts-${{ steps.tag_version.outputs.version }}
195229 path : out/
196230 retention-days : 30
197-
0 commit comments