DEV Community

Stefan Zweifel
Stefan Zweifel

Posted on • Updated on

Automatically update CHANGELOG file when a new release is published

My Workflow

My submission to the Hackathon: an Action that automatically keeps the up-to-date with the release notes of a project.

When a new release is published, the Action takes the name and body text of the release and adds them at the right place within the file.

If the changelog follows the "Keep a Changelog"-format and has an "Unreleased" heading with a link to GitHub's compare view, the Action will to a bit of magic. At first, it will update the compare URL of the "Unreleased" heading to point to the new release and HEAD.
It will then also use that URL to build another compare URL, to allow users to compare the previous release to the latest release (eg. compare v1.0.0 to v1.1.0).

With the recent overhaul of the "Releases" feature on GitHub and the adding of the "Auto Generate Release Notes"-button, I hope this Action will help increase the adoption of changelogs and will reduce the burden to keep those changelogs up-to-date.

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

Workflow to use this Action.

# .github/workflows/update-changelog.yaml
name: "Update Changelog"

    types: [released]

    runs-on: ubuntu-latest

      - name: Checkout code
        uses: actions/checkout@v2
          ref: main

      - name: Update Changelog
        uses: stefanzweifel/changelog-updater-action@v1
          latest-version: ${{ }}
          release-notes: ${{ github.event.release.body }}

      - name: Commit updated CHANGELOG
        uses: stefanzweifel/git-auto-commit-action@v4
          branch: main
          commit_message: Update CHANGELOG
Enter fullscreen mode Exit fullscreen mode

GitHub logo stefanzweifel / changelog-updater-action

A GitHub Action to automatically update a "Keep a Changelog" CHANGELOG with the latest release notes.

changelog-updater Action

A GitHub Action to update a changelog with the latest release notes.

The Action …

  • adds a new second level heading for the new release
  • pastes your release notes in the appropriate place in

If your changelog follows the "Keep a Changelog" format and contains an "Unreleased"-heading, the Action will update the heading to point to the compare view between the latest version and HEAD. (Read more about this here)

Don't want to use GitHub Actions? Checkout the changelog-updater CLI that powers this Action Want to learn more about this Action? Read my introduction blog post.

This Action will emit warnings in your workflow logs regarding the set-output command until 2022-12-31.
The Action has already been updated to support the new syntax and will stop emitting a warning starting 2023-01-01.
Please do not open issues regarding this issue.


The Action is…

Additional Resources / Info

Open Source projects using this Action.
Mostly my own projects, as I just released the Action. However, Spatie, a huge contributor to open source PHP packages recently added the workflow to their PHP package template; which makes me super proud ♥️

I've written a couple of posts on my blog / profile on the motivation to create this Action:

Top comments (0)