1
1
Param (
2
+ [string ]$ref = " master" ,
2
3
[switch ]$verbose = $False
3
4
)
4
5
@@ -50,8 +51,13 @@ function Extract-BuildIdentifier($statuses, $forContext) {
50
51
}
51
52
52
53
function Download-AppVeyor-Artifacts ($statuses , $downloadLocation ) {
54
+ $prOrBranch = " branch"
53
55
54
- $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/appveyor/branch"
56
+ if ($ref.StartsWith (" pull/" )) {
57
+ $prOrBranch = " pr"
58
+ }
59
+
60
+ $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/appveyor/$prOrBranch "
55
61
56
62
Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor build `" $buildIdentifier `" "
57
63
$build = Invoke-RestMethod - Ex " https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier "
@@ -71,8 +77,13 @@ function Download-AppVeyor-Artifacts($statuses, $downloadLocation) {
71
77
}
72
78
73
79
function Download-Travis-Artifacts ($statuses , $downloadLocation ) {
80
+ $prOrBranch = " push"
81
+
82
+ if ($ref.StartsWith (" pull/" )) {
83
+ $prOrBranch = " pr"
84
+ }
74
85
75
- $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/push "
86
+ $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/$prOrBranch "
76
87
77
88
Write-Host - ForegroundColor " Yellow" " Retrieving Travis build `" $buildIdentifier `" "
78
89
$build = Invoke-RestMethod - Ex " https://api.travis-ci.org/builds/$buildIdentifier "
@@ -96,9 +107,18 @@ $path = [System.IO.Path]::Combine($env:Temp, [System.IO.Path]::GetRandomFileName
96
107
Write-Host - ForegroundColor " Yellow" " Creating temporary folder at `" $path `" "
97
108
New-Item " $path " - type Directory > $null
98
109
99
- $ref = " master"
110
+ if ($ref.StartsWith (" pull/" )) {
111
+ $pr = $ref.Replace (" pull/" , " " )
112
+ Write-Host - ForegroundColor " Yellow" " Retrieving pull request information for pull request $pr "
113
+
114
+ $prData = Invoke-RestMethod - Ex " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/pulls/$pr "
115
+ $statusesUrl = $prData.statuses_url
116
+ } else {
117
+ $statusesUrl = " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref /statuses"
118
+ }
119
+
100
120
Write-Host - ForegroundColor " Yellow" " Retrieving LibGit2Sharp.NativeBinaries latest CI statuses of `" $ref `" "
101
- $statuses = Invoke-RestMethod - Ex " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/ $ref /statuses "
121
+ $statuses = Invoke-RestMethod - Ex $statusesUrl
102
122
103
123
Download- AppVeyor- Artifacts $statuses $path
104
124
Download- Travis- Artifacts $statuses $path
@@ -116,10 +136,10 @@ Add-Type -assembly "System.Io.Compression.Filesystem"
116
136
[Io.Compression.ZipFile ]::ExtractToDirectory(" $ ( $osxBins.FullName ) " , " $ ( $osxBins.FullName ) .ext" )
117
137
118
138
Write-Host - ForegroundColor " Yellow" " Including non Windows build artifacts"
119
- Move-Item " $ ( $linuxBins.FullName ) .ext\runtimes \linux-x64\*.so" " $ ( $package.FullName ) .ext\runtimes\linux-x64"
120
- Remove-Item " $ ( $package.FullName ) .ext\runtimes\linux-x64\addbinaries.here"
121
- Move-Item " $ ( $osxBins.FullName ) .ext\runtimes \osx\*.dylib" " $ ( $package.FullName ) .ext\runtimes\osx"
122
- Remove-Item " $ ( $package.FullName ) .ext\runtimes\osx\addbinaries.here"
139
+ Move-Item " $ ( $linuxBins.FullName ) .ext\libgit2 \linux-x64\native\ *.so" " $ ( $package.FullName ) .ext\runtimes\linux-x64\native "
140
+ Remove-Item " $ ( $package.FullName ) .ext\runtimes\linux-x64\native\ addbinaries.here"
141
+ Move-Item " $ ( $osxBins.FullName ) .ext\libgit2 \osx\native\ *.dylib" " $ ( $package.FullName ) .ext\runtimes\osx\native "
142
+ Remove-Item " $ ( $package.FullName ) .ext\runtimes\osx\native\ addbinaries.here"
123
143
124
144
Write-Host - ForegroundColor " Yellow" " Building final NuGet package"
125
145
Push-location " $ ( $package.FullName ) .ext"
0 commit comments