Created
April 15, 2016 18:05
-
-
Save george-polevoy/459530bbb4e6e8bd84fb273e6a4e07ae to your computer and use it in GitHub Desktop.
Few Lines of Code - Appveyor init powershell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference='Stop'; | |
$branch = $env:APPVEYOR_REPO_BRANCH; | |
$buildNumber = $env:APPVEYOR_BUILD_NUMBER; | |
$num = '(0|[1-9]{1}[0-9]{0,})'; | |
$rx = "^[a-z\-]+/v(?'ver'$num\.$num\.$num)(-(?'preSpec'[a-zA-Z]{1,}[0-9]{0,})){0,1}$"; | |
$match = [regex]::match($branch, $rx); | |
if (!$match.Success) | |
{ | |
throw "Branch name is not correct semver (1.0.0): " + $branch; | |
} | |
$version = $match.Groups['ver'].Value; | |
$preReleaseSpec = $match.Groups['preSpec'].Value; | |
$assemblyVersion = $version + ".0"; | |
$fileVersion = $version + "." + $buildNumber; | |
$informationalVersion = $version; | |
if ("" -eq $preReleaseSpec) | |
{ | |
$informationalVersion = $version + "." + $buildNumber; | |
} | |
else | |
{ | |
$informationalVersion = $version + "-" + $preReleaseSpec + "-" + $buildNumber.PadLeft(6,'0'); | |
} | |
$env:release_AssemblyVersion = $assemblyVersion; | |
$env:release_FileVersion = $fileVersion; | |
$env:release_InformationalVersion = $informationalVersion; | |
Write-Output "Versioning for a nuget release" | |
Write-Output "env:release_AssemblyVersion = $assemblyVersion" | |
Write-Output "env:release_FileVersion = $fileVersion" | |
Write-Output "env:release_InformationalVersion = $informationalVersion" | |
$displayVersion = "debug 01 " + $informationalVersion | |
Update-AppveyorBuild -Version $displayVersion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment