GitHub Action
Changelog Enforcer
The purpose of this action is to enforce a change to a ongoing changelog file. Inspired by Keep A Changelog, this action helps development teams to keep a change file up to date as new features or fixes are implemented.
To use, follow the typical GitHub Action uses
syntax.
Requires the common Checkout Action as shown below! The enforcement of change is done all using local git
commands and requires the repository be checked out!
name: "Pull Request Workflow"
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
jobs:
# Enforces the update of a changelog file on every pull request
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dangoslen/changelog-enforcer@v2
with:
changeLogPath: 'CHANGELOG.md'
skipLabels: 'Skip-Changelog'
Below are the properties allowed by the Changelog Enforcer. These properties are shipped with sane defaults for typical use, especially for changelogs inline with the KeepAChangelog format.
- Default:
CHANGELOG.md
- The path to your changelog file. Should be from the perspective of the root directory to
git
. The file being checked for updates must be either an add (A
) or modified (M
) status togit
to qualify as updated.
-
Default:
'Skip-Changelog'
-
List of labels used to skip enforcing of the changelog during a pull request. Each label name is comma seperated and only one label needs to be present for enforcement to be skipped.
For example, if
label-1,label-2
was supplied as theskipLabels
,label-1
orlabel-2
would skip the enforcer. Each label is trimmed for leading and trailing spaces since GitHub labels do not allow for leading or trailing spaces. Thus, the following lists are equivalent:label-1,label-2
label-1 , label-2
label-1 ,label-2
- Default:
''
- Custom error message to use when no update to the changelog is found.
- Default:
''
- The latest version of the software expected in the changelog. Should be in the form of
v1.1.0
,v3.5.6
etc.
- Default:
'## \\[((v|V)?\\d*\\.\\d*\\.\\d*-?\\w*|unreleased|Unreleased|UNRELEASED)\\]'
- A regex pattern used to extract the versions from the changelog. Changelog Enforcer assumes the use of the KeepAChangelog.com convention, and as such looks for a line starting with
## [version] - date
. Your regex should match the version as the 2nd match group. The regex pattern is used with global and multiline flags. Also note that since this is passed as a String, you will need to escape a backslash\
character via\\
- The reason for why the Changelog Enforcer failed. Uses the
missingUpdateErrorMessage
property value if set when no update to the changelog is found.
Using this Action and the Changelog Reader, plus a few standard GitHub created Actions, we can keep the changelog of a project up to date and create a GitHub release automatically with contents from the changelog. See this project's release.yml for how to set up a simple workflow to create a new release based on a VERSION
file and a changelog.