CLI tools for Semantic Versioning.
Print version information.
semver info <version> [--format <format>]
or semver <version> [--format <format>]
swift run semver 1.0.0-beta.1
# buildMetaData : <null>
# major : 1
# minor : 0
# nextMajor : 2.0.0
# nextMinor : 1.1.0
# nextPatch : 1.0.1
# patch : 0
# preRelease : beta.1
Print with JSON format.
swift run semver 1.0.0-beta.1 --format json
# {"buildMetaData":null,"major":1,"minor":0,"nextMajor":"2.0.0","nextMinor":"1.1.0","nextPatch":"1.0.1","patch":0,"preRelease":"beta.1"}
Pipe with jq
.
swift run semver 1.0.0-beta.1 --format json | jq '.nextPatch'
# "1.0.1"
Increment version.
semver increment --major --minor --patch <version>
# increment major version
swift run semver increment --major 1.0.0-beta.1
# 2.0.0
# increment minor version
swift run semver increment --minor 1.0.0-beta.1
# 1.1.0
# increment patch version
swift run semver increment --patch 1.0.0-beta.1
# 1.0.1
Compare versions with >
, >=
.
semver gt <version1> <version2>
, semver gte <version1> <version2>
If <version1>
is greater than (or equal to) <version2>
, 1
is printed. Otherwise, 0
is printed.
swift run semver gt 1.0.0 1.0.1
# 0
swift run semver gt 1.1.0 1.0.1
# 1
swift run semver gte 1.0.0 1.0.0
# 1
Compare versions with <
, <=
.
semver lt <version1> <version2>
, semver lte <version1> <version2>
If <version1>
is less than (or equal to) <version2>
, 0
is printed. Otherwise, 1
is printed.
swift run semver lt 1.0.0 1.0.1
# 1
swift run semver lt 1.1.0 1.0.1
# 0
swift run semver lte 1.0.0 1.0.0
# 1
- Swift 5.5 or later
- macOS 10.13+ or iOS 11.0+ or watchOS 4.0+ or tvOS 11.0+
- Apple Platforms
- Linux