Skip to content

Commit 393d600

Browse files
author
Bart Koelman
committed
cleanup revision
1 parent fdf84bd commit 393d600

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

Build.ps1

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,39 +65,28 @@ function ReportCodeCoverage {
6565
CheckLastExitCode
6666
}
6767

68-
# Gets the version suffix from the repo tag
69-
# example: v1.0.0-preview1-final => preview1-final
70-
function GetVersionSuffixFromTag {
71-
$tag = $env:APPVEYOR_REPO_TAG_NAME
72-
$split = $tag -split "-"
73-
$suffix = $split[1..2]
74-
$final = $suffix -join "-"
75-
return $final
76-
}
77-
7868
function CreateNuGetPackage {
7969
if ($env:APPVEYOR_REPO_TAG -eq $true) {
80-
$revision = GetVersionSuffixFromTag
81-
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
82-
Write-Output "VERSION-SUFFIX: $revision"
83-
84-
if ([string]::IsNullOrWhitespace($revision)) {
85-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
86-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
87-
}
88-
else {
89-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
90-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
91-
}
70+
# Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final
71+
$tag = $env:APPVEYOR_REPO_TAG_NAME
72+
$segments = $tag -split "-"
73+
$suffixSegments = $segments[1..2]
74+
$versionSuffix = $suffixSegments -join "-"
9275
}
9376
else {
77+
# Get the version suffix from the build number, defaulting to 1 for non-cibuilds.
9478
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
9579
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
80+
$versionSuffix="pre-$revision"
81+
}
9682

97-
$packageVersionSuffix="pre-$revision"
98-
Write-Output "VERSION-SUFFIX: $packageVersionSuffix"
99-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix"
100-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix
83+
if ([string]::IsNullOrWhitespace($versionSuffix)) {
84+
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
85+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
86+
}
87+
else {
88+
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$versionSuffix"
89+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$versionSuffix
10190
}
10291

10392
CheckLastExitCode

0 commit comments

Comments
 (0)