This GitHub Action automatically updates a changelog file (changelog.json) based on commit messages. It follows semantic versioning principles and provides a structured way to track changes in your project.
- Features
- Setup
- Usage
- Commit Message Format
- Version Determination
- Changelog Structure
- Contributing
- Credits
- License
- Automatic changelog updates based on commit messages
- Semantic versioning support
- Customizable commit types for different change categories
- JSON-based changelog for easy parsing and integration
- Ignores its own commits to prevent infinite loops
- Create a
.github/workflowsdirectory in your repository if it doesn't already exist. - Create a new file named
update-changelog.ymlin the.github/workflowsdirectory. - Copy the contents of the provided GitHub Action YAML into this file.
- Commit and push these changes to your repository.
Once set up, the action will run automatically on every push to the main branch (or whichever branch you specify in the YAML file). It will analyze the latest commit, update the changelog.json file in the src directory, and commit the changes.
To make the most of this action, format your commit messages as follows:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Where <type> can be one of:
major: Breaking changesfeat: A new feature (minor version bump)fix: A bug fix (patch version bump)docs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary tools and libraries
Example:
feat: add user authentication feature
This commit adds a new user authentication system using JWT tokens.
Closes #123
The action determines the new version number based on the following logic:
-
It finds the latest version number in the existing changelog by:
- Selecting all non-TBD versions
- Sorting them numerically (considering all parts of the version number)
- Selecting the highest version
-
It then increments this version based on the commit type:
major: Increments the major version (X.0.0)feat: Increments the minor version (0.X.0)fix: Increments the patch version (0.0.X)- All other types do not cause a version increment
For example, if the latest version is 1.2.3:
- A
majorcommit would result in version 2.0.0 - A
featcommit would result in version 1.3.0 - A
fixcommit would result in version 1.2.4
The changelog.json file is structured as an array of objects, each representing a change:
[
{
"version": "1.2.3",
"commitHash": "abc123...",
"author": "John Doe",
"date": "2023-08-21T10:00:00Z",
"message": "Add new feature",
"type": "feat",
"versionBump": "minor"
},
...
]New entries are added to the end of this array, maintaining a reverse chronological order (newest last).
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT
Created at Fiction Tribe ® in Portland, OR
