Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7077a451c2 | ||
|
|
6ac083e814 | ||
|
|
3cebe1af29 | ||
|
|
0e4a66de68 | ||
|
|
aabbfd473b | ||
|
|
0674a52456 | ||
|
|
c796da950c | ||
|
|
b8f9f37f16 | ||
|
|
2303858797 | ||
|
|
57796af8bc | ||
|
|
e78519b3bd | ||
|
|
a3922ba505 | ||
|
|
38d0dcd8ed | ||
|
|
774f588a83 | ||
|
|
941d214e6a | ||
|
|
50a657f628 | ||
|
|
b2a97a5d32 | ||
|
|
fe418bc8f9 | ||
|
|
a03a71f5b9 | ||
|
|
3fee7a63b8 | ||
|
|
e0bb3399e3 | ||
|
|
c03aad052d | ||
|
|
e0cf9ee6df | ||
|
|
8688d41edf | ||
|
|
3e24dc8cc8 | ||
|
|
3802a495ed | ||
|
|
4ec6a001cc | ||
|
|
b9716b3284 | ||
|
|
72d71e3825 | ||
|
|
12703e7f24 | ||
|
|
62f943a7b7 | ||
|
|
0b2f796e4d | ||
|
|
e971e77318 | ||
|
|
b925f8e478 | ||
|
|
a33003e772 | ||
|
|
a448a9f0a2 | ||
|
|
2d2c6d300f | ||
|
|
f9651f49f0 | ||
|
|
4c753ece22 | ||
|
|
3de8a57a92 | ||
|
|
18efce22d9 | ||
|
|
4ace268ae2 | ||
|
|
6a7df9e3f1 | ||
|
|
a7fd499098 | ||
|
|
b55b3344de | ||
|
|
965ad03650 | ||
|
|
9a35a04f4c | ||
|
|
b7cd8c7635 | ||
|
|
936c2a5f80 | ||
|
|
f9e93cf489 | ||
|
|
246501445f | ||
|
|
5576f1f4f3 | ||
|
|
4b8e1b04eb | ||
|
|
f6df8a60a7 | ||
|
|
6eb9c9d972 | ||
|
|
e72a3b732f | ||
|
|
512189b67e | ||
|
|
04dabe3db9 | ||
|
|
a5bd3bccab | ||
|
|
ace779fa65 | ||
|
|
e36b091f69 | ||
|
|
0f5d09ce56 | ||
|
|
ae681f57e6 | ||
|
|
26360d9b0f | ||
|
|
c4fd6f73e9 | ||
|
|
b3e9769761 | ||
|
|
d08937d559 | ||
|
|
3ae78bd823 | ||
|
|
d7bba81943 | ||
|
|
302eb63bc1 | ||
|
|
4c0ce0e112 | ||
|
|
a7224f5869 | ||
|
|
00d67e69f0 | ||
|
|
6ef8699cb2 | ||
|
|
1c12327cd0 |
12
README.md
@@ -2,13 +2,15 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
GitHub Actions that allow to install and use the [GitVersion](https://github.com/GitTools/GitVersion) and [GitReleaseManager](https://github.com/GitTools/GitReleaseManager) tools
|
GitHub Actions that allow the setup and use of the [GitVersion](https://github.com/GitTools/GitVersion) and [GitReleaseManager](https://github.com/GitTools/GitReleaseManager) tools.
|
||||||
|
|
||||||
[](https://github.com/GitTools/actions/actions)
|
[](https://github.com/GitTools/actions/actions)
|
||||||
[](https://github.com/GitTools/actions/actions)
|
[](https://github.com/GitTools/actions/actions)
|
||||||
|
|
||||||
[](https://marketplace.visualstudio.com/items?itemName=gittools.gittools)
|
[](https://github.com/GitTools/actions/releases/latest)
|
||||||
[](https://github.com/marketplace/actions/use-actions)
|
|
||||||
|
[](https://marketplace.visualstudio.com/items?itemName=gittools.gittools)
|
||||||
|
[](https://github.com/marketplace/actions/gittools)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -17,11 +19,11 @@ GitHub Actions that allow to install and use the [GitVersion](https://github.com
|
|||||||
Examples for usage of **GitVersion**:
|
Examples for usage of **GitVersion**:
|
||||||
|
|
||||||
- [GitHub Actions](docs/examples/github/gitversion/index.md)
|
- [GitHub Actions](docs/examples/github/gitversion/index.md)
|
||||||
- [Azure Pipeline tasks](docs/examples/azure/gitversion/index.md)
|
- [Azure Pipelines tasks](docs/examples/azure/gitversion/index.md)
|
||||||
|
|
||||||
### GitReleaseManager
|
### GitReleaseManager
|
||||||
|
|
||||||
Examples for usage of **GitReleaseManager**:
|
Examples for usage of **GitReleaseManager**:
|
||||||
|
|
||||||
- [GitHub Actions](docs/examples/github/gitreleasemanager/index.md)
|
- [GitHub Actions](docs/examples/github/gitreleasemanager/index.md)
|
||||||
- [Azure Pipeline tasks](docs/examples/azure/gitreleasemanager/index.md)
|
- [Azure Pipelines tasks](docs/examples/azure/gitreleasemanager/index.md)
|
||||||
|
|||||||
13
action.yml
@@ -1,18 +1,9 @@
|
|||||||
name: use-actions
|
name: GitTools
|
||||||
description: GitHub Action for Easy Semantic Versioning with GitVersion. Installs the specific version of GitVersion.Tool
|
description: Build tasks for easy semantic versioning for projects using Git and release management.
|
||||||
author: GitTools
|
author: GitTools
|
||||||
branding:
|
branding:
|
||||||
color: gray-dark
|
color: gray-dark
|
||||||
icon: git-pull-request
|
icon: git-pull-request
|
||||||
inputs:
|
|
||||||
versionSpec:
|
|
||||||
description: Required version in the form of 5.x or exact version like 5.0.0
|
|
||||||
required: true
|
|
||||||
default: ''
|
|
||||||
includePrerelease:
|
|
||||||
description: Include pre-release versions when matching a version
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: dist/github/setup/index.js
|
main: dist/github/setup/index.js
|
||||||
|
|||||||
1051
dist/azure/gitreleasemanager/addasset/bundle.js
vendored
1051
dist/azure/gitreleasemanager/close/bundle.js
vendored
1051
dist/azure/gitreleasemanager/create/bundle.js
vendored
1051
dist/azure/gitreleasemanager/discard/bundle.js
vendored
1051
dist/azure/gitreleasemanager/open/bundle.js
vendored
1051
dist/azure/gitreleasemanager/publish/bundle.js
vendored
1051
dist/azure/gitreleasemanager/setup/bundle.js
vendored
1105
dist/azure/gitversion/execute/bundle.js
vendored
BIN
dist/azure/gitversion/execute/icon.png
vendored
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.8 KiB |
1105
dist/azure/gitversion/setup/bundle.js
vendored
BIN
dist/azure/gitversion/setup/icon.png
vendored
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
dist/azure/images/build-task.png
vendored
|
Before Width: | Height: | Size: 24 KiB |
BIN
dist/azure/images/icon.png
vendored
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
dist/azure/images/pipeline-editor-tasks.png
vendored
Normal file
|
After Width: | Height: | Size: 37 KiB |
9
dist/azure/overview.md
vendored
@@ -2,5 +2,10 @@ Versioning when using Git, solved. GitVersion looks at your Git history and work
|
|||||||
|
|
||||||
It works with most branching strategies but has been designed mainly around GitFlow and GitHubFlow (pull request workflow). The calculated version numbers can then be accessed through variables such as `$(GitVersion.NuGetVersion)` and `$(GitVersion.SemVer)`. It is also very configurable to allow it to work with most release workflows!
|
It works with most branching strategies but has been designed mainly around GitFlow and GitHubFlow (pull request workflow). The calculated version numbers can then be accessed through variables such as `$(GitVersion.NuGetVersion)` and `$(GitVersion.SemVer)`. It is also very configurable to allow it to work with most release workflows!
|
||||||
|
|
||||||

|
## Azure Pipelines tasks
|
||||||

|
|
||||||
|

|
||||||
|
|
||||||
|
## Azure Pipelines run examples
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
BIN
dist/azure/screenshots/pipeline-editor-execute-gitversion-task.png
vendored
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
dist/azure/screenshots/pipeline-editor-setup-gitversion-task.png
vendored
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
dist/azure/screenshots/pipeline-run-execute-gitversion-task.png
vendored
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
dist/azure/screenshots/pipeline-run-setup-gitversion-task.png
vendored
Normal file
|
After Width: | Height: | Size: 56 KiB |
16
dist/azure/vss-extension.json
vendored
@@ -19,7 +19,8 @@
|
|||||||
{ "path": "gitreleasemanager/close" },
|
{ "path": "gitreleasemanager/close" },
|
||||||
{ "path": "gitreleasemanager/open" },
|
{ "path": "gitreleasemanager/open" },
|
||||||
{ "path": "gitreleasemanager/publish" },
|
{ "path": "gitreleasemanager/publish" },
|
||||||
{ "path": "gitreleasemanager/addasset" }
|
{ "path": "gitreleasemanager/addasset" },
|
||||||
|
{ "path": "images", "addressable": true }
|
||||||
],
|
],
|
||||||
"categories": [
|
"categories": [
|
||||||
"Azure Pipelines"
|
"Azure Pipelines"
|
||||||
@@ -55,11 +56,18 @@
|
|||||||
"uri": "https://github.com/GitTools/actions/issues"
|
"uri": "https://github.com/GitTools/actions/issues"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"screenshots": [{
|
"screenshots": [
|
||||||
"path": "images/builds.png"
|
{
|
||||||
|
"path": "screenshots/pipeline-editor-setup-gitversion-task.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "images/build-task.png"
|
"path": "screenshots/pipeline-run-setup-gitversion-task.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "screenshots/pipeline-editor-execute-gitversion-task.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "screenshots/pipeline-run-execute-gitversion-task.png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"content": {
|
"content": {
|
||||||
|
|||||||
824
dist/github/gitreleasemanager/addasset/bundle.js
vendored
824
dist/github/gitreleasemanager/close/bundle.js
vendored
824
dist/github/gitreleasemanager/create/bundle.js
vendored
824
dist/github/gitreleasemanager/discard/bundle.js
vendored
824
dist/github/gitreleasemanager/open/bundle.js
vendored
824
dist/github/gitreleasemanager/publish/bundle.js
vendored
824
dist/github/gitreleasemanager/setup/bundle.js
vendored
878
dist/github/gitversion/execute/bundle.js
vendored
878
dist/github/gitversion/setup/bundle.js
vendored
579
dist/mock/gitreleasemanager/addasset/bundle.js
vendored
579
dist/mock/gitreleasemanager/close/bundle.js
vendored
579
dist/mock/gitreleasemanager/create/bundle.js
vendored
579
dist/mock/gitreleasemanager/discard/bundle.js
vendored
579
dist/mock/gitreleasemanager/open/bundle.js
vendored
579
dist/mock/gitreleasemanager/publish/bundle.js
vendored
579
dist/mock/gitreleasemanager/setup/bundle.js
vendored
633
dist/mock/gitversion/execute/bundle.js
vendored
633
dist/mock/gitversion/setup/bundle.js
vendored
299
docs/examples/azure/gitversion/execute/usage-examples.md
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
# Execute GitVersion Task (gitversion/execute) Usage Examples
|
||||||
|
|
||||||
|
Find out how to use the **gitversion/execute** task using the examples below.
|
||||||
|
|
||||||
|
> The examples use the latest _0.x_ version of the GitVersion Execute task. It is recommended to use the latest released version in your own pipelines.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
The Execute GitVersion task accepts the following inputs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
targetPath:
|
||||||
|
description: Optionally supply the path to the working directory.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
useConfigFile:
|
||||||
|
description: Whether to use a custom configuration file.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
configFilePath:
|
||||||
|
description: Optional path to config file (defaults to GitVersion.yml).
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
updateAssemblyInfo:
|
||||||
|
description: Whether to update versions in the AssemblyInfo files.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
updateAssemblyInfoFilename:
|
||||||
|
description: Update versions in specified file.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
additionalArguments:
|
||||||
|
description: Additional arguments to send to GitVersion.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
```
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
The Execute GitVersion task creates the following job-scoped variables and multi-job output variables:
|
||||||
|
|
||||||
|
- GitVersion.Major
|
||||||
|
- GitVersion.Minor
|
||||||
|
- GitVersion.Patch
|
||||||
|
- GitVersion.PreReleaseTag
|
||||||
|
- GitVersion.PreReleaseTagWithDash
|
||||||
|
- GitVersion.PreReleaseLabel
|
||||||
|
- GitVersion.PreReleaseNumber
|
||||||
|
- GitVersion.WeightedPreReleaseNumber
|
||||||
|
- GitVersion.BuildMetaData
|
||||||
|
- GitVersion.BuildMetaDataPadded
|
||||||
|
- GitVersion.FullBuildMetaData
|
||||||
|
- GitVersion.MajorMinorPatch
|
||||||
|
- GitVersion.SemVer
|
||||||
|
- GitVersion.LegacySemVer
|
||||||
|
- GitVersion.LegacySemVerPadded
|
||||||
|
- GitVersion.AssemblySemVer
|
||||||
|
- GitVersion.AssemblySemFileVer
|
||||||
|
- GitVersion.FullSemVer
|
||||||
|
- GitVersion.InformationalVersion
|
||||||
|
- GitVersion.BranchName
|
||||||
|
- GitVersion.EscapedBranchName (since 5.2.0)
|
||||||
|
- GitVersion.Sha
|
||||||
|
- GitVersion.ShortSha
|
||||||
|
- GitVersion.NuGetVersionV2
|
||||||
|
- GitVersion.NuGetVersion
|
||||||
|
- GitVersion.NuGetPreReleaseTagV2
|
||||||
|
- GitVersion.NuGetPreReleaseTag
|
||||||
|
- GitVersion.VersionSourceSha
|
||||||
|
- GitVersion.CommitsSinceVersionSource
|
||||||
|
- GitVersion.CommitsSinceVersionSourcePadded (since 5.2.0)
|
||||||
|
- GitVersion.UncommittedChanges (since 5.5.0)
|
||||||
|
- GitVersion.CommitDate
|
||||||
|
|
||||||
|
The job-scoped variables can be accessed using the macro syntax `$(GitVersion.<variableName>)` in subsequent steps in the same job. Azure Pipelines also creates environment variables of the form `GITVERSION_<VARIABLENAME>`. See examples [5](#example-5) and [6](#example-6).
|
||||||
|
|
||||||
|
The multi-job output variables can be accessed across jobs and stages, in both conditions and variables. See examples [7](#example-7) to [10](#example-10).
|
||||||
|
|
||||||
|
**GitVersion also automatically updates the pre-defined Build variable `Build.BuildNumber`.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
|
||||||
|
Calculate the version for the build.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Determine Version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
|
||||||
|
Calculate the version for the build using a config file with the default name **GitVersion.yml**.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Determine Version
|
||||||
|
inputs:
|
||||||
|
useConfigFile: true
|
||||||
|
```
|
||||||
|
|
||||||
|
Example contents of **GitVersion.yml**:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
mode: Mainline
|
||||||
|
branches:
|
||||||
|
master:
|
||||||
|
regex: ^latest$
|
||||||
|
pull-request:
|
||||||
|
tag: pr
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
|
||||||
|
Calculate the version for the build using a config file named **VersionConfig.yml** in the root of the working folder.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Determine Version
|
||||||
|
inputs:
|
||||||
|
useConfigFile: true
|
||||||
|
configFilePath: 'VersionConfig.yml'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 4
|
||||||
|
|
||||||
|
Show the effective configuration for GitVersion by running the **/showConfig** command (passed as an additional argument).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Display GitVersion config
|
||||||
|
inputs:
|
||||||
|
additionalArguments: '/showConfig'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 5
|
||||||
|
|
||||||
|
Calculate the version for the build and display all the calculated variables in the next step.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Determine Version
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
echo Major: $(GitVersion.Major)
|
||||||
|
echo Minor: $(GitVersion.Minor)
|
||||||
|
echo Patch: $(GitVersion.Patch)
|
||||||
|
echo PreReleaseTag: $(GitVersion.PreReleaseTag)
|
||||||
|
echo PreReleaseTagWithDash: $(GitVersion.PreReleaseTagWithDash)
|
||||||
|
echo PreReleaseLabel: $(GitVersion.PreReleaseLabel)
|
||||||
|
echo PreReleaseNumber: $(GitVersion.PreReleaseNumber)
|
||||||
|
echo WeightedPreReleaseNumber: $(GitVersion.WeightedPreReleaseNumber)
|
||||||
|
echo BuildMetaData: $(GitVersion.BuildMetaData)
|
||||||
|
echo BuildMetaDataPadded: $(GitVersion.BuildMetaDataPadded)
|
||||||
|
echo FullBuildMetaData: $(GitVersion.FullBuildMetaData)
|
||||||
|
echo MajorMinorPatch: $(GitVersion.MajorMinorPatch)
|
||||||
|
echo SemVer: $(GitVersion.SemVer)
|
||||||
|
echo LegacySemVer: $(GitVersion.LegacySemVer)
|
||||||
|
echo LegacySemVerPadded: $(GitVersion.LegacySemVerPadded)
|
||||||
|
echo AssemblySemVer: $(GitVersion.AssemblySemVer)
|
||||||
|
echo AssemblySemFileVer: $(GitVersion.AssemblySemFileVer)
|
||||||
|
echo FullSemVer: $(GitVersion.FullSemVer)
|
||||||
|
echo InformationalVersion: $(GitVersion.InformationalVersion)
|
||||||
|
echo BranchName: $(GitVersion.BranchName)
|
||||||
|
echo EscapedBranchName: $(GitVersion.EscapedBranchName)
|
||||||
|
echo Sha: $(GitVersion.Sha)
|
||||||
|
echo ShortSha: $(GitVersion.ShortSha)
|
||||||
|
echo NuGetVersionV2: $(GitVersion.NuGetVersionV2)
|
||||||
|
echo NuGetVersion: $(GitVersion.NuGetVersion)
|
||||||
|
echo NuGetPreReleaseTagV2: $(GitVersion.NuGetPreReleaseTagV2)
|
||||||
|
echo NuGetPreReleaseTag: $(GitVersion.NuGetPreReleaseTag)
|
||||||
|
echo VersionSourceSha: $(GitVersion.VersionSourceSha)
|
||||||
|
echo CommitsSinceVersionSource: $(GitVersion.CommitsSinceVersionSource)
|
||||||
|
echo CommitsSinceVersionSourcePadded: $(GitVersion.CommitsSinceVersionSourcePadded)
|
||||||
|
echo UncommittedChanges: $(GitVersion.UncommittedChanges)
|
||||||
|
echo CommitDate: $(GitVersion.CommitDate)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 6
|
||||||
|
|
||||||
|
Calculate the version for the build and use the `GitVersion.NuGetVersion` variable to set the NuGet package version.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Determine Version
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: Pack Example
|
||||||
|
inputs:
|
||||||
|
command: pack
|
||||||
|
packagesToPack: src/Example/LibExample.csproj
|
||||||
|
versioningScheme: byEnvVar
|
||||||
|
versionEnvVar: GitVersion.NuGetVersion # alternative syntax GITVERSION_NUGETVERSION (the former gets converted into the latter internally)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 7
|
||||||
|
|
||||||
|
Calculate the version for the build and use the `GitVersion.BranchName` variable in a condition for starting another job.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
job: CalculateVersion
|
||||||
|
displayName: Calculate version using GitVersion
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Use GitVersion
|
||||||
|
name: Version # the step MUST be named to access its output variables in another job.
|
||||||
|
|
||||||
|
job: CreateReleaseNotes
|
||||||
|
condition: and(succeeded(), eq(dependencies.CalculateVersion.outputs['Version.GitVersion.BranchName'], 'main')
|
||||||
|
dependsOn: CalculateVersion
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 8
|
||||||
|
|
||||||
|
Calculate the version for the build and map the `GitVersion.SemVer` variable into a variable in another job.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
job: CalculateVersion
|
||||||
|
displayName: Calculate version using GitVersion
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Use GitVersion
|
||||||
|
name: Version # the step MUST be named to access its output variables in another job.
|
||||||
|
|
||||||
|
job: BuildAndPack
|
||||||
|
variables:
|
||||||
|
Ver.MajorMinorPatch: $[ dependencies.CalculateVersion.outputs['Version.GitVersion.MajorMinorPatch'] ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 9
|
||||||
|
|
||||||
|
Calculate the version for the build and use the `GitVersion.Major` output variable in a condition for starting another stage.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
stages:
|
||||||
|
- stage: S1
|
||||||
|
jobs:
|
||||||
|
- job: CalculateVersion
|
||||||
|
displayName: Calculate version number using GitVersion
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Use GitVersion
|
||||||
|
name: Version # the step MUST be named to access its output variables in another stage.
|
||||||
|
|
||||||
|
- stage: S2
|
||||||
|
condition: and(succeeded(), gt(dependencies.S1.outputs['CalculateVersion.Version.GitVersion.Major'], 0))
|
||||||
|
dependsOn: S1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 10
|
||||||
|
|
||||||
|
Calculate the version for the build and map the `GitVersion.AssemblySemVer` variable into a variable in another job for a different stage.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
stages:
|
||||||
|
- stage: S1
|
||||||
|
jobs:
|
||||||
|
- job: CalculateVersion
|
||||||
|
displayName: Calculate version number using GitVersion
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@0 task omitted for brevity.
|
||||||
|
|
||||||
|
- task: gitversion/execute@0
|
||||||
|
displayName: Use GitVersion
|
||||||
|
name: Version # the step MUST be named to access its output variables in another stage.
|
||||||
|
- stage: S2
|
||||||
|
dependsOn: S1
|
||||||
|
jobs:
|
||||||
|
- job: UpdateAssemblyVersions
|
||||||
|
variables:
|
||||||
|
Ver.AssemblyVer: $[ stageDependencies.S1.CalculateVersion.outputs['Version.GitVersion.AssemblySemVer'] ] # Note the 'stageDependencies.<jobName>' syntax.
|
||||||
|
```
|
||||||
@@ -1,43 +1,11 @@
|
|||||||
# Example
|
# GitVersion Tasks Usage Examples
|
||||||
|
|
||||||
```yaml
|
Use the following links to see usage examples of the Setup GitVersion (**gitversion/setup**) and Execute GitVersion (**gitversion/execute**) tasks.
|
||||||
steps:
|
|
||||||
- task: gitversion/setup@0
|
## Setup GitVersion (gitversion/setup)
|
||||||
displayName: Install GitVersion
|
|
||||||
inputs:
|
- [Usage examples](setup/usage-examples.md)
|
||||||
versionSpec: '5.1.3'
|
|
||||||
- task: gitversion/execute@0
|
## Execute GitVersion (gitversion/execute)
|
||||||
displayName: Use GitVersion
|
|
||||||
- script: |
|
- [Usage examples](execute/usage-examples.md)
|
||||||
echo FullSemVer: $(fullSemVer)
|
|
||||||
echo ##vso[build.updatebuildnumber]$(fullSemVer)
|
|
||||||
echo Major: ${{ steps.gitversion.outputs.major }}
|
|
||||||
echo Minor: ${{ steps.gitversion.outputs.minor }}
|
|
||||||
echo Patch: ${{ steps.gitversion.outputs.patch }}
|
|
||||||
echo PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}
|
|
||||||
echo PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}
|
|
||||||
echo PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}
|
|
||||||
echo PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}
|
|
||||||
echo WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}
|
|
||||||
echo BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}
|
|
||||||
echo BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}
|
|
||||||
echo FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}
|
|
||||||
echo MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
|
|
||||||
echo SemVer: ${{ steps.gitversion.outputs.semVer }}
|
|
||||||
echo LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}
|
|
||||||
echo LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}
|
|
||||||
echo AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}
|
|
||||||
echo AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}
|
|
||||||
echo InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}
|
|
||||||
echo BranchName: ${{ steps.gitversion.outputs.branchName }}
|
|
||||||
echo Sha: ${{ steps.gitversion.outputs.sha }}
|
|
||||||
echo ShortSha: ${{ steps.gitversion.outputs.shortSha }}
|
|
||||||
echo NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
|
|
||||||
echo NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}
|
|
||||||
echo NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}
|
|
||||||
echo NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}
|
|
||||||
echo VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}
|
|
||||||
echo CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}
|
|
||||||
echo CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}
|
|
||||||
echo CommitDate: ${{ steps.gitversion.outputs.commitDate }}
|
|
||||||
```
|
|
||||||
|
|||||||
61
docs/examples/azure/gitversion/setup/usage-examples.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Setup GitVersion Task (gitversion/setup) Usage Examples
|
||||||
|
|
||||||
|
Find out how to use the **gitversion/setup** task using the examples below.
|
||||||
|
|
||||||
|
> The examples use the latest _0.x_ version of the GitVersion Setup task. It is recommended to use the latest released version in your own pipelines.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
The Setup GitVersion task accepts the following inputs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
versionSpec:
|
||||||
|
description: Required version in the form of 5.x or exact version like 5.0.0.
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
|
includePrerelease:
|
||||||
|
description: Include pre-release versions when matching a version.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage examples
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
|
||||||
|
Install the latest GitVersion 5 version.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- task: gitversion/setup@0
|
||||||
|
displayName: Install GitVersion
|
||||||
|
inputs:
|
||||||
|
versionSpec: '5.x'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
|
||||||
|
Install GitVersion 5.5.0.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- task: gitversion/setup@0
|
||||||
|
displayName: Install GitVersion
|
||||||
|
inputs:
|
||||||
|
versionSpec: '5.5.0'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
|
||||||
|
Install the latest GitVersion 6 pre-release version. For example **6.0.0-beta1.1**.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- task: gitversion/setup@0
|
||||||
|
displayName: Install GitVersion
|
||||||
|
inputs:
|
||||||
|
versionSpec: '6.x'
|
||||||
|
includePrerelease: true
|
||||||
|
```
|
||||||
283
docs/examples/github/gitversion/execute/usage-examples.md
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
# Execute GitVersion Action (gitversion/execute) Usage Examples
|
||||||
|
|
||||||
|
Find out how to use the **gitversion/execute** action using the examples below.
|
||||||
|
|
||||||
|
For the GitVersion workflow to execute successfully, you must checkout your Git repository with `fetch-depth: 0` to fetch all history for all tags and branches, as follows:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
```
|
||||||
|
|
||||||
|
This step is omitted from the examples for brevity.
|
||||||
|
|
||||||
|
> The examples use version _0.9.7_ of the GitVersion Execute action. It is recommended to use the latest released version in your own workflows.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
The Execute GitVersion action accepts the following inputs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
targetPath:
|
||||||
|
description: Optionally supply the path to the working directory.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
useConfigFile:
|
||||||
|
description: Whether to use a custom configuration file.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
configFilePath:
|
||||||
|
description: Optional path to config file (defaults to GitVersion.yml).
|
||||||
|
required: false
|
||||||
|
default: 'GitVersion.yml'
|
||||||
|
updateAssemblyInfo:
|
||||||
|
description: Whether to update versions in the AssemblyInfo files.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
updateAssemblyInfoFilename:
|
||||||
|
description: Update versions in specified file.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
additionalArguments:
|
||||||
|
description: Additional arguments to send to GitVersion.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
```
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
The Execute GitVersion action creates the following outputs:
|
||||||
|
|
||||||
|
- major
|
||||||
|
- minor
|
||||||
|
- patch
|
||||||
|
- preReleaseTag
|
||||||
|
- preReleaseTagWithDash
|
||||||
|
- preReleaseLabel
|
||||||
|
- preReleaseNumber
|
||||||
|
- weightedPreReleaseNumber
|
||||||
|
- buildMetaData
|
||||||
|
- buildMetaDataPadded
|
||||||
|
- fullBuildMetaData
|
||||||
|
- majorMinorPatch
|
||||||
|
- semVer
|
||||||
|
- legacySemVer
|
||||||
|
- legacySemVerPadded
|
||||||
|
- assemblySemVer
|
||||||
|
- assemblySemFileVer
|
||||||
|
- fullSemVer
|
||||||
|
- informationalVersion
|
||||||
|
- branchName
|
||||||
|
- escapedBranchName (since 5.2.0)
|
||||||
|
- sha
|
||||||
|
- shortSha
|
||||||
|
- nuGetVersionV2
|
||||||
|
- nuGetVersion
|
||||||
|
- nuGetPreReleaseTagV2
|
||||||
|
- nuGetPreReleaseTag
|
||||||
|
- versionSourceSha
|
||||||
|
- commitsSinceVersionSource
|
||||||
|
- commitsSinceVersionSourcePadded (since 5.2.0)
|
||||||
|
- uncommittedChanges (since 5.5.0)
|
||||||
|
- commitDate
|
||||||
|
|
||||||
|
The outputs can be accessed using the syntax `${{ steps.<id>.outputs.<outputName> }}`, where `<id>` is the ID assigned to the step that calls the action, by subsequent steps later in the same job. See example [5](#example-5).
|
||||||
|
|
||||||
|
The action also creates environment variables of the form `GITVERSION_<OUTPUTNAME>` for use by other steps in the same job. See example [6](#example-6).
|
||||||
|
|
||||||
|
The outputs can be accessed across jobs by mapping them to job outputs and referencing the job outputs using the `needs` context in dependent jobs. See examples [7](#example-7) and [8](#example-8).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
|
||||||
|
Calculate the version for the build.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@v0.9.7 action omitted for brevity.
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
|
||||||
|
Calculate the version for the build using a config file with the default name **GitVersion.yml**.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Determine Version
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
with:
|
||||||
|
useConfigFile: true
|
||||||
|
```
|
||||||
|
|
||||||
|
Example contents of **GitVersion.yml**:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
mode: Mainline
|
||||||
|
branches:
|
||||||
|
master:
|
||||||
|
regex: ^latest$
|
||||||
|
pull-request:
|
||||||
|
tag: pr
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
|
||||||
|
Calculate the version for the build using a config file named **VersionConfig.yml** in the root of the working folder.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@v0.9.7 action omitted for brevity.
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
with:
|
||||||
|
useConfigFile: true
|
||||||
|
configFilePath: VersionConfig.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 4
|
||||||
|
|
||||||
|
Show the effective configuration for GitVersion by running the **/showConfig** command (passed as an additional argument).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@v0.9.7 action omitted for brevity.
|
||||||
|
|
||||||
|
- name: Display GitVersion config
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
with:
|
||||||
|
useConfigFile: true
|
||||||
|
additionalArguments: '/showConfig'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 5
|
||||||
|
|
||||||
|
Calculate the version for the build and display all the calculated variables in the next step.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@v0.9.7 action omitted for brevity.
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
id: gitversion
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
|
||||||
|
- name: Display GitVersion outputs
|
||||||
|
run: |
|
||||||
|
echo "Major: ${{ steps.gitversion.outputs.major }}"
|
||||||
|
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
|
||||||
|
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
|
||||||
|
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
|
||||||
|
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
|
||||||
|
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
|
||||||
|
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
|
||||||
|
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
|
||||||
|
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
|
||||||
|
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
|
||||||
|
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
|
||||||
|
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
|
||||||
|
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
|
||||||
|
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
|
||||||
|
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
|
||||||
|
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
|
||||||
|
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
|
||||||
|
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
|
||||||
|
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
|
||||||
|
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
|
||||||
|
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
|
||||||
|
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
|
||||||
|
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
|
||||||
|
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
|
||||||
|
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
|
||||||
|
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
|
||||||
|
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
|
||||||
|
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
|
||||||
|
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
|
||||||
|
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
|
||||||
|
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
|
||||||
|
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 6
|
||||||
|
|
||||||
|
Calculate the version for the build and display the value of the `GITVERSION_SEMVER` environment variable.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# gitversion/setup@v0.9.7 action omitted for brevity.
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
|
||||||
|
- name: Display SemVer
|
||||||
|
run: |
|
||||||
|
echo "SemVer: $GITVERSION_SEMVER"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 7
|
||||||
|
|
||||||
|
Calculate the version for the build and use the `branchName` output in a condition for starting another job.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
calculate-version:
|
||||||
|
name: Calculate Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
branchName: ${{ steps.gitversion.outputs.branchName }} # To use an output in another job, you have to map it to a job output.
|
||||||
|
steps:
|
||||||
|
# gitversion/execute step omitted for brevity
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
id: gitversion
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
|
||||||
|
create-release-notes:
|
||||||
|
name: Create Release Notes
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: calculate-version
|
||||||
|
if: contains(needs.calculate-version.outputs.branchName, 'main') # Output variable accessed via `needs` context.
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
# Output variables can also be accessed in steps, using an expression.
|
||||||
|
echo "Creating release notes for ${{ needs.calculate-version.outputs.branchName }} branch."
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 8
|
||||||
|
|
||||||
|
Calculate the version for the build and map the `semVer` output into an environment variable in another job.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
calculate-version:
|
||||||
|
name: Calculate Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
semVer: ${{ steps.gitversion.outputs.semVer }}
|
||||||
|
steps:
|
||||||
|
# gitversion/execute step omitted for brevity
|
||||||
|
|
||||||
|
- name: Determine Version
|
||||||
|
id: gitversion
|
||||||
|
uses: gittools/actions/gitversion/execute@v0.9.7
|
||||||
|
|
||||||
|
display-semver:
|
||||||
|
name: Display Semantic Version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: calculate-version
|
||||||
|
env:
|
||||||
|
SEMVER: ${{ needs.calculate-version.outputs.semVer }}
|
||||||
|
steps:
|
||||||
|
- name: Display version
|
||||||
|
run: |
|
||||||
|
echo SemVer: $SEMVER
|
||||||
|
```
|
||||||
@@ -1,50 +1,11 @@
|
|||||||
# GitVersion
|
# GitVersion Actions Usage Examples
|
||||||
|
|
||||||
For the GitVersion workflow to execute successfully, you must checkout your Git
|
Use the following links to see usage examples of the Setup GitVersion (**gitversion/setup**) and Execute GitVersion (**gitversion/execute**) actions.
|
||||||
repository with `fetch-depth: 0` to fetch all history for all tags and branches.
|
|
||||||
|
|
||||||
```yaml
|
## Setup GitVersion (gitversion/setup)
|
||||||
steps:
|
|
||||||
- name: Checkout
|
- [Usage examples](setup/usage-examples.md)
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
## Execute GitVersion (gitversion/execute)
|
||||||
fetch-depth: 0
|
|
||||||
- name: Install GitVersion
|
- [Usage examples](execute/usage-examples.md)
|
||||||
uses: gittools/actions/gitversion/setup@v0.9.4
|
|
||||||
with:
|
|
||||||
versionSpec: '5.3.x'
|
|
||||||
- name: Use GitVersion
|
|
||||||
id: gitversion # step id used as reference for output values
|
|
||||||
uses: gittools/actions/gitversion/execute@v0.9.4
|
|
||||||
- run: |
|
|
||||||
echo "Major: ${{ steps.gitversion.outputs.major }}"
|
|
||||||
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
|
|
||||||
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
|
|
||||||
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
|
|
||||||
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
|
|
||||||
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
|
|
||||||
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
|
|
||||||
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
|
|
||||||
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
|
|
||||||
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
|
|
||||||
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
|
|
||||||
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
|
|
||||||
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
|
|
||||||
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
|
|
||||||
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
|
|
||||||
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
|
|
||||||
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
|
|
||||||
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
|
|
||||||
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
|
|
||||||
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
|
|
||||||
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
|
|
||||||
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
|
|
||||||
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
|
|
||||||
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
|
|
||||||
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
|
|
||||||
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
|
|
||||||
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
|
|
||||||
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
|
|
||||||
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
|
|
||||||
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
|
|
||||||
```
|
|
||||||
|
|||||||
61
docs/examples/github/gitversion/setup/usage-examples.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Setup GitVersion Action (gitversion/setup) Usage Examples
|
||||||
|
|
||||||
|
Find out how to use the **gitversion/setup** action using the examples below.
|
||||||
|
|
||||||
|
> The examples use version _0.9.7_ of the GitVersion Execute action. It is recommended to use the latest released version in your own workflows.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
The Setup GitVersion action accepts the following inputs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
versionSpec:
|
||||||
|
description: Required version in the form of 5.x or exact version like 5.0.0.
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
|
includePrerelease:
|
||||||
|
description: Include pre-release versions when matching a version.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage examples
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
|
||||||
|
Install the latest GitVersion 5 version.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Install GitVersion
|
||||||
|
uses: gittools/actions/gitversion/setup@v0.9.7
|
||||||
|
with:
|
||||||
|
versionSpec: '5.x'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
|
||||||
|
Install GitVersion 5.5.0.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Install GitVersion
|
||||||
|
uses: gittools/actions/gitversion/setup@v0.9.7
|
||||||
|
with:
|
||||||
|
versionSpec: '5.5.0'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
|
||||||
|
Install the latest GitVersion 6 pre-release version. For example **6.0.0-beta1.1**.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Install GitVersion
|
||||||
|
uses: gittools/actions/gitversion/setup@v0.9.7
|
||||||
|
with:
|
||||||
|
versionSpec: '6.x'
|
||||||
|
includePrerelease: true
|
||||||
|
```
|
||||||
BIN
docs/icon.png
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -19,7 +19,7 @@ inputs:
|
|||||||
configFilePath:
|
configFilePath:
|
||||||
description: Optional path to config file (defaults to GitVersion.yml)
|
description: Optional path to config file (defaults to GitVersion.yml)
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: 'GitVersion.yml'
|
||||||
updateAssemblyInfo:
|
updateAssemblyInfo:
|
||||||
description: Whether to update versions in the AssemblyInfo files
|
description: Whether to update versions in the AssemblyInfo files
|
||||||
required: false
|
required: false
|
||||||
@@ -73,6 +73,8 @@ outputs:
|
|||||||
description: 'The InformationalVersion value'
|
description: 'The InformationalVersion value'
|
||||||
branchName:
|
branchName:
|
||||||
description: 'The BranchName value'
|
description: 'The BranchName value'
|
||||||
|
escapedBranchName:
|
||||||
|
description: 'The EscapedBranchName value'
|
||||||
sha:
|
sha:
|
||||||
description: 'The Sha value'
|
description: 'The Sha value'
|
||||||
shortSha:
|
shortSha:
|
||||||
@@ -91,5 +93,7 @@ outputs:
|
|||||||
description: 'The CommitsSinceVersionSource value'
|
description: 'The CommitsSinceVersionSource value'
|
||||||
commitsSinceVersionSourcePadded:
|
commitsSinceVersionSourcePadded:
|
||||||
description: 'The CommitsSinceVersionSourcePadded value'
|
description: 'The CommitsSinceVersionSourcePadded value'
|
||||||
|
uncommittedChanges:
|
||||||
|
description: 'The UncommittedChanges value'
|
||||||
commitDate:
|
commitDate:
|
||||||
description: 'The CommitDate value'
|
description: 'The CommitDate value'
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: gitversion-setup
|
name: gitversion-setup
|
||||||
description: GitHub Action for Easy Semantic Versioning with GitVersion. Installs the specific version of GitVersion.Tool
|
description: GitHub Action for Easy Semantic Versioning with GitVersion. Installs the specific version of GitVersion tool
|
||||||
author: GitTools
|
author: GitTools
|
||||||
branding:
|
branding:
|
||||||
color: gray-dark
|
color: gray-dark
|
||||||
|
|||||||
1014
package-lock.json
generated
24
package.json
@@ -29,27 +29,27 @@
|
|||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^1.6.0",
|
"@actions/tool-cache": "^1.6.1",
|
||||||
"azure-pipelines-task-lib": "^2.11.3",
|
"azure-pipelines-task-lib": "^2.12.0",
|
||||||
"azure-pipelines-tool-lib": "^0.13.2",
|
"azure-pipelines-tool-lib": "^0.13.2",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.5",
|
||||||
"typed-rest-client": "^1.7.3",
|
"typed-rest-client": "^1.8.0",
|
||||||
"uuid": "^8.3.1"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^14.14.6",
|
"@types/node": "^14.14.20",
|
||||||
"@types/q": "^1.5.4",
|
"@types/q": "^1.5.4",
|
||||||
"@types/semver-compare": "^1.0.1",
|
"@types/semver-compare": "^1.0.1",
|
||||||
"@types/uuid": "^8.3.0",
|
"@types/uuid": "^8.3.0",
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.2.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"replace-in-file-webpack-plugin": "^1.0.6",
|
"replace-in-file-webpack-plugin": "^1.0.6",
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
"terser-webpack-plugin": "^5.0.3",
|
||||||
"tfx-cli": "^0.8.3",
|
"tfx-cli": "^0.8.3",
|
||||||
"ts-loader": "^8.0.9",
|
"ts-loader": "^8.0.13",
|
||||||
"typescript": "^4.0.5",
|
"typescript": "^4.1.3",
|
||||||
"webpack": "^5.4.0",
|
"webpack": "^5.11.1",
|
||||||
"webpack-cli": "^4.2.0"
|
"webpack-cli": "^4.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ export class DotnetTool implements IDotnetTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public disableTelemetry(): void {
|
public disableTelemetry(): void {
|
||||||
this.buildAgent.exportVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1')
|
this.buildAgent.exportVariable('DOTNET_CLI_TELEMETRY_OPTOUT', 'true')
|
||||||
|
this.buildAgent.exportVariable('DOTNET_NOLOGO', 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ export interface IGitReleaseManagerTool extends IDotnetTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class GitReleaseManagerTool extends DotnetTool
|
export class GitReleaseManagerTool
|
||||||
|
extends DotnetTool
|
||||||
implements IGitReleaseManagerTool {
|
implements IGitReleaseManagerTool {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export interface GitVersionOutput {
|
|||||||
FullSemVer: string
|
FullSemVer: string
|
||||||
InformationalVersion: string
|
InformationalVersion: string
|
||||||
BranchName: string
|
BranchName: string
|
||||||
|
EscapedBranchName: string
|
||||||
Sha: string
|
Sha: string
|
||||||
ShortSha: string
|
ShortSha: string
|
||||||
NuGetVersionV2: string
|
NuGetVersionV2: string
|
||||||
@@ -48,5 +49,6 @@ export interface GitVersionOutput {
|
|||||||
VersionSourceSha: string
|
VersionSourceSha: string
|
||||||
CommitsSinceVersionSource: number
|
CommitsSinceVersionSource: number
|
||||||
CommitsSinceVersionSourcePadded: string
|
CommitsSinceVersionSourcePadded: string
|
||||||
|
UncommittedChanges: number
|
||||||
CommitDate: string
|
CommitDate: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
workDir = srcDir
|
workDir = srcDir
|
||||||
} else {
|
} else {
|
||||||
if (this.buildAgent.directoryExists(targetPath)) {
|
if (this.buildAgent.directoryExists(targetPath)) {
|
||||||
workDir = path.join(srcDir, targetPath)
|
workDir = targetPath
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Directory not found at ' + targetPath)
|
throw new Error('Directory not found at ' + targetPath)
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
workDir: string,
|
workDir: string,
|
||||||
options: GitVersionSettings
|
options: GitVersionSettings
|
||||||
): string[] {
|
): string[] {
|
||||||
const args = [workDir, '/output', 'json', '/output', 'buildserver']
|
let args = [workDir, '/output', 'json', '/output', 'buildserver']
|
||||||
|
|
||||||
const {
|
const {
|
||||||
useConfigFile,
|
useConfigFile,
|
||||||
@@ -103,8 +103,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalArguments) {
|
if (additionalArguments) {
|
||||||
//args.push(additionalArguments)
|
args = args.concat(this.argStringToArray(additionalArguments))
|
||||||
Array.prototype.push.apply(args,additionalArguments.split(' '))
|
|
||||||
}
|
}
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
@@ -120,13 +119,75 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private argStringToArray(argString: string): string[] {
|
||||||
|
var args: string[] = []
|
||||||
|
|
||||||
|
var inQuotes = false
|
||||||
|
var escaped = false
|
||||||
|
var lastCharWasSpace = true
|
||||||
|
var arg = ''
|
||||||
|
|
||||||
|
var append = function (c: string) {
|
||||||
|
// we only escape double quotes.
|
||||||
|
if (escaped && c !== '"') {
|
||||||
|
arg += '\\'
|
||||||
|
}
|
||||||
|
|
||||||
|
arg += c
|
||||||
|
escaped = false
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < argString.length; i++) {
|
||||||
|
var c = argString.charAt(i)
|
||||||
|
|
||||||
|
if (c === ' ' && !inQuotes) {
|
||||||
|
if (!lastCharWasSpace) {
|
||||||
|
args.push(arg)
|
||||||
|
arg = ''
|
||||||
|
}
|
||||||
|
lastCharWasSpace = true
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
lastCharWasSpace = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === '"') {
|
||||||
|
if (!escaped) {
|
||||||
|
inQuotes = !inQuotes
|
||||||
|
} else {
|
||||||
|
append(c)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === '\\' && escaped) {
|
||||||
|
append(c)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === '\\' && inQuotes) {
|
||||||
|
escaped = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
append(c)
|
||||||
|
lastCharWasSpace = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lastCharWasSpace) {
|
||||||
|
args.push(arg.trim())
|
||||||
|
}
|
||||||
|
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
|
||||||
private toCamelCase(input: string): string {
|
private toCamelCase(input: string): string {
|
||||||
return input.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (
|
return input.replace(
|
||||||
match,
|
/(?:^\w|[A-Z]|\b\w|\s+)/g,
|
||||||
index
|
function (match, index) {
|
||||||
) {
|
if (+match === 0) return '' // or if (/\s+/.test(match)) for white spaces
|
||||||
if (+match === 0) return '' // or if (/\s+/.test(match)) for white spaces
|
return index == 0 ? match.toLowerCase() : match.toUpperCase()
|
||||||
return index == 0 ? match.toLowerCase() : match.toUpperCase()
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||