semver-gauge

Gauge · package quality

semver-gauge

A CI gate that checks your version bump matches what changed, and that the CHANGELOG has a real entry for it.

npm i -D @mrlouiswright/semver-gauge

Published to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).

What it checks

  • Bump checkthe required level (major/minor/patch/none) comes from every commit since the last v* tag (or --base <ref>) that touches the package directory, so it works per-package in monorepos. Merge commits and release commits are ignored.
  • SemVer rules done properlypre-release precedence (1.0.0-rc.1 → 1.0.0-rc.2 → 1.0.0), 0.x semantics (breaking → minor, feature → patch) and the 0.x → 1.0.0 graduation.
  • CHANGELOG checkKeep a Changelog (## [1.2.0] - 2026-01-01), ## 1.2.0 (2026-01-01) and # v1.2.0 headings; empty entries, out-of-order entries, future or impossible dates, and a forgotten [Unreleased] section.
  • No git needed--commits <file> and --base-version let you feed it commit messages from anywhere.
  • Outputtext, JSON, SARIF 2.1.0 and Markdown; --fail-on; exit codes 0/1/2; allowlist entries with expiry dates.

Quick usage

CLI

npx semver-gauge                          # check package.json against the latest v* tag and CHANGELOG.md
npx semver-gauge --base origin/main       # compare with another ref
npx semver-gauge --require-bump           # release PRs: releasable commits must come with a bump
npx semver-gauge --changelog-only         # just check CHANGELOG.md has an entry for the current version
npx semver-gauge -f sarif > semver.sarif

API

import { check, formatText } from 'semver-gauge';
const report = check('.', { base: 'v1.2.0' });
console.log(formatText(report, { failOn: 'high' }));

Every option is documented in the semver-gauge docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only needed for the SARIF upload
jobs:
  semver-gauge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false, fetch-depth: 0 }
      - uses: MrLouisWright/semver-gauge@v1
        with:
          fail-on: high
          sarif: semver-gauge.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: semver-gauge.sarif }