-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPack.psm1
31 lines (26 loc) · 1.29 KB
/
Pack.psm1
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
30
31
function Push-Package
{
Param(
[parameter(Mandatory=$true, Position=0)]
[string]
$NuSpecFile,
[parameter(Mandatory=$true, Position=1)]
[string]
$TargetRepository
)
$nugetVersion = gitversion /showvariable NuGetVersion
$commitsSinceVersionSourcePadded = gitversion /showvariable CommitsSinceVersionSourcePadded
$branchName = gitversion /showvariable BranchName
$versionToApply = $nuGetVersion
if ($branchName -ne "master" -and $branchName -ne "develop" -and $commitsSinceVersionSource -ne 0)
{
$majorMinorPatch = gitversion /showvariable MajorMinorPatch
$nuGetPreReleaseTag = gitversion /showvariable NuGetPreReleaseTag
$subNugetVersion = $nuGetPreReleaseTag.Substring(0, $nuGetPreReleaseTag.Length - 4)
$subNugetVersion = $subNugetVersion.Replace("-", "")
$versionToApply = "$majorMinorPatch-$subNugetVersion$commitsSinceVersionSourcePadded"
}
nuget pack $NuSpecFile -Version $versionToApply
$baseFileName = [System.IO.Path]::GetFileNameWithoutExtension($NuSpecFile)
Start-Process -Wait -NoNewWindow -FilePath "nuget.exe" -ArgumentList push, "$baseFileName.$versionToApply.nupkg", -source, "$TargetRepository"
}