Skip to content

Commit de6c57b

Browse files
committed
added gitversion/command
1 parent adae2d5 commit de6c57b

File tree

23 files changed

+484
-13
lines changed

23 files changed

+484
-13
lines changed

.azure/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ jobs:
7171
node gitversion/setup/main.mjs
7272
displayName: gitversion/setup
7373
workingDirectory: dist/vsix
74+
- pwsh: |
75+
# set the inputs for the 'gitversion/command' action
76+
$env:INPUT_TARGETPATH = './'
77+
$env:INPUT_ARGUMENTS = '/showvariable FullSemVer'
78+
79+
# run the 'gitversion/command' action
80+
node gitversion/command/main.mjs
81+
displayName: gitversion/command (showvariable)
82+
workingDirectory: dist/vsix
83+
- pwsh: |
84+
# set the inputs for the 'gitversion/command' action
85+
$env:INPUT_TARGETPATH = './'
86+
$env:INPUT_ARGUMENTS = '/format {Major}.{Minor}'
87+
88+
# run the 'gitversion/command' action
89+
node gitversion/command/main.mjs
90+
displayName: gitversion/command (format)
91+
workingDirectory: dist/vsix
7492
- pwsh: |
7593
# set the inputs for the 'gitversion/execute' action
7694
$env:INPUT_TARGETPATH = './'

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ jobs:
5454
uses: ./gitversion/setup
5555
with:
5656
versionSpec: '6.x'
57+
- name: gitversion/command (showvariable)
58+
uses: ./gitversion/command
59+
with:
60+
arguments: '/showvariable FullSemVer'
61+
- name: gitversion/command (format)
62+
uses: ./gitversion/command
63+
with:
64+
arguments: '/format {Major}.{Minor}'
5765
- name: gitversion/execute
5866
id: gitversion # step id used as reference for output values
5967
uses: ./gitversion/execute
1.75 KB
Loading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { run } from './tools/lib.mjs'
2+
await run('azure', 'gitversion', 'command')
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"id": "41dc3dd2-6a51-4ba5-a889-824274acca8b",
3+
"name": "gitversion/command",
4+
"friendlyName": "Command GitVersion Task",
5+
"description": "Easy Semantic Versioning (https://semver.org) for projects using Git",
6+
"author": "GitTools Contributors",
7+
"helpMarkDown": "See the [documentation](https://gitversion.net/docs/) for help",
8+
"category": "Build",
9+
"demands": [],
10+
"version": {
11+
"Major": 0,
12+
"Minor": 0,
13+
"Patch": 1
14+
},
15+
"minimumAgentVersion": "3.224.0",
16+
"execution": {
17+
"Node20_1": {
18+
"target": "main.mjs",
19+
"argumentFormat": "",
20+
"workingDirectory": "."
21+
}
22+
},
23+
"instanceNameFormat": "gitversion/command",
24+
"inputs": [
25+
{
26+
"name": "targetPath",
27+
"type": "string",
28+
"label": "Working directory path",
29+
"defaultValue": "",
30+
"required": false,
31+
"helpMarkDown": "Optionally supply the path to the working directory",
32+
"groupName": "gitversionDetails"
33+
},
34+
{
35+
"name": "disableShallowCloneCheck",
36+
"type": "boolean",
37+
"label": "Disable Shallow Clone Check",
38+
"defaultValue": "false",
39+
"required": false,
40+
"helpMarkDown": "Whether to disable GitVersion shallow clone check"
41+
},
42+
{
43+
"name": "arguments",
44+
"type": "string",
45+
"label": "GitVersion arguments",
46+
"defaultValue": "",
47+
"required": true,
48+
"helpMarkDown": "Arguments to send to GitVersion"
49+
}
50+
]
51+
}

dist/azure/manifest.config.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = (env) => {
55

66
const gitversion = [
77
{ id: 'setup', path: 'gitversion/setup' },
8-
{ id: 'execute', path: 'gitversion/execute' }
8+
{ id: 'execute', path: 'gitversion/execute' },
9+
{ id: 'command', path: 'gitversion/command' }
910
]
1011

1112
const gitreleasemanager = [

dist/azure/tasks.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"execute": {
88
"test": "9b58ed30-0deb-4083-b007-5f6ce7787544",
99
"prod": "9013cf7f-ee8d-49f4-a39b-db244928d391"
10+
},
11+
"command": {
12+
"test": "b5559270-0af3-49c8-bde3-c44847a8503b",
13+
"prod": "41dc3dd2-6a51-4ba5-a889-824274acca8b"
1014
}
1115
},
1216
"gitreleasemanager": {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Command GitVersion Task (gitversion/command) usage Examples
2+
3+
Find out how to use the **gitversion/command** task using the examples below.
4+
5+
Note that if the pipeline is set up to use a shallow git fetch mode the GitVersion Command task will fail. It is required to use `fetchDepth: 0`.
6+
You must also run the GitVersion Setup step before the Command step:
7+
8+
```yaml
9+
steps:
10+
- checkout: self
11+
fetchDepth: 0
12+
13+
- task: gitversion/[email protected]
14+
displayName: Install GitVersion
15+
inputs:
16+
versionSpec: '6.x'
17+
```
18+
19+
These steps are omitted from the examples for brevity.
20+
21+
> The examples use version _2.0.1_ of the GitVersion Command task. It is recommended to use the latest released version in your own workflows.
22+
23+
## Inputs
24+
25+
The Command GitVersion task accepts the following inputs:
26+
27+
```yaml
28+
targetPath:
29+
description: Optionally supply the path to the working directory
30+
required: false
31+
default: ''
32+
disableShallowCloneCheck:
33+
description: Whether to disable the check for shallow clone
34+
required: false
35+
default: 'false'
36+
arguments:
37+
description: Arguments to send to GitVersion
38+
required: true
39+
default: ''
40+
```
41+
42+
---
43+
44+
## Execution Examples
45+
46+
### Example 1
47+
48+
<details>
49+
<summary>Show the effective configuration for GitVersion by running the <b>/showConfig</b> command.</summary>
50+
51+
```yaml
52+
steps:
53+
# gitversion/[email protected] task omitted for brevity.
54+
55+
- task: gitversion/[email protected]
56+
displayName: Display GitVersion config
57+
inputs:
58+
arguments: '/showConfig'
59+
```
60+
61+
</details>
62+
63+
### Example 2
64+
65+
<details>
66+
<summary>Outputs the <i>FullSemVer</i> variable by running the <b>/showvariable FullSemVer</b> command.</summary>
67+
68+
```yaml
69+
steps:
70+
# gitversion/[email protected] task omitted for brevity.
71+
72+
- task: gitversion/[email protected]
73+
displayName: Output the FullSemVer variable
74+
inputs:
75+
arguments: '/showvariable FullSemVer'
76+
```
77+
78+
</details>
79+
80+
### Example 3
81+
82+
<details>
83+
<summary>Outputs the formatted version by running the <b>/format {Major}.{Minor}</b> command.</summary>
84+
85+
```yaml
86+
steps:
87+
# gitversion/[email protected] task omitted for brevity.
88+
89+
- task: gitversion/[email protected]
90+
displayName: Output the formatted version
91+
inputs:
92+
arguments: '/format {Major}.{Minor}' # any Output Variable can be used here
93+
```
94+
95+
</details>

docs/examples/azure/gitversion/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ Note: You need to run the Setup step before the Execute step, otherwise the Exec
1111
## Execute GitVersion (gitversion/execute)
1212

1313
- [Execute](execute.md)
14+
15+
## Execute GitVersion (gitversion/command)
16+
17+
- [Command](command.md)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

Comments
 (0)