DEV Community

Cover image for Automate Release Notes a.ka. Changelog with release please
Sofia Ma
Sofia Ma

Posted on • Edited on

Automate Release Notes a.ka. Changelog with release please

Curious about what is being released into a project?

Keep a Changelog, it keeps your audience up to date with the latest changes at a glance!

And even better, automate the CHANGELOG.md each time a PR is merged into the base branch:

How to automate the Changelog

1 - Create .github/workflows/release-please.yml at the root of the repository

$ mkdir .github && cd .github && mkdir workflows && cd workflows && touch release-please.yml
Enter fullscreen mode Exit fullscreen mode

2 - Modify the changes on release-please.yml and choose the release-type

# release-please.yml
on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v3
        with:
          release-type: simple
Enter fullscreen mode Exit fullscreen mode

3 - Add the commit message and merge the branch. Make sure to follow conventional commits.

4 - Some changelog sections will not be displayed. To override the default, update the release-please.yml with changelog-types with the field hidden:false

# release-please.yml
...
        with:
          release-type: simple
          changelog-types: >
            [
              { "type": "build", "section": "Build System", "hidden": false },
              { "type": "ci", "section": "Continuous Integration", "hidden": false },
              { "type": "chore", "section": "Miscellaneous Chores", "hidden": false },
              { "type": "docs", "section": "Documentation", "hidden": false },
              { "type": "feat", "section": "Features", "hidden": false },
              { "type": "fix", "section": "Bug Fixes", "hidden": false },
              { "type": "perf", "section": "Performance Improvements", "hidden": false },
              { "type": "revert", "section": "Reverts", "hidden": false },
              { "type": "refactor", "section": "Code Refactoring", "hidden": false },
              { "type": "style", "section": "Styles", "hidden": false },
              { "type": "test", "section": "Tests", "hidden": false }
            ]
Enter fullscreen mode Exit fullscreen mode

5 - Configure default to PR title for squash and merge commits when merging a pull request

6 - See the automated changelog PR - github link

automated changelog

Using the Squash and merge PR in github will group the commits into one commit, displaying just one line with the PR#. While not using the Squash and merge PR, each commit will be listed on its own, as displayed under the section "Continuous Integration"

Squash and merge

The individual commit history of the PR can still be viewed by clicking the PR# in the CHANGELOG.MD

PR commit history

Release notes can also be overridden in the body of the PR with the changelog reflecting the changes

override release notes

changelog reflecting changes

Simplify merged PRs

Configure merged PRs to keep a cleaner history in the base branch

1 - Add a branch protection rule to require branches to be up to date before merging

rebase branch

2 - Use squash and merge commits on PRs to keep a cleaner commit history in the base branch

squash and merge branch

3 - Delete branches automatically after a merge

delete branch


The Github repo for this tutorial can be found here

Top comments (0)