Note that this fork is under heavy redevelopment and should be treated as a moving target until there is a stable release
It is basically a Kong CLI wrapper around the excellent Masterminds semver library.
$ semver --help
Usage: semver <command>
command-line semantic versioning tools
Commands:
satisfies (sat) test if a version satisfies given constraints
greater (gt) compare two versions, successful if the first is greater
lesser (lt) compare two versions, successful if the second is greater
equal (eq) compare two versions, successful if they are equal
increment (inc) increment major, minor, or patch component
get get major, minor, or patch component
set set prerelease or metadata component
latest (lat) list latest version from a list of versions
Flags:
-h, --help Show context-sensitive help.
-V, --verbose enable verbose output
-v, --version display version information and exit
Run "semver <command> --help" for more information on a command.
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.
#!/bin/bash
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
deploy