|
| 1 | +# Command GitVersion Action (gitversion/command) usage Examples |
| 2 | + |
| 3 | +Find out how to use the **gitversion/command** action using the examples below. |
| 4 | + |
| 5 | +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`. |
| 6 | +You must also run the GitVersion Setup step before the Command step: |
| 7 | + |
| 8 | +```yaml |
| 9 | +steps: |
| 10 | + - name: Checkout |
| 11 | + uses: actions/checkout@v4 |
| 12 | + with: |
| 13 | + fetch-depth: 0 |
| 14 | + |
| 15 | + - name: Install GitVersion |
| 16 | + uses: gittools/actions/gitversion/[email protected] |
| 17 | + with: |
| 18 | + versionSpec: '6.x' |
| 19 | +``` |
| 20 | +
|
| 21 | +These steps are omitted from the examples for brevity. |
| 22 | +
|
| 23 | +> The examples use version _2.0.1_ of the GitVersion Command action. It is recommended to use the latest released version in your own workflows. |
| 24 | +
|
| 25 | +## Inputs |
| 26 | +
|
| 27 | +The Command GitVersion action accepts the following inputs: |
| 28 | +
|
| 29 | +```yaml |
| 30 | +targetPath: |
| 31 | + description: Optionally supply the path to the working directory |
| 32 | + required: false |
| 33 | + default: '' |
| 34 | +disableShallowCloneCheck: |
| 35 | + description: Whether to disable the check for shallow clone |
| 36 | + required: false |
| 37 | + default: 'false' |
| 38 | +arguments: |
| 39 | + description: Arguments to send to GitVersion |
| 40 | + required: true |
| 41 | + default: '' |
| 42 | +``` |
| 43 | +
|
| 44 | +--- |
| 45 | +
|
| 46 | +## Execution Examples |
| 47 | +
|
| 48 | +### Example 1 |
| 49 | +
|
| 50 | +<details> |
| 51 | + <summary>Show the effective configuration for GitVersion by running the <b>/showConfig</b> command.</summary> |
| 52 | +
|
| 53 | +```yaml |
| 54 | +steps: |
| 55 | + # gittools/actions/gitversion/[email protected] action omitted for brevity. |
| 56 | + |
| 57 | + - name: Display GitVersion config |
| 58 | + uses: gittools/actions/gitversion/[email protected] |
| 59 | + with: |
| 60 | + useConfigFile: true |
| 61 | + arguments: '/showConfig' |
| 62 | +``` |
| 63 | +
|
| 64 | +</details> |
| 65 | +
|
| 66 | +### Example 2 |
| 67 | +
|
| 68 | +<details> |
| 69 | + <summary>Outputs the <i>FullSemVer</i> variable by running the <b>/showvariable FullSemVer</b> command.</summary> |
| 70 | +
|
| 71 | +```yaml |
| 72 | +steps: |
| 73 | + # gittools/actions/gitversion/[email protected] action omitted for brevity. |
| 74 | + |
| 75 | + - name: Output the FullSemVer variable |
| 76 | + uses: gittools/actions/gitversion/[email protected] |
| 77 | + with: |
| 78 | + arguments: '/showvariable FullSemVer' |
| 79 | +``` |
| 80 | +
|
| 81 | +</details> |
| 82 | +
|
| 83 | +### Example 3 |
| 84 | +
|
| 85 | +<details> |
| 86 | + <summary>Outputs the formatted version by running the <b>/format {Major}.{Minor}</b> command.</summary> |
| 87 | +
|
| 88 | +```yaml |
| 89 | +steps: |
| 90 | + # gittools/actions/gitversion/[email protected] action omitted for brevity. |
| 91 | + |
| 92 | + - name: Output the formatted version |
| 93 | + uses: gittools/actions/gitversion/[email protected] |
| 94 | + with: |
| 95 | + arguments: '/format {Major}.{Minor}' # any Output Variable can be used here |
| 96 | +``` |
| 97 | +
|
| 98 | +</details> |
0 commit comments