{"id":22822033,"url":"https://github.com/olivki/semver4k","last_synced_at":"2025-10-12T22:32:36.631Z","repository":{"id":53850003,"uuid":"375783794","full_name":"Olivki/semver4k","owner":"Olivki","description":"A Kotlin multiplatform implementation of the semantic versioning 2.0 specification.","archived":false,"fork":false,"pushed_at":"2022-08-05T16:47:08.000Z","size":185,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T05:14:02.710Z","etag":null,"topics":["kotlin","kotlin-library","kotlin-multiplatform","semver","semver-compare","semver-parser"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Olivki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-10T17:50:30.000Z","updated_at":"2022-05-03T13:50:14.000Z","dependencies_parsed_at":"2022-08-24T14:52:21.292Z","dependency_job_id":null,"html_url":"https://github.com/Olivki/semver4k","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olivki%2Fsemver4k","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olivki%2Fsemver4k/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olivki%2Fsemver4k/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Olivki%2Fsemver4k/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Olivki","download_url":"https://codeload.github.com/Olivki/semver4k/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246395574,"owners_count":20770240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","kotlin-library","kotlin-multiplatform","semver","semver-compare","semver-parser"],"created_at":"2024-12-12T16:10:14.743Z","updated_at":"2025-10-12T22:32:31.595Z","avatar_url":"https://github.com/Olivki.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## semver4k\n\n![Maven Central](https://img.shields.io/maven-central/v/net.ormr.semver4k/semver4k?label=RELEASE\u0026style=for-the-badge)\n\nA no dependencies, Kotlin multiplatform implementation of the semantic versioning 2.0 specification. \n\nSupports building semantic versions directly, and parsing valid semantic versions.\n\n## Installation\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"net.ormr.semver4k:semver4k:${RELEASE_VERSION}\")\n    // if you want kotlinx.serialization support\n    implementation(\"net.ormr.semver4k:semver4k-serialization:${RELEASE_VERSION}\")\n}\n```\n\n## Serialization\nIf serialization support for `SemVer` instances is desired, include the `semver4k-serialization` dependency as shown in the [Installation](#installation) section.\n\nThen either annotate the desired `SemVer` properties with `@Serializable(with = SemVerStringSerializer::class)` or just replace the `SemVer` type with the `SerializableSemVer` type. *(`SerializableSemVer` is just a type-alias, not its own concrete type)*\n\nAn extension function for adding a contextual serializer in a `SerializersModuleBuilder` instance is also provided, named `installSemVerStringSerializer`.\n\nThe `kotlinx.serialization` support was split into its own module for the sake of keeping the core library small and light-weight without any external dependencies. \n\n## Usage\n\n### Building a `SemVer` instance\n\n#### Via the `SemVer` factory function\n\n```kotlin\nSemVer(1u, 0u, 0u, preRelease = \"alpha.1\", buildMetadata = \"a474fh6\")\n```\n\n#### Invoking the constructor directly\n\n```kotlin\nSemVer(\n    1u, \n    0u, \n    0u, \n    preRelease = listOf(Identifier(\"alpha\"), Identifier(1u)),\n    buildMetadata = listOf(Identifier(\"a474fh6\")),\n)\n```\n\nIn both cases `preRelease` and `buildMetadata` are optional, and can be omitted if not needed.\n\n### Parsing a `SemVer` instance\n\n```kotlin\nSemVer.parse(\"1.0.0-alpha.1+a474fh6\")\n```\n\nThe above string will be parsed into an instance that is structurally the same as the instances created above.\n\nNote that `parse` does not return a `SemVer` instance, but rather a [`Result\u003cSemVer\u003e`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/) and needs to be handled appropriately.\n\n### Comparing two `SemVer` instances\n\n`SemVer` implements the `Comparable` interface, so all operators and functions that work with that will work with the `SemVer` instance, i.e: `\u003c \u003e \u003c= \u003e=`.\n\n```kotlin\nSemVer(1u, 0u, 0u) \u003e SemVer(0u, 10u, 2u) // true\nSemVer(1u, 0u, 0u) \u003c SemVer(0u, 10u, 2u) // false\n// etc...\n```\n\n### Modifying a `SemVer` instance\n\n`SemVer` instances are not mutable.\n\nTherefore it is not possible to just modify an existing instance, and instead the `copy` function should be used to create an updated instance.\n\nThere is currently no convenience functions for operations like just incrementing the major, minor or patch number, there may be some added in the future.\n\n## Info\nPlease note that this library is made with Kotlin exclusive use in mind, and therefore uses [unsigned integers](https://kotlinlang.org/docs/basic-types.html#unsigned-integers) to represent the major, minor and patch versions. This may result in weird interop if `SemVer` instances are used in a shared Java/JS code base.\n\nThe only thing to look out for is that the equality and comparability of two `SemVer` instances are *not* guaranteed to be the same. Comparability of two instances ignores the build metadata, as per the specification, but equality checks includes the build metadata. This means that two instances which may be equal according to `compareTo` may not actually be equal according to the equality check. This may or may not change in the future.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivki%2Fsemver4k","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folivki%2Fsemver4k","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivki%2Fsemver4k/lists"}