claudiodekker / changelog-updater
A PHP package to programmatically update your changelog file.
Package info
github.com/claudiodekker/changelog-updater
pkg:composer/claudiodekker/changelog-updater
Requires
- php: ^8.5
- illuminate/collections: ^13.44
- illuminate/support: ^13.44
- phar-io/version: ^3.2.1
Requires (Dev)
- phpunit/phpunit: ^13.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A GitHub Action that keeps your CHANGELOG.md up to date in the Keep a Changelog 1.1.0 format. Each merged pull request becomes an entry under "Unreleased", and each published release moves those entries under a heading of its own. You can see an example of what this looks like here.
Setup
Create .github/workflows/changelog.yml in your repository:
name: Changelog on: pull_request_target: types: [closed] release: types: [published] jobs: changelog: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.repository.default_branch }} - uses: claudiodekker/changelog-updater@v2
When a pull request titled feat: add dark mode is merged, the action adds it under "Unreleased", then commits and pushes the changelog:
## Unreleased ### Added - Add dark mode ([#42](https://github.com/acme/app/pull/42))
When you then publish the v1.4.0 release, those entries move under a heading for it, dated the day the release was published, in UTC:
## Unreleased ## [v1.4.0](https://github.com/acme/app/releases/tag/v1.4.0) - 2026-11-28 ### Added - Add dark mode ([#42](https://github.com/acme/app/pull/42))
Where an entry goes
A merged pull request's section comes from its labels or its title. A title in the Conventional Commits form, type(scope)!: description, is placed by its type. When a label matches too, the label wins:
| Section | Labels | Title types |
|---|---|---|
| Added | enhancement, feature |
feat |
| Changed | change, improvement, optimization, performance, refactor, revert |
perf, refactor, revert |
| Deprecated | deprecation, deprecated |
|
| Removed | removal |
|
| Fixed | bug, bugfix, fix, patch |
fix |
| Security | security |
|
| No entry | skip-changelog |
build, chore, ci, docs, style, test |
The entry's text is the title. When the title starts with one of the types in the table, that prefix is removed and the rest starts with a capital letter, whichever of the two placed it. A description whose second letter is already a capital, such as iOS crash on launch, keeps its case.
A ! before the colon, as in feat!: drop the v1 API, marks a breaking change. Its entry starts with **Breaking:** , as in - **Breaking:** Drop the v1 API, and goes in the section of its type, or under Changed for a type in the No entry row. A label that maps to a section still decides the section, and the entry is still marked. Only the title is read, so a BREAKING CHANGE: footer in the pull request's description does not mark it.
A pull request that is closed without being merged, or that neither its labels nor its title place, leaves the changelog as it is. Sections are written in the order of the table, and any other section, from your own map or already in the file, comes after them in alphabetical order.
To use your own labels, give the action a map of label: Section pairs, one per line. It replaces the labels in the table, while the title types and skip-changelog keep working:
- uses: claudiodekker/changelog-updater@v2 with: labels: | type/feature: Added type/bug: Fixed
Releases
A published release moves the entries under "Unreleased" into a heading for its tag, linked to the release's page. A pre-release, such as v2.0.0-beta.1, leaves the changelog alone unless you set prereleases: true. A release whose version is lower than the highest version among the changelog's headings, such as v1.2.5 published from a maintenance branch after v2.0.0, also leaves it alone, so the entries under "Unreleased" stay for the next release on the default branch. That holds when an earlier backport heads the file too, and headings that are not versions, such as Nightly, are left out of the comparison. A tag that is not a version, such as nightly, fails the step.
A changelog that links its version headings through link references at the end of the file, as the Keep a Changelog example does, keeps them. The new heading links through a new reference instead, and the version is written the way the headings before it write theirs, with or without a leading v. When [unreleased] compares the previous tag with HEAD, the new reference compares the previous tag with the new one, and [unreleased] moves on to the new tag. Publishing v1.4.0 turns this:
## [Unreleased] ### Added - Add dark mode ([#42](https://github.com/acme/app/pull/42)) ## [1.3.0] - 2026-10-02 ### Fixed - Fix the login redirect ([#40](https://github.com/acme/app/pull/40)) [unreleased]: https://github.com/acme/app/compare/v1.3.0...HEAD [1.3.0]: https://github.com/acme/app/compare/v1.2.0...v1.3.0
into this:
## [Unreleased] ## [1.4.0] - 2026-11-28 ### Added - Add dark mode ([#42](https://github.com/acme/app/pull/42)) ## [1.3.0] - 2026-10-02 ### Fixed - Fix the login redirect ([#40](https://github.com/acme/app/pull/40)) [unreleased]: https://github.com/acme/app/compare/v1.4.0...HEAD [1.4.0]: https://github.com/acme/app/compare/v1.3.0...v1.4.0 [1.3.0]: https://github.com/acme/app/compare/v1.2.0...v1.3.0
Without such an [unreleased] reference, the new reference links to the release's page. An [unreleased] reference that compares nothing yet, such as [unreleased]: https://github.com/acme/app/commits/HEAD before the first release, starts comparing the new tag with HEAD when the release link is the release's page, so the next release gets a comparison.
A changelog whose latest heading links inline keeps getting inline links, even when other references, such as [@bob]: https://github.com/bob, end the file. Those stay as they are. Before the first release, only an [unreleased] reference makes the heading link through a reference.
The heading is committed after the release is published, so the tagged commit itself still lists those entries under "Unreleased". If the tag must include the finished changelog, add the heading yourself before you create the release, and the action leaves it as it is.
Requiring a changelog entry
To also check pull requests while they are open, add the pull_request trigger:
on: pull_request: types: [opened, edited, labeled, unlabeled, reopened, synchronize] pull_request_target: types: [closed] release: types: [published]
A pull request passes when a label or its title's type is in the table above, and fails otherwise.
A ruleset that requires this check, or a branch that takes no direct pushes, also rejects the changelog commit the action pushes after a merge. Either:
-
Push with a deploy key: use
examples/required-check.ymlas your workflow, and follow the three setup steps at its top. -
Open a pull request instead: set
commit: falseand add a pull request step, withpull-requests: writeand "Allow GitHub Actions to create and approve pull requests" turned on. Pull requests opened by a workflow get no checks, so this one needs a bypass to merge.- uses: claudiodekker/changelog-updater@v2 with: commit: false - uses: peter-evans/create-pull-request@v7 with: branch: changelog title: "chore: update changelog"
Configuration
Every input is optional.
| Input | Default | Description |
|---|---|---|
file |
./CHANGELOG.md |
The changelog file. |
entry-position |
bottom |
Where a new entry goes in its section: top or bottom. |
labels |
The table above | Your own labels, one label: Section pair per line. |
prereleases |
false |
Whether a published pre-release also gets a heading. |
commit |
true |
Whether the action commits and pushes the changelog. Set it to false to commit it in a later step yourself, as in Requiring a changelog entry. |
Upgrading from v1
Replace your v1 workflow with the one under Setup. The action now reads the pull request and commits the changelog itself, so the shell step that mapped labels to sections, the inputs that passed the pull request through and the commit step all go.
Until you do, a v1 workflow keeps working. Its section, entry-text and entry-link inputs still override what the action would take from the pull request. Your own commit step finds nothing left to commit: remove it, or set commit: false to keep it.