Created: 2018-04-02 08:49
Updated: 2019-01-23 22:41
License: mit


Build Status Go Report Card

semver-cli is a simple command line tool to compare and manipulate version strings.

It is basically a cli wrapper around the excellent Masterminds semver library, with lots of help from the also excellent Kingpin

usage: semver [<flags>] <command> [<args> ...]

Command-line semver tools. On error, print to stderr and exit -1.

      --help     Show context-sensitive help (also try --help-long and --help-man).
  -v, --verbose  Verbose mode.

  help [<command>...]
    Show help.

    Test if a version satisfies a constraint. Exit 0 if satisfies, 1 if not. If verbose, print an explanation to stdout.

  greater <A> <B>
    Compare two versions. Exit 0 if the first is greater, 1 if not. If verbose, print greater to stdout.

  lesser <A> <B>
    Compare two versions. Exit 0 if the first is lesser, 1 if not. If verbose, print lesser to stdout.

  equal <A> <B>
    Compare two versions. Exit 0 if they are equal, 1 if not.

    Increment major, minor, or patch component.

    Get major, minor, patch, prerelease or metadata component.

    Set prerelease or metadata component.


Deploy only when the CI tag is within constraints and is greater than what is currently released. For example, with constraints 1.* and a released version of 1.4, a version of 1.5 would be released but a version of 2.0 or 1.2 would not.


CONSTRAINTS=$(jq .labels.constraints manifest.json)
RELEASED=$(jq .image manifest.json | cut -d: -f 2)

semver satisfies "$CI_TAG" "$CONSTRAINTS" || exit 1
semver greater   "$CI_TAG" "$RELEASED"    || exit 1

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more