Semantic Versioning & Releases

Communicating change through version numbers — SemVer major, minor and patch rules, pre-releases, version ranges and lockfiles, what counts as a breaking change, deprecation policies, CalVer, changelogs, Conventional Commits and automated releases, and API versioning.

Beginner 5 min readLesson 8 of 9

When you publish a library, API or app that others depend on, the version number is a promise about compatibility. Semantic Versioning (SemVer) is the most widely used convention for that promise, and package managers rely on it to decide which upgrades are safe.

SemVer: MAJOR.MINOR.PATCH

   2 . 4 . 1
   │   │   └── PATCH: backward-compatible bug fixes
   │   └────── MINOR: backward-compatible new functionality
   └────────── MAJOR: incompatible (breaking) API changes
ChangeBumpExample
Fix a bug without changing the APIPatch2.4.1 → 2.4.2
Add a new function, optional parameter or endpointMinor (reset patch)2.4.2 → 2.5.0
Remove or rename something, change behaviour callers rely onMajor (reset minor and patch)2.5.0 → 3.0.0

Additional rules:

  • 0.y.z is initial development: anything may change at any time. Many ecosystems treat a 0.x minor bump as breaking (^0.4.0 allows only 0.4.x).
  • 1.0.0 declares a stable public API.
  • Pre-releases: 3.0.0-alpha.1, 3.0.0-beta.2, 3.0.0-rc.1 — lower precedence than the release, not picked by normal ranges.
  • Build metadata: 3.0.0+20261204.sha3f9c2a — ignored for precedence.
  • Once published, a version's contents must never change; fix mistakes with a new version.

What is a breaking change?

More subtle than "I renamed a function". Breaking changes include:

  • Removing or renaming public functions, classes, fields, endpoints, CLI flags or config keys.
  • Adding a required parameter; changing parameter or return types.
  • Changing behaviour callers depend on — default values, error types, ordering, timing, validation strictness.
  • Raising the minimum supported runtime (Node 18 → 20, Java 17 → 21) or platform.
  • For APIs: removing response fields, adding a required request field, changing status codes or enum semantics (API design).

Hyrum's law: with enough users, every observable behaviour of your system will be depended on by somebody — even undocumented ones. So be explicit about what is public API, and be careful even with "internal" changes.

Consuming versions: ranges and lockfiles

Package managers let you depend on a range:

Syntax (npm)AllowsMeaning
2.4.1Exactly 2.4.1Pinned
~2.4.1≥ 2.4.1, < 2.5.0Patch updates
^2.4.1≥ 2.4.1, < 3.0.0Minor + patch updates (the npm default)
>=2.4 <4Explicit range—

Other ecosystems: Cargo uses caret semantics by default; Python uses ~= (compatible release) and >=, <; Maven/Gradle typically pin exact versions.

Ranges let you receive fixes, but builds must be reproducible, so commit a lockfile (package-lock.json, pnpm-lock.yaml, poetry.lock, uv.lock, Cargo.lock, go.sum) that records the exact resolved versions. Update deliberately with tools like Dependabot or Renovate, which open PRs that CI tests.

Guidelines:

  • Applications: commit lockfiles; update regularly in small batches.
  • Libraries: declare the widest range you actually support, so you don't force conflicts on users.
  • Watch for dependency hell: two libraries needing incompatible major versions of a shared dependency (npm can nest copies; Python and Java generally can't).
  • Supply-chain hygiene: review new dependencies, prefer well-maintained ones, and scan for vulnerabilities (Web security).

Deprecation

Don't surprise users with removals. A good deprecation path:

  1. Introduce the replacement in a minor release.
  2. Mark the old API deprecated — documentation, compiler warnings (@Deprecated, #[deprecated], DeprecationWarning), runtime warnings, or Deprecation/Sunset HTTP headers for APIs.
  3. Provide a migration guide (and codemods where possible).
  4. Remove it in the next major release, after a published support window.

Communicate support policies: e.g. "each major version receives security fixes for 12 months after the next major is released" or LTS (long-term support) releases like Node's even-numbered versions or Ubuntu LTS.

Alternatives to SemVer

SchemeFormatUsed byWhy
CalVer2026.12, 24.04, 2026.12.1Ubuntu, pip, many appsRelease date matters more than compatibility signalling; time-based release trains
Marketing versions"Windows 11", "iOS 18"Consumer productsBranding; internal build numbers differ
Monotonic build numbersbuild 4821Mobile apps (internal), CI artefactsOrdering only
ZeroVer (jokingly)0.x foreverMany projectsAvoiding stability commitments — not recommended for widely used libraries

For a continuously deployed web service with no external consumers, version numbers matter less — the git SHA identifies what's running. Versioning matters at boundaries: public APIs, SDKs, libraries, mobile apps and file formats.

Changelogs

A changelog tells humans what changed and whether they need to act. The Keep a Changelog format groups entries by version and type:

markdown
## [2.5.0] - 2026-12-04
### Added
- `retry` option for `Client.charge()` with exponential backoff.
### Fixed
- Rounding error in tax totals for amounts above ₹1 crore (#412).
### Deprecated
- `Client.pay()` — use `Client.charge()`; removal planned for 3.0.0.

## [2.4.1] - 2026-11-20
### Security
- Validate webhook timestamps to prevent replay attacks.

Write for users ("what does this mean for me?"), not as a dump of commit messages. Call out breaking changes and migrations prominently.

Automating releases

Conventional Commits give commit messages a machine-readable structure:

feat(payments): add retry option to charge()
fix(tax): correct rounding above 1 crore
feat(api)!: remove deprecated pay() method

BREAKING CHANGE: pay() was removed; use charge() instead.

Tools like semantic-release, release-please and Changesets read these (or explicit change files) to determine the next version (fix → patch, feat → minor, !/BREAKING CHANGE → major), generate changelogs, tag the release, publish packages and create GitHub releases — all from CI (CI/CD, Version control workflows).

A typical release pipeline:

  1. Merge to main triggers CI.
  2. The release tool computes the version and changelog.
  3. Tag (v2.5.0) and build once; sign artefacts and record provenance (Digital signatures).
  4. Publish to the registry (npm, PyPI, Maven Central, crates.io, container registry).
  5. Announce: release notes, migration guides for majors.

API versioning

Web APIs face the same problem with different tools (REST, GraphQL and gRPC):

  • Additive change first: add fields and endpoints instead of changing existing ones; clients should ignore unknown fields.
  • Explicit versions for breaking changes: URL path (/v2/orders), header, or date-based versions (Stripe's Stripe-Version: 2026-11-01, pinning each account to the version it integrated with).
  • GraphQL typically avoids versions: add fields, deprecate old ones with @deprecated, remove after usage drops.
  • Protobuf/gRPC: never reuse field numbers; add new fields as optional.
  • Run old and new versions side by side; monitor who still calls deprecated versions before turning them off.
Key takeaways
  • SemVer MAJOR.MINOR.PATCH: breaking changes bump major, compatible features bump minor, fixes bump patch; published versions are immutable.
  • Breaking changes include behaviour, defaults, errors and runtime requirements — Hyrum's law says someone depends on everything observable.
  • Consumers use ranges (caret, tilde) plus committed lockfiles; update with Dependabot or Renovate.
  • Deprecate before removing: replacement in a minor, warnings, migration guide, removal in the next major.
  • CalVer suits time-based releases; versioning matters most at public boundaries.
  • Keep human-friendly changelogs; automate versioning and publishing with Conventional Commits and release tools.
  • Evolve web APIs additively; version explicitly for breaking changes.