Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.22 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.22 KB

SemVer

codecov

Kotlin data class for Semantic Versioning 2.0.0 specification with Kotlin Multiplatform and Serialization support.

Support parsing version number string and comparing version numbers using Comparable interface.

Installation

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation("net.swiftzer.semver:semver:2.0.0")
}

Usage

Parsing version number

val version: SemVer = SemVer.parse("1.0.0-beta+exp.sha.5114f85")

version.major // 1
version.minor // 0
version.patch // 0
version.preRelease // "beta"
version.buildMetadata // "exp.sha.5114f85"

Comparing version numbers

val semVer1 = SemVer(1, 0, 0)
val semVer2 = SemVer(1, 0, 2)
assertTrue(semVer1 < semVer2)

Creating next version numbers

val semVer = SemVer(1, 3, 5)
assertEquals(SemVer(1, 3, 6), semVer.nextPatch())
assertEquals(SemVer(1, 4, 0), semVer.nextMinor())
assertEquals(SemVer(2, 0, 0), semVer.nextMajor())