Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement full semver spec #867

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1294,13 +1294,16 @@ Response:

##### Version Object

Parsed Semantic Versioning 2.0.0. See https://semver.org/ for more info

| Field | Type | Description |
|------------|---------|------------------------------------------------------------------------------------|
| semver | string | The full version string of this Lavalink server |
| major | int | The major version of this Lavalink server |
| minor | int | The minor version of this Lavalink server |
| patch | int | The patch version of this Lavalink server |
| preRelease | ?string | The pre-release version according to semver as a `.` separated list of identifiers |
| build | ?string | The build metadata according to semver as a `.` separated list of identifiers |

##### Git Object

Expand All @@ -1323,11 +1326,12 @@ Response:
```json
{
"version": {
"string": "3.7.0-rc.1",
"string": "3.7.0-rc.1+test",
"major": 3,
"minor": 7,
"patch": 0,
"preRelease": "rc.1"
"preRelease": "rc.1",
"build": "test"
},
"buildTime": 1664223916812,
"git": {
Expand All @@ -1343,9 +1347,9 @@ Response:
],
"filters": [
"equalizer",
"karaoke",
"timescale",
"channelMix"
"karaoke",
"timescale",
"channelMix"
],
"plugins": [
{
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@ Please see [here](CHANGELOG.md)

Lavalink follows [Semantic Versioning](https://semver.org/).

Given a version number `MAJOR.MINOR.PATCH`, the following rules apply:
The version number is composed of the following parts:

MAJOR breaking API changes
MINOR new backwards compatible features
PATCH backwards compatible bug fixes
PRERELEASE pre-release version
BUILD additional build metadata

Additional labels for release candidates are available as extensions to the `MAJOR.MINOR.PATCH-rcNUMBER`(`3.6.0-rc1`) format.
Version numbers can come in different combinations, depending on the release type:

`MAJOR.MINOR.PATCH` - Stable release
`MAJOR.MINOR.PATCH+BUILD` - Stable release with additional build metadata
`MAJOR.MINOR.PATCH-PRERELEASE` - Pre-release
`MAJOR.MINOR.PATCH-PRERELEASE+BUILD` - Pre-release additional build metadata

---

## Client libraries:
| Client | Platform | Compatible With | REST API Support | Additional Information |
Expand Down
10 changes: 5 additions & 5 deletions protocol/src/main/java/dev/arbjerg/lavalink/protocol/v3/info.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ data class Version(
val minor: Int,
val patch: Int,
val preRelease: String?,
val build: String?,
) {
companion object {

private val versionRegex =
Regex("""^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?""")

private val versionRegex = Regex("""^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<build>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$""")
fun fromSemver(semver: String): Version {
val match = versionRegex.matchEntire(semver) ?: return Version(semver, 0, 0, 0, null)
val match = versionRegex.matchEntire(semver) ?: return Version(semver, 0, 0, 0, null, null)
val major = match.groups["major"]!!.value.toInt()
val minor = match.groups["minor"]!!.value.toInt()
val patch = match.groups["patch"]!!.value.toInt()
val preRelease = match.groups["prerelease"]?.value
return Version(semver, major, minor, patch, preRelease)
val build = match.groups["build"]?.value
return Version(semver, major, minor, patch, preRelease, build)
}
}
}
Expand Down