-
Notifications
You must be signed in to change notification settings - Fork 26
/
package.ps1
68 lines (56 loc) · 1.48 KB
/
package.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Param(
[Parameter(Mandatory = $true)]
[string] $Tag,
[bool] $UseBranch,
[string] $ApiKey
)
$ErrorActionPreference = "Stop";
if ($Tag -match '(?<=^v)\d+\.\d+\.\d+(?:.+)?$') {
$version = $Matches[0]
}
else {
throw "Incorrect tag format"
}
if ($version -match '^\d+\.\d+\.\d+') {
$versionNumber = $Matches[0]
}
else {
throw "Incorrect tag format"
}
if (-not $UseBranch) {
$branch = git symbolic-ref --short HEAD
git fetch -a
git checkout $Tag
if ($LastExitCode -ne 0) {
throw "Could not checkout tag"
}
}
$BinDir = './ADMPlugin/bin'
if(Test-Path -Path $BinDir ){
Remove-Item -Path ./ADMPlugin/bin -Recurse -Force
}
$ObjDir = './ADMPlugin/obj'
if(Test-Path -Path $ObjDir){
Remove-Item -Path ./ADMPlugin/obj -Recurse -Force
}
nuget restore
if ($LastExitCode -ne 0) {
throw "NuGet packages could not be restored"
}
msbuild ./ADMPlugin/ADMPlugin.csproj /m /p:Configuration=Release /p:Version=$version /p:FileVersion=$versionNumber.0 /t:rebuild /v:minimal
if ($LastExitCode -ne 0) {
throw "Project could no be built"
}
nuget pack ./AgGatewayADMPlugin.nuspec -verbosity detailed -outputdirectory ./dist -version $version
if ($LastExitCode -ne 0) {
throw "Package could no be built"
}
if (-not ([string]::IsNullOrEmpty($ApiKey))) {
nuget push ./dist/AgGatewayADMPlugin.$version.nupkg -apikey $ApiKey -source https://api.nuget.org/v3/index.json
if ($LastExitCode -ne 0) {
throw "Package could no be published"
}
}
if (-not $UseBranch) {
git checkout $branch
}