Find out how to use the gitversion/command action using the examples below.
Note that if the pipeline is set up to use a shallow git fetch mode the GitVersion Command action will fail. It is required to use fetch-depth: 0.
You must also run the GitVersion Setup step before the Command step:
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '7.0.x'These steps are omitted from the examples for brevity.
These examples require GitTools Actions v5 with GitVersion 7.0.x. Use Actions v4 with GitVersion 6.
The Command GitVersion action accepts the following inputs:
targetPath:
description: Optionally supply the path to the working directory
required: false
default: ''
disableShallowCloneCheck:
description: Whether to disable the check for shallow clone
required: false
default: 'false'
arguments:
description: Arguments to send to GitVersion
required: true
default: ''
verbosity:
description: Verbosity for the GitVersion process (quiet, minimal, normal, verbose, diagnostic)
required: false
default: 'normal'Show the effective configuration for GitVersion by running the --show-config command.
steps:
# gittools/actions/gitversion/[email protected] action omitted for brevity.
- name: Display GitVersion config
uses: gittools/actions/gitversion/[email protected]
with:
arguments: '--show-config'Outputs the FullSemVer variable by running the --show-variable FullSemVer command.
steps:
# gittools/actions/gitversion/[email protected] action omitted for brevity.
- name: Output the FullSemVer variable
uses: gittools/actions/gitversion/[email protected]
with:
arguments: '--show-variable FullSemVer'Outputs the formatted version by running the --format {Major}.{Minor} command.
steps:
# gittools/actions/gitversion/[email protected] action omitted for brevity.
- name: Output the formatted version
uses: gittools/actions/gitversion/[email protected]
with:
arguments: '--format {Major}.{Minor}' # any Output Variable can be used hereShow the effective configuration with reduced verbosity to avoid stdout maxBuffer length exceeded errors on large repositories.
steps:
# gittools/actions/gitversion/[email protected] action omitted for brevity.
- name: Display GitVersion config
uses: gittools/actions/gitversion/[email protected]
with:
arguments: '--show-config'
verbosity: 'minimal'