Skip to main content

Overview

gitversion action

The gitversion action automatically calculates semantic version numbers for your builds based on your Git repository history using GitVersion. It analyzes your commit history, branches, and tags to determine the appropriate version number following semantic versioning principles (Major.Minor.Patch).

This action eliminates manual version management by deriving versions from your Git branching strategy. It provides consistent, reproducible version numbers across builds and generates various version formats suitable for different purposes (NuGet packages, assemblies, Docker tags, etc.).

The action also extracts branch information and assigns branch-specific tags (e.g., 'alpha' for development branches, 'beta' for release branches, 'main' for production) that can be used for tagging artifacts.

Inputs

InputRequiredDefaultDescription
targetPathNo''The path to the working directory containing the Git repository. Defaults to the repository root.
useConfigFileNotrueWhether to use a GitVersion configuration file to customize versioning behavior.
configFilePathNo''Path to a custom GitVersion configuration file. If not specified and useConfigFile is true, downloads the default config from the KingTech repository.
updateAssemblyInfoNofalseWhether to automatically update version numbers in .NET AssemblyInfo files.
updateAssemblyInfoFilenameNo''Specific AssemblyInfo filename to update with version information.
additionalArgumentsNo''Additional command-line arguments to pass to the GitVersion tool.

Outputs

OutputDescriptionExample
versionThe full semantic version number (SemVer).1.2.3
branchThe name of the current Git branch.development
branchTagA tag derived from the branch name: 'main' for main branch, 'beta' for release branches, 'alpha' for development, 'dev' for others.alpha

Additionally, the action outputs numerous GitVersion properties including major, minor, patch, preReleaseTag, nuGetVersion, assemblySemVer, shortSha, and many more that can be accessed via ${{ steps.<step-id>.outputs.<property> }}.