Skip to content
Latchkey

How to Generate a Changelog With conventional-changelog in GitHub Actions

The conventional-changelog CLI reads commits since the last tag and prepends a new release section to CHANGELOG.md using a preset such as angular.

Run npx conventional-changelog-cli -p angular -i CHANGELOG.md -s after tagging, then commit the updated file or include it in the release body.

Steps

  • Check out with full history so all tags are visible.
  • Run the CLI with -p angular -i CHANGELOG.md -s to update in place.
  • Commit the changed file with a bot identity, or attach it to the release.

Workflow

.github/workflows/release.yml
on:
  push:
    tags: ['v*.*.*']
permissions:
  contents: write
jobs:
  changelog:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0
      - run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git commit -am "docs: update changelog" && git push

Gotchas

  • -s rewrites the file in place; -r 0 regenerates every release section instead of just the latest.
  • The preset must match your commit convention or sections come out empty.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →