Documentation
¶
Overview ¶
gitsemver prints or validates semVer-compatible version strings for git refs.
Usage:
gitsemver version [--dir <path>] [--ref <ref>] gitsemver next <bump-type> [--last-tag <tag>] gitsemver validate [--type dev|rc|stable|any] <version>
The "version" subcommand resolves and prints the version for a git ref:
For a ref that carries a stable tag (vX.Y.Z) it prints X.Y.Z.
For a pre-release tag (vX.Y.Z-rc.N) it prints X.Y.Z-rc.N.
For an untagged ref it prints a dev build:
X.Y.(Z+1)-dev.<branch>.<YYYY-MM-DD>.<HH-MM-SS>
where X.Y.Z is the most recent stable ancestor tag reachable from the ref,
or 0.0.0 when none exists.
The "next" subcommand computes the next semver tag from the highest-semver tag reachable from HEAD. Valid bump types from a stable tag: patch, minor, major, patch-rc, minor-rc, major-rc. Valid from an RC tag: rc, rc-release. Use --last-tag to skip git and compute directly from a supplied base tag.
The "validate" subcommand checks whether a version string matches the expected format. It exits 0 and prints "valid" on success, exits 1 and prints "invalid" otherwise.
Environment variables:
GS_BRANCH_NAME Override the branch name embedded in dev builds.
Defaults to the HEAD branch of the repo, then "unknown".
GS_GIT_TAG_PREFIX Monorepo support: only consider tags prefixed with
"<value>/", e.g. "module-a/v1.2.3". The "next --last-tag"
flag accepts both prefixed ("module-a/v1.2.3") and bare
("v1.2.3") forms; the prefix is stripped automatically.
Click to show internal directories.
Click to hide internal directories.