Automate Update CHANGELOG.md

nasrulhazim

Nasrul Hazim Bin Mohamad

Posted on August 3, 2022

Automate Update CHANGELOG.md

TLDR;

Copy paste the following Github Action configuration:

name: "Update Changelog"

on:
  release:
    types: [released]

jobs:
  update:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          ref: master

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

      - name: Commit updated CHANGELOG
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          branch: master
          commit_message: Update CHANGELOG
          file_pattern: CHANGELOG.md
Enter fullscreen mode Exit fullscreen mode

And add file named CHANGELOG.md in your root repository, and with the following content:

# Changelog

All notable changes will be documented in this file.
Enter fullscreen mode Exit fullscreen mode

With above setup, each time you release a new version of your application or package, Github Action will take care of your CHANGELOG details.

Do take note, you need to ensure the ref: master and branch: master is the branch that you always create tagged release version.

If you have protected branch, for now - I disable the branch protection. Not sure if there's workaround if the commits from Github Action, we can still commit and protect the branch at the same time.

Photo by Mason Kimbarovsky on Unsplash

💖 💪 🙅 🚩
nasrulhazim
Nasrul Hazim Bin Mohamad

Posted on August 3, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related