semver is a little tool to manipulate the version bumping in a project that follows the Semver Specification 2.0 .
Its use are:
- bump version
- extract specific version part
- compare versions
A version must match the following regular expression:
^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$
In English:
- The version must match X.Y.Z[-PRERELEASE][+BUILD] where X, Y and Z are non-negative integers.
- PRERELEASE is a dot separated sequence of non-negative integers and/or identifiers composed of alphanumeric characters and hyphens (with at least one non-digit). Numeric identifiers must not have leading zeros. A hyphen ("-") introduces this optional part.
- BUILD is a dot separated sequence of identifiers composed of alphanumeric characters and hyphens. A plus ("+") introduces this optional part.
mvn clean install
import com.github.wonno.semver.Semver
//version validation
assert !Semver.validate("1.2.invalid")
//version change
assert Semver.parse("1.2.3+abcd").prerel("rc1").minor().text()=="1.3.0"
//version comparison
assert Semver.parse("1.0.7+acf430") < new Semver("1.0.6").patch()
- Semver Specification 2.0
- Inspired by semver-tool written in bash.
- semver-tool project for the regex and the testcases