Guidelines to standardize commit messages
- Validates commit messages against the Conventional Commits specification.
- Formats commit messages using a series of prompts.
- Automates the generation of a CHANGELOG.md file.
- Bumps the version and generates a new release.
Install the necessary dependencies locally:
yarn add --dev husky @commitlint/cli @commitlint/config-conventional cz-conventional-changelogInstall commitizen globally to enable standardized commit message formatting:
sudo yarn global add commitizenUpdate your project's package.json file to configure commitizen:
{
...
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog",
"disableScopeLowerCase": true
}
},
...
}
Create a commitlint.config.js file in your project root directory to configure commitlint:
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"scope-case": [0],
},
};Edit package.json > prepare script and run it once:
npm pkg set scripts.prepare="husky install"
yarn prepareAdd a hook to run commitlint
npx husky add .husky/commit-msg "yarn commitlint --edit"Configure commitizen to use the conventional changelog adapter:
commitizen init cz-conventional-changelog --save-dev --save-exactAutomate release management with Release Please:
Deploy release-please with GitHub Action by creating a .github/workflows/release-please.yml file with these contents:
on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: release-please-action
Make sure you have the correct Workflow permissions on your repository (Settings > Actions > General):
Standard Commit simplifies the process of writing standardized commit messages:
Instead of git commit, use git cz to open a wizard and generate a standardized commit message:
git add .
git cz
git push --follow-tagsYou can still use git commit ... but the commit will fail if the commit message is not properly formatted.
git add .
git commit -m "feat(blog): add comment section"
git push --follow-tags- commitizen helps format commit messages with a series of prompts
- husky will trigger the commitlint on each commit
- commitlint checks if your commit messages meet the Conventional Commits specification
- release-please automates
CHANGELOG.md, bump the version and generate a new release
Want to contribute? All contributions are welcome. Read the contributing guide.
If you have questions tweet me at @sandro_m_m or open an issue.
This project is licensed under the MIT License - see the LICENSE file for details
**~ sharing is caring ~**

