Using conventional commit messages, we can automate the process of generating the CHANGELOG file. All commits messages will automatically be validated against the following regex.
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build|improvement)((.+))?: .{1,50}/
A commit message consists of a header, body and footer. The header has a type, scope and subject:
The scope is optional
feat(router): add support for prefix
Prefix makes it easier to append a path to a group of routes
feat
is type.router
is scope and is optionaladd support for prefix
is the subject- The body is followed by a blank line.
- The optional footer can be added after the body, followed by a blank line.
Only one type can be used at a time and only following types are allowed.
- feat
- fix
- docs
- style
- refactor
- perf
- test
- workflow
- ci
- chore
- types
- build
If a type is feat
or fix
, then the commit will appear in the CHANGELOG.md file. However if there is any BREAKING CHANGE, the commit will always appear in the changelog.
If the commit reverts a previous commit, it should begin with revert:
, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>
., where the hash is the SHA of the commit being reverted.
The scope could be anything specifying place of the commit change. For example: router
, view
, querybuilder
, database
, model
and so on.
The subject contains succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes".
- don't capitalize first letter
- no dot (.) at the end
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.
Breaking Changes should start with the word BREAKING CHANGE:
with a space or two newlines. The rest of the commit message is then used for this.