diff --git a/.github/workflows/version-and-publish.yml b/.github/workflows/version-and-publish.yml index a3e0e5f..c429894 100644 --- a/.github/workflows/version-and-publish.yml +++ b/.github/workflows/version-and-publish.yml @@ -130,7 +130,7 @@ jobs: echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - - name: Update merge commit with changelog + - name: Create single squashed commit with changelog if: steps.version-type.outputs.type != 'none' run: | # Extract version type for commit title @@ -149,10 +149,21 @@ jobs: ${{ steps.changelog.outputs.changelog }}" - # Amend the merge commit with the clean message - git commit --amend -m "$NEW_MSG" + # Get the previous commit (before the merge/PR commits) + # This assumes we want to squash everything since the last release + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -n "$LAST_TAG" ]; then + BASE_COMMIT=$LAST_TAG + else + # If no tags, use the commit before this PR + BASE_COMMIT=$(git log --oneline --skip=10 -1 --format="%H" 2>/dev/null || git log --max-parents=0 --format="%H") + fi - - name: Version bump + # Reset to the base and create a single squashed commit + git reset --soft $BASE_COMMIT + git commit -m "$NEW_MSG" + + - name: Version bump and finalize commit if: steps.version-type.outputs.type != 'none' id: version-bump run: | @@ -177,7 +188,7 @@ jobs: git add pnpm-lock.yaml fi - # Amend the merge commit to include version changes + # Amend the squashed commit to include version changes git commit --amend --no-edit # Create git tag @@ -185,7 +196,7 @@ jobs: ${{ steps.changelog.outputs.changelog }}" - echo "Version bumped from $CURRENT_VERSION to $NEW_VERSION" + echo "Created single squashed commit with version bump from $CURRENT_VERSION to $NEW_VERSION" - name: Push version changes if: steps.version-type.outputs.type != 'none' diff --git a/VERSION_WORKFLOW.md b/VERSION_WORKFLOW.md index e12bdcc..f271797 100644 --- a/VERSION_WORKFLOW.md +++ b/VERSION_WORKFLOW.md @@ -84,7 +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 +- ✅ Squashes all PR commits into single clean commit - ✅ Runs tests before publishing - ✅ Builds the package before publishing - ✅ Creates git tags with changelog in tag message @@ -103,10 +103,37 @@ The workflow automatically generates a standardized changelog for each release u - ⚡ **Performance** - Performance optimizations The generated changelog is included in: -- The PR merge commit message (automatically appended) +- The single squashed release commit message - The git tag message - The GitHub release notes +## Git History Structure + +The workflow creates an ultra-clean git history by squashing all commits from the PR into a single release commit: + +**Before Squashing:** +``` +abc123 feat: add email scheduling +def456 fix: validation bug +ghi789 docs: update readme +jkl012 test: add unit tests +``` + +**After Squashing:** +``` +abc123 ✨ Minor Release + +## Changes +### 🚀 Features +- Add email scheduling feature +### 🐛 Bug Fixes +- Fix validation error handling +### 📚 Documentation +- Update readme with new examples +``` + +This results in one meaningful commit per release with all changes summarized in the AI-generated changelog. + ## Version Branch Maintenance Keep version branches up to date by periodically merging from main: