All guides

Semantic versioning and automated releases

Under Semantic Versioning, a version number conveys what changed from one version to the next. When each commit message states the kind of change, a tool can determine the next version, create the tag and generate the changelog.

A laptop screen showing JavaScript in a code editor

What the three numbers mean

Semantic Versioning 2.0.0 gives a version the form MAJOR.MINOR.PATCH and ties each number to the public API.

  • MAJOR is incremented when backward incompatible changes are introduced to the public API. MINOR and PATCH reset to 0.
  • MINOR is incremented when new, backward compatible functionality is introduced, and when any public API functionality is marked as deprecated. PATCH resets to 0.
  • PATCH is incremented when only backward compatible bug fixes are introduced.

Three more rules from the specification apply to every release. The software must declare a public API, in the code itself or in documentation. Once a version has been released, its contents must not be modified, and any modification is released as a new version. Major version zero, 0.y.z, marks initial development: any part may change at any moment.

Pre-release identifiers and build metadata

A pre-release version appends a hyphen and a series of dot-separated identifiers to the patch version, as in 1.0.0-alpha.1. It has lower precedence than the associated normal version, and it indicates that the version is unstable. Identifiers hold only ASCII alphanumerics and hyphens.

Text

1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta
  < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0

This ordering is the specification's own example. Identifiers of digits only are compared numerically, which is why beta.11 comes after beta.2. An identifier that contains letters or hyphens is compared lexically, by ASCII sort order.

Build metadata follows a plus sign, as in 1.0.0+20130313144700. It is ignored when precedence is determined.

Commit messages that carry the bump

Conventional Commits 1.0.0 structures a commit message as a type, an optional scope and a description. These three lines come from the specification:

Text

fix: prevent racing of requests
feat(lang): add Polish language
feat(api)!: send an email to the customer when a product is shipped
  • fix patches a bug and correlates with PATCH.
  • feat introduces a new feature and correlates with MINOR.
  • A ! after the type or scope marks a breaking change and correlates with MAJOR. A footer that starts with BREAKING CHANGE: does the same, in a commit of any type.

Other types, such as docs, chore and ci, are allowed. Unless one includes a breaking change, they carry no implicit effect in Semantic Versioning.

Releases on every merge with semantic-release

semantic-release is meant to run in CI after every successful build on a release branch. It obtains the last release by analyzing Git tags, determines the type of release from the commits added since, generates release notes, creates a Git tag and publishes.

The configuration can live in a .releaserc file. This is the documented example:

JSON

{
  "branches": ["main", "next"]
}

By default, the branch main or master gets regular releases, and a branch named beta or alpha, if it exists, gets pre-releases. The documentation gives the pre-release case with "branches": ["master", {"name": "beta", "prerelease": true}]: after a 1.0.0 release from master, a breaking change pushed to beta is released as 2.0.0-beta.1. Tags use the format v${version} by default.

Four plugins are part of semantic-release: @semantic-release/commit-analyzer, @semantic-release/release-notes-generator, @semantic-release/npm and @semantic-release/github. The README notes that under the default configuration the BREAKING CHANGE: token has to sit in the commit's footer. The --dry-run argument prints the next version and the release notes, and skips the prepare and publish steps.

A release pull request with release-please

release-please maintains a release pull request and keeps it up to date as additional work is merged. When you are ready to tag a release, you merge that pull request. release-please then updates the changelog file and other language-specific files, tags the commit with the version number and creates a GitHub release. It does not handle publication to package managers.

This workflow is the basic configuration from the action's README:

YAML

on:
  push:
    branches:
      - main

permissions:
  contents: write
  issues: write
  pull-requests: write

name: release-please

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        with:
          # this assumes that you have created a personal access token
          # (PAT) and configured it as a GitHub action secret named
          # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
          token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
          # this is a built-in strategy in release-please, see "Action Inputs"
          # for more options
          release-type: simple

The README pins @v4. The repository's releases page lists v5.0.0, dated 22 April 2026, whose breaking change is the upgrade to Node 24. The two pages differ, so check both before you choose the version to pin.

The simple release type is for a repository with a version.txt and a CHANGELOG.md. A release pull request is created when the default branch contains releasable units: commits with the prefixes feat, fix and deps. A chore or build commit is not one. Resources that release-please creates with the built-in GITHUB_TOKEN do not trigger other GitHub Actions workflows, which is why the example passes a personal access token.

Tags and changelogs

  • Tags. semantic-release creates a Git tag for each release and finds the last release by analyzing Git tags. release-please tags the commit with the version number and looks at commits since the last release tag.
  • Changelogs. semantic-release writes release notes that cover the commits added since the previous release. release-please updates the changelog file at the moment the release pull request is merged.
  • Released versions. The specification requires any modification of a released version to be released as a new version.
  • Squash merges. release-please recommends them, because a linear history makes it easier to control the changelog.

Where to start

  1. Declare the public API, in code or in documentation.
  2. Enforce the commit format. The semantic-release README names commitizen and commitlint as tools for that.
  3. Protect the release branches. With semantic-release configured, any user who can push to one of them can publish a release.
  4. Choose the tool by how you release. semantic-release makes a release on a push to a release branch, if the changes since the last release affect the package. release-please waits for you to merge the release pull request.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides