Generate a changelog from git history since the last tag or a specified reference point.
- Find the latest tag:
git describe --tags --abbrev=0 2>/dev/null || echo "initial". - Get all commits since that tag:
git log <tag>..HEAD --oneline --no-merges. - Parse each commit message to extract type, scope, and subject.
- Group commits by type with these categories:
- Features (
feat) - Bug Fixes (
fix) - Performance (
perf) - Refactoring (
refactor) - Documentation (
docs) - Tests (
test) - Chores (
chore)
- Features (
- Within each group, sort by scope alphabetically.
- Highlight breaking changes in a separate section at the top.
- Output the changelog in Keep a Changelog format.
## [Unreleased] - YYYY-MM-DD
### Breaking Changes
- scope: description of breaking change
### Features
- scope: description of new feature
### Bug Fixes
- scope: description of fix
### Performance
- scope: description of improvement- Only include types that have entries. Skip empty sections.
- If commits do not follow conventional commit format, group them under "Other Changes".
- Include commit hashes as references for traceability.
- Suggest a version bump: patch (fixes only), minor (features), major (breaking changes).