forked from Kentico/KInspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappveyor-set_version.ps1
29 lines (24 loc) · 1.2 KB
/
appveyor-set_version.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Write-Output "Checking Tag Version"
$env:SEMVER_VERSION = $env:APPVEYOR_BUILD_VERSION
$env:DOTNET_VERSION = $env:APPVEYOR_BUILD_VERSION
$tagName = & git describe --abbrev=0 --tags
if ($env:APPVEYOR_REPO_TAG -eq $true) {
$tagName = $env:APPVEYOR_REPO_TAG_NAME
}
Write-Output "Checking tag for SemVer naming"
$regex = new-object System.Text.RegularExpressions.Regex ('v(?<versionwithprerelease>(?<version>(?<major>[0-9]+).(?<minor>[0-9]+).(?<patch>[0-9]+))(-(?<prerelease>.+))?)', [System.Text.RegularExpressions.RegexOptions]::MultiLine)
$match = $regex.Match($tagName)
if($match.Success) {
Write-Output "SemVer naming found: $tagName"
$version = $match.Groups["version"].Value
$versionwithprerelease = $match.Groups["versionwithprerelease"].Value
$env:DOTNET_VERSION = "$version.$env:APPVEYOR_BUILD_NUMBER"
if ($env:APPVEYOR_REPO_TAG -eq $true) {
$env:SEMVER_VERSION = $versionwithprerelease
} else {
$env:SEMVER_VERSION = "$versionwithprerelease+dev.build.$env:APPVEYOR_BUILD_VERSION"
}
Write-Output "Changing version '$env:APPVEYOR_BUILD_VERSION' to '$env:SEMVER_VERSION' based on tag"
Update-AppveyorBuild -Version "$env:SEMVER_VERSION"
Write-Output "DotNet version is: '$env:DOTNET_VERSION'"
}