semantic_release.version.version module

class semantic_release.version.version.Version(major: int, minor: int, patch: int, *, prerelease_token: str = 'rc', prerelease_revision: int | None = None, build_metadata: str = '', tag_format: str = 'v{version}')[source]

Bases: object

as_semver_tag() str[source]
as_tag() str[source]
bump(level: LevelBump) Version[source]

Return a new Version instance according to the level specified to bump. Note this will intentionally drop the build metadata - that should be added elsewhere for the specific build producing this version.

finalize_version() Version[source]
property is_prerelease: bool
classmethod parse(version_str: str, tag_format: str = 'v{version}', prerelease_token: str = 'rc') Version[source]

Parse version string to a Version instance. Inspired by semver.version:VersionInfo.parse, this implementation doesn’t allow optional minor and patch versions.

Parameters:

prerelease_token – will be ignored if the version string is a prerelease, the parsed token from version_str will be used instead.

property tag_format: str
to_prerelease(token: str | None = None, revision: int | None = None) Version[source]