Getting Started
A Scala 3 toolkit for intent-based versioning conforming to Semantic Versioning 2.0.0.
What's Included
| Module | Dependency | Purpose |
|---|---|---|
| Core library | "africa.shuwari" %% "version" % "0.6.2" |
SemVer types and operations |
| CLI core | "africa.shuwari" %% "version-cli-core" % "0.6.2" |
Git-based version derivation engine |
| Jsoniter codec | "africa.shuwari" %% "version-codecs-jsoniter" % "0.6.2" |
JSON codecs |
| ZIO JSON codec | "africa.shuwari" %% "version-codecs-zio" % "0.6.2" |
JSON codecs |
| YAML codec | "africa.shuwari" %% "version-codecs-yaml" % "0.6.2" |
YAML codecs |
| ZIO Prelude | "africa.shuwari" %% "version-zio-prelude" % "0.6.2" |
Type class instances |
| sbt Plugin | addSbtPlugin("africa.shuwari" % "sbt-version" % "0.6.2") |
sbt plugin implementation |
Use %%% instead of %% for Scala.js and Scala Native.
Platform Support
| Scala | JDK | Scala.js | Scala Native |
|---|---|---|---|
| 3.7.4+ | 17.0.17+ | 1.20.2+ | 0.5.9+ |
Quick Example
import version.*
import version.given
// Parse a version string
val v = "1.2.3-alpha.1".toVersionUnsafe
// Inspect components
v.major.value // 1
v.minor.value // 2
v.patch.value // 3
v.preRelease.isDefined // true
// Bump versions
v.next[MajorVersion] // 2.0.0
v.next[MinorVersion] // 1.3.0
v.next[PatchNumber] // 1.2.4
// Advance within same pre-release
v.next[Alpha] // 1.2.3-alpha.2
// Work with pre-releases
v.core // 1.2.3
v.as[Snapshot] // 1.2.3-SNAPSHOT
Objectives
Version numbers should encode intent, not build artefacts. This toolkit supports a declarative approach:
- Commit messages express semantic intent — use directives like
breaking:,feature:, ortarget: 2.0.0 - Git tags mark releases — annotated tags define version boundaries
- Build tools derive versions — the sbt plugin computes versions from Git state
This eliminates manual version bumping whilst preserving control over version semantics.
Next steps
- Core Library — understand the version model
- Automatic Versioning — set up Git-based resolution
- sbt Plugin — integrate with your build
Licence
Licensed under the Apache License, Version 2.0.
In this article