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@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.0.x'
These steps are omitted from the examples for brevity.
The examples use version 3.1.11 of the GitVersion Command action. It is recommended to use the latest released version in your own workflows.
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: ''
Show the effective configuration for GitVersion by running the /showConfig command.
steps:
# gittools/actions/gitversion/[email protected] action omitted for brevity.
- name: Display GitVersion config
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
arguments: '/showConfig'
Outputs the FullSemVer variable by running the /showvariable 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: '/showvariable 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 here