From 5d4ba245f5ba186afbe7e71cccc85f2dd614cab8 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sat, 13 Sep 2025 13:03:00 +0200 Subject: [PATCH] feat: integrate changelog directly into PR merge commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 **Improved Changelog Integration:** - Changelog is now appended to the PR merge commit message instead of creating a separate commit - Version bump changes are included in the same amended merge commit - Uses git commit --amend to modify the merge commit with both changelog and version changes - Updated force push with --force-with-lease for safer history rewriting - Cleaner git history with single commit containing all release information **Benefits:** - ✅ Single commit per release (cleaner history) - ✅ Changelog directly visible in merge commit - ✅ No additional 'chore: bump version' commits - ✅ All release info consolidated in one place - ✅ Safer force push with --force-with-lease --- .github/workflows/version-and-publish.yml | 25 +++++++++++++++++++---- VERSION_WORKFLOW.md | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/version-and-publish.yml b/.github/workflows/version-and-publish.yml index 4d571e7..2cfeb8a 100644 --- a/.github/workflows/version-and-publish.yml +++ b/.github/workflows/version-and-publish.yml @@ -130,6 +130,23 @@ jobs: echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + - name: Update merge commit with changelog + if: steps.version-type.outputs.type != 'none' + run: | + # Get the merge commit (HEAD) + MERGE_COMMIT=$(git rev-parse HEAD) + + # Get original commit message + ORIGINAL_MSG=$(git log -1 --format=%B) + + # Create new commit message with changelog + NEW_MSG="$ORIGINAL_MSG + + ${{ steps.changelog.outputs.changelog }}" + + # Amend the merge commit with the new message + git commit --amend -m "$NEW_MSG" + - name: Version bump if: steps.version-type.outputs.type != 'none' id: version-bump @@ -145,7 +162,7 @@ jobs: NEW_VERSION=$(node -p "require('./package.json').version") echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT - # Create commit with changelog + # Stage version changes git add package.json # Add lockfile if it exists (npm version might create package-lock.json) if [ -f package-lock.json ]; then @@ -154,9 +171,9 @@ jobs: if [ -f pnpm-lock.yaml ]; then git add pnpm-lock.yaml fi - git commit -m "chore: bump version to v$NEW_VERSION - ${{ steps.changelog.outputs.changelog }}" + # Amend the merge commit to include version changes + git commit --amend --no-edit # Create git tag git tag -a "v$NEW_VERSION" -m "Version $NEW_VERSION @@ -168,7 +185,7 @@ jobs: - name: Push version changes if: steps.version-type.outputs.type != 'none' run: | - git push origin main + git push --force-with-lease origin main git push origin --tags - name: Publish to NPM diff --git a/VERSION_WORKFLOW.md b/VERSION_WORKFLOW.md index 69e714c..e12bdcc 100644 --- a/VERSION_WORKFLOW.md +++ b/VERSION_WORKFLOW.md @@ -84,6 +84,7 @@ Make sure these secrets are configured in your GitHub repository: - ✅ Automatic version bumping based on branch - ✅ AI-generated changelog using Claude Code CLI +- ✅ Appends changelog to PR merge commit message - ✅ Runs tests before publishing - ✅ Builds the package before publishing - ✅ Creates git tags with changelog in tag message @@ -102,7 +103,7 @@ The workflow automatically generates a standardized changelog for each release u - ⚡ **Performance** - Performance optimizations The generated changelog is included in: -- The version bump commit message +- The PR merge commit message (automatically appended) - The git tag message - The GitHub release notes