Video in progress

Strong Middle 🌿 Git

What are Conventional Commits, and how can they be used to automate the version and the CHANGELOG?

It is a convention for commit messages: prefixes such as feat:, fix:, feat!: or BREAKING CHANGE:. Tools (semantic-release, release-please) use these prefixes to compute the next SemVer version, write the CHANGELOG and create the tag.

📖 Answer

The format:

feat(payment): Payme orqali qaytarish (refund) qo'shildi
fix(auth): muddati o'tgan refresh token 500 o'rniga 401 qaytaradi
refactor(order): narx hisoblash alohida klassga ajratildi

feat(api)!: /v1/orders javobidan legacyStatus maydoni olib tashlandi

The versioning rule: if there has been a fix since the last tag, PATCH; a feat, MINOR; a ! or a BREAKING CHANGE: footer, MAJOR. chore, docs and test do not change the version.

A scheme that works well in practice is release-please (or a similar tool):

  1. After every merge to main, a bot opens or updates a "Release v2.5.0" PR, with the version and CHANGELOG inside.
  2. When the team is ready, it merges that PR.
  3. The bot creates the tag and a GitHub Release, and CI publishes the artifact.

Conditions for it to work: check the format in a commit-msg hook and in CI; and if you use squash merge, the PR title must be in this format too, because that is what lands on main as the commit message.

Be careful: the automation trusts the prefix you wrote. If you label a change that broke the API as fix:, clients will update thinking it is a PATCH and break. So check the ! marker in review too.