Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Kotlin Build Status Codecov

Semantic Versioning

Semantic Versioning implementation in Kotlin. Semver represents the versioning system specified in Semantic Versioning Specification.

Installation

Semver requires no external dependencies. You can install the library via:

Gradle

// build.gradle
repositories {
    jcenter()
}
dependencies {
    implementation 'com.github.glwithu06.semver:semver:x.y.z'
}

JitPack

// build.gradle
repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.glwithu06:semver.kt:x.y.z'
}

Usage

Create

You can create a Semver instance like the following:

val version = Semver(major = 1, minor = 23, patch = 45, prereleaseIdentifiers = listOf("rc", "1"), buildMetadataIdentifiers = listOf("B001"))

minor, patch are optional parameters and set to "0" by default.

prereleaseIdentifiers, buildMetadataIdentifiers are optional parameters and set to empty lists by default.

Parse

You can create Semver from String:

val version = Semver("1.23.45-rc.1+B001")

or from Numeric:

val version = Semver(1.23)
val version = Semver(10)

If the given argument has an invalid format, it throws a IllegalArgumentException.

Compare

Semver class implements Comparable interface and overrides equals(), so their instances can be compared using the default operators including < , <= , > ,>= ,== , !=.

The comparison rules are specified in Semantic Versioning Specification.

Contribution

Pull requests and bug reports are welcomed!

Feel free to make a pull request.

About

Semantic versioning framework in Kotlin

Topics

Resources

License

Packages

No packages published

Languages