Sub topic 14
Writing and generating release notes
This chapter assumes you can create a tag, push it, and run gh release create. Release notes are the text shown on a GitHub Release page. They tell users what changed between the previous version and this one.
What good notes contain
Readers scan notes to decide whether to upgrade. Group changes by what they mean to the reader, not by commit order.
- Breaking changes: anything that requires users to change their code or configuration.
- Features: new capabilities.
- Fixes: bugs that no longer occur.
- Other: documentation, dependency updates, internal cleanups.
Commit messages are written for maintainers. Release notes are written for users, so rewrite "fix nil check in parse()" as "Fixed a crash when the input file was empty."
Writing notes by hand
Pass notes with --notes, or read them from a file with --notes-file. A file is easier to review and keep in the repository.
gh release create v1.1.0 --title "Version 1.1.0" --notes-file RELEASE_NOTES.mdYou can also edit the notes of an existing release:
gh release edit v1.1.0 --notes-file RELEASE_NOTES.mdGenerating notes automatically
GitHub can build notes from the pull requests merged since the previous release. Add --generate-notes to the command.
gh release create v1.1.0 --generate-notesThe generated text lists merged pull requests with their authors and ends with a "Full Changelog" link that compares the two tags. In the web UI, the same feature is the Generate release notes button on the release form.
GitHub chooses the starting point automatically. To control it, name the previous tag yourself:
gh release create v1.1.0 --generate-notes --notes-start-tag v1.0.0You can combine your own text with generated text. When you pass --notes and --generate-notes together, GitHub places your text first and appends the generated list.
gh release create v1.1.0 --generate-notes --notes "Highlights: faster startup and a new config format."Grouping pull requests with a configuration file
Generated notes are a flat list by default. To group entries by category, create .github/release.yml. GitHub sorts pull requests into categories by their labels.
changelog:
exclude:
labels:
- skip-changelog
categories:
- title: Breaking changes
labels:
- breaking-change
- title: New features
labels:
- enhancement
- title: Bug fixes
labels:
- bug
- title: Other changes
labels:
- "*"The "*" label matches any pull request not placed in an earlier category. Categories are checked in order, and each pull request appears only once.
Common problems
- Notes are empty or too short. Changes were pushed directly to the branch without pull requests, so there is nothing to list. Use pull requests, or write notes by hand.
- Wrong range of changes. GitHub picked a different previous tag than you expected. Set
--notes-start-tag. - Everything lands in "Other changes." Pull requests have no labels. Label them before merging, or add a labeler workflow.
- Generated notes read poorly. They reuse pull request titles. Write clear titles, or edit the notes after creation.
Exercise
A release created with --generate-notes lists every change under one flat list, though your pull requests are labeled bug and enhancement. What do you add to fix this?
Show answer
Add a .github/release.yml file with changelog.categories. Each category has a title and a list of labels, and GitHub groups the merged pull requests by those labels.
Exercise
Which option makes GitHub compare against v1.0.0 instead of the tag it would choose by default?
Show answer
--notes-start-tag v1.0.0, used together with --generate-notes.