Sub topic 5
Release notes generated from merged pull requests
This chapter assumes you can read a workflow file, know how to create a tag, and use pull requests and labels on GitHub. It builds on the tag-triggered workflow from the previous chapter.
What generated notes are
GitHub can write release notes for you. It collects the pull requests merged since the previous release, lists each with its title, author and number, and adds a link that compares the two tags. It also lists first-time contributors. You get a readable changelog without anyone editing a file.
The notes are only as good as your pull request titles. A title like "fix stuff" produces a note that says "fix stuff". Many teams treat the title as the changelog entry and review it before merging.
Where the notes come from
GitHub works out the range from two points:
- The tag you are releasing.
- The previous release tag. By default this is the most recent earlier release, ordered by semantic version and creation date.
Every pull request merged into the target branch between those two points is included. Direct commits that never went through a pull request are not listed as entries, which is one reason to merge through pull requests.
Turning it on in a workflow
You ask for generated notes with a single flag on gh release create. This is the workflow from the previous chapter:
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tagThe --generate-notes flag tells GitHub to build the body. The --verify-tag flag makes the command fail if the tag does not exist on the remote, instead of silently creating one. The contents: write permission is the only access the job has.
What the output looks like
For a release v1.2.0, the body looks like this:
- A "What's Changed" heading.
- One bullet per pull request, such as "Handle empty config file by @alice in #41".
- A "New Contributors" section when someone merged a first pull request.
- A "Full Changelog" link comparing
v1.1.0...v1.2.0.
Without further setup, all pull requests appear in one flat list. The next chapter shows how to group them by label and leave some out.
Choosing the starting point
If the automatic choice of previous tag is wrong, you can name it. gh release create accepts --notes-start-tag:
- name: Create release with explicit range
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --generate-notes --notes-start-tag v1.0.0 --verify-tagThis is useful after a hotfix branch, where the newest earlier release is not the one you want to compare against. It is also useful when you want the notes for a final release to cover everything since the last stable version, not just since the last release candidate.
Common problems
- The notes are empty or very short. No pull requests were merged between the tags, or the changes were pushed directly to the branch.
- The wrong changes appear. The previous tag was not what you expected. Set
--notes-start-tag. - Titles are unclear. Fix the pull request titles before merging. Renaming a title after release does not update the published notes unless you regenerate or edit them.
Exercise
A release for v2.0.0 lists changes you already shipped in v1.9.0, because the previous release you want to compare against is a hotfix tag on another branch. Which option do you add to gh release create, and why do you keep --generate-notes?
Show answer
Add --notes-start-tag v1.9.0 so the range begins at the tag you choose instead of the automatically detected previous release. Keep --generate-notes because that flag is what asks GitHub to build the notes from the merged pull requests in that range.