Standard-version is a tool that automates versioning and changelog generation based on conventional commits. It is a replacement for npm version with some additional features, such as customizing the header of your changelog, skipping any of the steps (tag, commit, changelog), and dry-run mode.
How to use standard-version on a GitHub project
To use standard-version on a GitHub project, follow these steps:
- Install standard-version as a dev dependency:
npm i --save-dev standard-version
- Add a script to your package.json:
"release": "standard-version"
- Make sure your commit messages follow the conventional commit format:
type(scope): subject
- When you are ready to release a new version, run
npm run release
- This will automatically bump the version in your package.json, update the changelog file, create a new commit and tag it with the version number.
- Push your changes and tags to GitHub:
git push --follow-tags origin main
Conventional commit format
The conventional commit format is a simple way to structure your commit messages so that they can be parsed by tools like standard-version. The format consists of three parts:
- type: The kind of change that the commit introduces. It can be one of the following:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons,etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- chore: Other changes that don’t modify src or test files
- scope (optional): The scope of the change. It can be any word that describes the affected part of the code. subject: A short description of the change.
Some examples of conventional commits are:
feat(cart):
add checkout button
fix(order):
handle invalid input
docs(readme):
update installation instructions
Comments (0)