Skip to content

tsdtsdtsd/nextversion

Repository files navigation

nextversion

Automatic semantic versioning utility

Latest Release Version Godoc Build Status Go Report Card codecov CodeQL

nextversion detects current application version based on git tags and suggests a bumped version based on conventional commit messages.

Constraints

  • nextversion needs annotated git tags to determine the current app version
  • nextversion does not create tags for you, it only generates a suggestion
  • nextversion sticks to Semantic Versioning and Conventional Commits:
    • your tags must follow the semver pattern without prerelease suffix and an optional v prefix (e.g. v1.2.3 or 1.2.3).
    • you have to make sure that commit messages follow the Conventional Commits spec.
      The used parser is in best effort mode

Usage

# Let's check the CLI help screen

$ nextversion --help
NAME:
   nextversion - versioning helper tool

USAGE:
   nextversion [global options] command [command options] 

VERSION:
   v0.2.0

DESCRIPTION:
   nextversion detects application version based on git tags and suggests a bumped version based on conventional commits.

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --repo PATH, -r PATH                  PATH to a git repository (default: "./")
   --format FORMAT, -f FORMAT            Output FORMAT (simple, json) (default: "simple")
   --defaultCurrent VERSION, -d VERSION  Fallback current VERSION if none could be detected (default: "v0.0.0")
   --prestable, -p                       Pre-stable mode (default: false)
   --help, -h                            show help
   --version, -v                         print version of this tool (default: false)

# Run nextversion 

~/my-repo$ nextversion
CURRENT=v0.1.2
CURRENT_STRICT=0.1.2
HAS_CURRENT=true
NEXT=v0.2.0
NEXT_STRICT=0.2.0
HAS_NEXT=true
PRERELEASE=v0.2.0-rc+main.cd81544
PRERELEASE_STRICT=0.2.0-rc+main.cd81544

# Please return JSON and make it readable

~/my-repo$ nextversion -f json | jq
{
  "current": "v0.1.2",
  "current-strict": "0.1.2",
  "has-current": true,
  "next": "v0.2.0",
  "next-strict": "0.2.0",
  "has-next": true,
  "prerelease": "v0.2.0-rc+main.cd81544",
  "prerelease-strict": "0.2.0-rc+main.cd81544"
}