Categories We Write About

Automatically generate changelogs

Automatically generating changelogs can be accomplished through tools and practices that parse commit messages, track changes in your codebase, and format the output into human-readable changelog files. Here’s how you can set it up:


1. Follow a Conventional Commit Format

To generate changelogs automatically, your commits should follow a structured format like Conventional Commits, such as:

pgsql
feat: add user login functionality fix: correct typo in dashboard title chore: update dependencies

Common tags:

  • feat: a new feature

  • fix: a bug fix

  • docs: documentation changes

  • style: code style changes (formatting, missing semi colons, etc.)

  • refactor: code refactoring

  • test: adding or updating tests

  • chore: maintenance tasks


2. Use Changelog Generation Tools

Here are some popular tools that automate changelog creation:

a. standard-version (Node.js)

A powerful tool for versioning and changelog generation using Conventional Commits.

bash
npm install --save-dev standard-version

Usage:

bash
npx standard-version

Generates or updates a CHANGELOG.md and bumps version in package.json.


b. conventional-changelog CLI

Install globally:

bash
npm install -g conventional-changelog-cli

Generate changelog:

bash
conventional-changelog -p angular -i CHANGELOG.md -s

c. release-it

Customizable release automation tool.

bash
npm install --save-dev release-it

Config in .release-it.json or package.json:

json
{ "plugins": { "@release-it/conventional-changelog": { "preset": "angular" } } }

Run with:

bash
npx release-it

d. GitHub Actions for Automation

You can automate changelog generation during CI/CD with GitHub Actions. Example workflow:

yaml
name: Generate Changelog on: push: tags: - 'v*' jobs: changelog: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Generate Changelog run: npx conventional-changelog -p angular -i CHANGELOG.md -s

3. Best Practices

  • Commit discipline: Enforce Conventional Commits with a pre-commit hook (e.g., via Husky).

  • Semantic versioning: Combine with tools that bump versions based on commit type (feat = minor, fix = patch).

  • Review changelogs: Automatically generated logs should still be reviewed before publishing.


4. Additional Tools

  • Gitmoji + gitmoji-changelog: If using emoji-based commit messages.

  • Keep a Changelog format: Some tools can format the output following keepachangelog.com.

  • Semantic Release: Fully automates the release process with changelogs, versioning, and publishing.


Summary

By adopting structured commit messages and using tools like standard-version or conventional-changelog, you can automate changelog generation efficiently. Integration with CI/CD pipelines ensures your changelogs remain consistent and up to date without manual effort.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About