add logic to add pr postfix for pr triggered builds

This commit is contained in:
Andrew Welker
2020-06-29 14:47:54 -06:00
parent 83ca3ee350
commit a26c951dba

View File

@@ -20,11 +20,13 @@ Foreach ($version in $latestVersions) {
$newVersion = [version]$latestVersion $newVersion = [version]$latestVersion
$phase = "" $phase = ""
$newVersionString = "" $newVersionString = ""
if([string]::IsNullOrEmpty($Env:GITHUB_REF)) {
$phase = 'fork' switch -regex ($Env:GITHUB_REF) {
'^refs\/pull\/*.' {
$splitRef = $Env:GITHUB_REF -split "/"
$phase = "pr$($splitRef[2])"
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER $newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
} else { }
switch -regex ($Env:GITHUB_REF) {
'^refs\/heads\/main*.' { '^refs\/heads\/main*.' {
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build $newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build
} }
@@ -50,7 +52,7 @@ if([string]::IsNullOrEmpty($Env:GITHUB_REF)) {
$phase = 'hotfix' $phase = 'hotfix'
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER $newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
} }
}
} }