https://github.com/davidrjonas/semver-cli
semver-cli is a simple command line tool to compare and manipulate version strings.
https://github.com/davidrjonas/semver-cli
cd ci cli commandline deployment devops scripting semver
Last synced: 21 days ago
JSON representation
semver-cli is a simple command line tool to compare and manipulate version strings.
- Host: GitHub
- URL: https://github.com/davidrjonas/semver-cli
- Owner: davidrjonas
- License: mit
- Created: 2018-04-02T08:49:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T08:53:59.000Z (9 months ago)
- Last Synced: 2025-04-09T20:14:42.672Z (21 days ago)
- Topics: cd, ci, cli, commandline, deployment, devops, scripting, semver
- Language: Go
- Size: 15.6 KB
- Stars: 44
- Watchers: 1
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
semver-cli
==========[](https://travis-ci.org/davidrjonas/semver-cli)
[](https://goreportcard.com/report/github.com/davidrjonas/semver-cli)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](https://github.com/Masterminds/semver), with lots of help from the also excellent [Kingpin](https://github.com/alecthomas/kingpin)
```
usage: semver [] [ ...]Command-line semver tools. On error, print to stderr and exit -1.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-v, --verbose Verbose mode.Commands:
help [...]
Show help.satisfies
Test if a version satisfies a constraint. Exit 0 if satisfies, 1 if not. If verbose, print an explanation to stdout.greater
Compare two versions. Exit 0 if the first is greater, 1 if not. If verbose, print greater to stdout.lesser
Compare two versions. Exit 0 if the first is lesser, 1 if not. If verbose, print lesser to stdout.equal
Compare two versions. Exit 0 if they are equal, 1 if not.inc
Increment major, minor, or patch component.get
Get major, minor, patch, prerelease or metadata component.set
Set prerelease or metadata component.
```Example
-------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.
```bash
#!/bin/bashCONSTRAINTS=$(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 1deploy
```