April 1 2022
Automating release notes with github actions
The Problem
Release note generation can often be lacking, tedious or not exist at all.
The Solution
Automate it!
Here is a small Github Actions workflow to do exactly that!
name: Create release notes
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- id: tag
name: Bump version and push tag
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: 'patch'
- id: release_notes
name: Create release notes
run: gh release create ${{ steps.tag.outputs.new_tag }} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
What does it do
When pushed to the main branch
on:
push:
branches:
- main
Checkout the repo
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
Use the Github tag action to bump the version using git tags. This may not fit with every workflow so may need to adjust. This configuration will bump the tag using the patch strategy if none is explicitly defined in any of the commits since the large merge. For more details on how to configure the action, see the repo’s README
- id: tag
name: Bump version and push tag
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: 'patch'
Use the Github CLI to automatically create a new release, and generate some release notes
- id: release_notes
name: Create release notes
run: gh release create ${{ steps.tag.outputs.new_tag }} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
What does it look like?
Here’s an example! It collates all merge commits and list them alongside authors, as well as provide a changelog and list of contributors.
Further automation
You can then send this to slack or any other messaging service and communicate what you’re releasing without manual intervention.