No committed version files
Calculate semantic versions from branches, tags, commits, and repository state.
A Rust CLI and GitHub Action for trunk-based repositories with release branches.

Git Versioner calculates semantic versions from Git history. It is designed for trunk-based repositories where trunk, main, or master is the integration line and release branches stabilize individual versions.
cargo install git-versioner
git-versioner- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine Version
id: versioner
uses: crown0815/git-versioner@v1Fetch full history
Git Versioner needs tags and branch history. In GitHub Actions, set fetch-depth: 0 on actions/checkout.
Run Git Versioner from the repository root:
git-versionerUseful options:
| Option | Description |
|---|---|
-p, --path <PATH> | Path to the repository to calculate the version for. |
--main-branch <MAIN_BRANCH> | Regex to detect the main branch. |
--release-branch <RELEASE_BRANCH> | Regex to detect release branches. |
--feature-branch <FEATURE_BRANCH> | Regex to detect feature branches. |
--feature-branch-name-limit <LIMIT> | Maximum length of the escaped feature branch name used in pre-release versions. 0 means no limit (default). |
--tag-prefix <TAG_PREFIX> | Regex to detect version tags. |
--pre-release-tag <PRE_RELEASE_TAG> | Label for pre-release versions, for example pre, alpha, beta, or rc. |
--patch-pre-release-tag <PATCH_PRE_RELEASE_TAG> | Label for patch pre-release versions. Defaults to PreReleaseTag. |
--continuous-delivery | Calculate the version using continuous delivery mode. |
--commit-message-incrementing <VALUE> | Use Enabled or Disabled for conventional commit based increments. |
--assembly-informational-format <FORMAT> | Format string for InformationalVersion. |
-a, --as-release | Force release generation instead of pre-release generation. |
--show-config | Print the effective configuration and exit. |
-c, --config <CONFIG_FILE> | Path to a TOML or YAML configuration file. |
The GitHub Action exports values with a GitVersion_ prefix and also exposes PascalCase output names without the prefix.
- name: Use Version
run: echo "The version is ${{ steps.versioner.outputs.SemVer }}"The GitLab environment output follows the same GitVersion-style naming pattern:
GitVersion_AssemblySemFileVer=0.1.0.55001
GitVersion_AssemblySemVer=0.1.0.0
GitVersion_BranchName=trunk
GitVersion_BuildMetadata=
GitVersion_CalVerDay=09
GitVersion_CalVerMinor=1
GitVersion_CalVerMonth=03
GitVersion_CalVerYear=2024
GitVersion_CommitDate=2024-03-09
GitVersion_CommitDay=09
GitVersion_CommitMonth=03
GitVersion_CommitYear=2024
GitVersion_CommitsSinceVersionSource=0
GitVersion_EscapedBranchName=trunk
GitVersion_FullBuildMetaData=
GitVersion_FullSemVer=0.1.0-pre.1
GitVersion_InformationalVersion=0.1.0-pre.1
GitVersion_Major=0
GitVersion_MajorMinorPatch=0.1.0
GitVersion_Minor=1
GitVersion_Patch=0
GitVersion_PreReleaseLabel=pre
GitVersion_PreReleaseLabelWithDash=-pre
GitVersion_PreReleaseNumber=1
GitVersion_PreReleaseTag=pre.1
GitVersion_PreReleaseTagWithDash=-pre.1
GitVersion_SemVer=0.1.0-pre.1
GitVersion_WeightedPreReleaseNumber=55001Create .git-versioner.toml, .git-versioner.yaml, or .git-versioner.yml in the repository root. All fields are optional.
MainBranch: ^(trunk|main|master)$
ReleaseBranch: ^releases?[/-](?<BranchName>.+)$
FeatureBranch: ^features?[/-](?<BranchName>.+)$
FeatureBranchNameLimit: 0
TagPrefix: '[vV]?'
PreReleaseTag: pre
CommitMessageIncrementing: Disabled
AssemblyInformationalFormat: '{InformationalVersion}'FeatureBranchNameLimit caps the escaped feature branch name that is inserted into the pre-release version (for example, 0.1.0-this-is-a-.1 when the limit is 10). Use this when versions are embedded in file names and a long branch name could exceed path length limits, such as on Windows. A value of 0 disables the limit and preserves the full escaped name.
The same option can also be set in kebab case for TOML and YAML compatibility:
assembly-informational-format: "{InformationalVersion}"AssemblyInformationalFormat supports GitVersion-style placeholders and environment variables.
{InformationalVersion}
{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber ?? 0}
{Major}.{Minor}.{Patch}.{env:BUILD_NUMBER}
{Major}.{Minor}.{Patch}.{env:BUILD_NUMBER ?? 42}This site is generated with VitePress from Markdown source files. That keeps documentation authoring simple while providing a polished static site, navigation, local search, code groups, custom containers, and GitHub Pages deployment.
cd docs
npm install
npm run docs:devThe local documentation site will be available at http://localhost:5173/git-versioner/.