Understanding Semantic Versioning
Prakash Pun - April 22, 2023
• 2 min read
Semantic Versioning
Semantic versioning, known as SemVer
, is a versioning system for software libraries, frameworks, and applications. It provides a standardized way of defining and communicating changes to software versions in a clear and predictable manner. It uses a three-part version separated by dots i.e. MAJOR.MINOR.PATCH
→ 1.4.2
. These numbers represent different levels of changes made to the software.
MAJOR
, is incremented when there are major changes to the software that are not backward compatible. This could include changes to the API, major feature additions, or restructuring of the codebase.
Copied!npm version major
MINOR
, is incremented when there are minor changes to the software that are backward compatible. This could include the addition of new features or functionality, bug fixes, or small improvements.
Copied!npm version minor
PATCH
, is incremented when there are minor changes to the software that is backward compatible and do not add any new features. This could include bug fixes or minor improvements.
Copied!npm version patch
Semantic Versioning also allows for the use of pre-release version numbers and build metadata. Pre-release version numbers are indicated by appending a hyphen and a series of alphanumeric characters to the end of the version number. Build metadata is indicated by appending a plus sign and a series of alphanumeric characters to the end of the version number.
Code Status | Stage | Rule | Example version |
---|---|---|---|
First release | New product | Start with 1.0.0 | 1.0.0 |
Backward compatible bug fixes | Patch release | Increment the third digit | 1.0.1 |
Backward compatible new features | Minor release | Increment the middle digit and reset last digit to zero | 1.1.0 |
Changes that break backward compatibility | Major release | Increment the first digit and reset the middle and last digits to zero | 2.0.0 |
With the help of the Semantic Versioning system, developers and users can more easily grasp the effects of updates and upgrades by communicating changes to software versions in a clear and concise manner. Additionally, it minimizes the chance of compatibility issues by ensuring that various software components can function together seamlessly.