Bump is a library for working with semantic versioning following the Semantic Versioning 2.0.0 specification. It supports validation, precedence comparison, and increasing version numbers.
A SemVer object representing the version can be created by supplying arguments for the version, preRelease and
buildMetaData parts to the constructor or by supplying a string which will be parsed by the SemVerParser using
parser combinators.
Bump is published for Scala 2.13. To start using it add the following to your build.sbt:
libraryDependencies += "nl.gn0s1s" %% "bump" % "0.1.3"
import nl.gn0s1s.bump._
val version = SemVer(1, 0, 1, Some("alpha"), Some("20180329")) // version: nl.gn0s1s.bump.SemVer = 1.0.1-alpha+20180329
version.nextMinor.withoutPreRelease.withoutBuildMetadata // res0: nl.gn0s1s.bump.SemVer = 1.1.0
val version2 = SemVer("2.0.0").get // version2: nl.gn0s1s.bump.SemVer = 2.0.0
version < version2 // res1: Boolean = true
version2.nextPatch // res2: nl.gn0s1s.bump.SemVer = 2.0.1
val invalidVersion = SemVer("3.0") // invalidVersion: Option[nl.gn0s1s.bump.SemVer] = NoneThe following methods are available on a SemVer object:
toString- returns the semantic versioning 2.0.0 stringcompare- compares the precedence to the supplied SemVernextMajor/bumpMajor- returns a new SemVer with an incrementedmajorand reset (0)minorandpatchversion numbersnextMinor/bumpMinor- returns a new SemVer with an incrementedminorand a reset (0)patchversion numbernextPatch/bumpPatch- returns a new SemVer with an incrementedpatchversion numbernextStable- returns a new SemVer without pre-release information or an incrementedpatchversion numberwithMajor- returns a new SemVer with the suppliedmajorversion numberwithMinor- returns a new SemVer with the suppliedminorversion numberwithPatch- returns a new SemVer with the suppliedpatchversion numberwithPreRelease- returns a new SemVer with the suppliedpreReleasestringwithoutPreRelease- returns a new SemVer without pre-release informationwithBuildMetadata- returns a new SemVer with the suppliedbuildMetadatastringwithoutBuildMetadata- returns a new SemVer without build metadata
The code is available under the MIT license.