increment
Increments a version, according to the given scheme.
'semver' (default) — bumps major/minor/patch per SemVer, resetting the
finer-grained components (bumping major resets minor and patch to 0, etc.) and
dropping any prerelease/build metadata.
'gentoo' — bumps the component at type’s position (major → 1st, minor → 2nd,
patch → 3rd — Gentoo’s components array can be any length, but the first three follow
the same positional convention as SemVer), zeroing everything after it and dropping the
letter/suffixes/revision.
'debian' — throws: a Debian upstream version is free-form, with no major/minor/patch
structure to bump.
Available since v1.9.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
version | string | The version to increment |
type | IncrementType | The increment type (‘major’, ‘minor’, ‘patch’) |
scheme | VersionScheme | Which version scheme to interpret `version` as. Defaults to `‘semver’`. (optional) |
Returns
Section titled “Returns”string — Incremented version string
Examples
Section titled “Examples”Increment the patch version
Section titled “Increment the patch version”Bumps the patch number while keeping major and minor.
Increment the minor version
Section titled “Increment the minor version”Bumps the minor number and resets patch to 0.
Preserve the v prefix
Section titled “Preserve the v prefix”The v prefix is preserved if present in the input.
Increment a Gentoo/Portage version
Section titled “Increment a Gentoo/Portage version”Drops any letter/suffix/revision and resets components after the bumped one, same as the SemVer scheme.
Related Types
Section titled “Related Types”IncrementType
Section titled “IncrementType”The unit to bump — see increment.
VersionScheme
Section titled “VersionScheme”Identifies which version scheme parse/compare should use to interpret a
version string. Defaults to 'semver' everywhere it’s accepted.
