forked from IronFoundry/if-service-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
85 lines (68 loc) · 1.95 KB
/
build.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
param(
$NuGetPackageUrl = '',
$NuGetApiKey = '',
$ReleaseVersion = '0.0.0'
)
#
# TeamCity variables that may be set
#
$BuildVersion = $ReleaseVersion
if ($env:BUILD_NUMBER -ne $null) {
$BuildVersion = $env:BUILD_NUMBER
}
$BuildBranch = 'DevLocal'
if ($env:BUILD_BRANCH -ne $null) {
$BuildBranch = $env:BUILD_BRANCH
if ($BuildBranch -eq '<default>') {
$BuildBranch = 'master'
}
}
$BuildIsPrivate = ($BuildBranch -ne 'master')
if ($NuGetPackageUrl -eq '' -and $env:NUGET_PACKAGE_URL -ne $null) {
$NuGetPackageUrl = $env:NUGET_PACKAGE_URL
}
if ($NuGetApikey -eq '' -and $env:NUGET_API_KEY -ne $null) {
$NuGetApiKey = $env:NUGET_API_KEY
}
if ($BuildIsPrivate -eq $true) {
$NuGetVersion = "$BuildVersion-$BuildBranch"
}
else {
$NuGetVersion = $BuildVersion
}
#
# Base directories
#
$IFSourceDirectory = Convert-Path $PWD
$BuildRootDir = "$IFSourceDirectory\Build"
$ToolsDir = "$IFSourceDirectory\tools"
# Nuget properties
$NuGetExe = "$BuildRootDir\nuget.exe"
$NuGetNuSpec = "$BuildRootDir\Default.Deploy.nuspec"
$ReleaseDir = "$IFSourceDirectory\release"
$BrokerOut = "$IFSourceDirectory\output\$BuildVersion\binaries\IronFoundry.ServiceBroker"
function CopyTools()
{
mkdir "$BrokerOut\tools\" -force | Out-Null
copy "$ToolsDir\*.*" "$BrokerOut\tools\"
}
function CreateNuSpecs()
{
Write-Host "Creating nuspec packages"
mkdir $ReleaseDir -force | Out-Null
& $NuGetExe pack "$NuGetNuSpec" -Version $NuGetVersion -Prop "Id=ironfoundry.brokerservice" -BasePath "$BrokerOut" -NoPackageAnalysis -NoDefaultExcludes -OutputDirectory "$ReleaseDir"
}
function NuGetPush
{
Write-Host "Pushing to nuget url: $NuGetPackageUrl"
Get-ChildItem "$ReleaseDir\*.$NuGetVersion.nupkg" | ForEach-Object {
. $NuGetExe push -Source $NuGetPackageUrl -ApiKey "$NuGetApiKey" "$($_.FullName)"
}
}
if ($NuGetPackageUrl -ne '')
{
CopyTools
CreateNuSpecs
NuGetPush
}
Set-Location $IFSourceDirectory