11Param (
2+ [string ]$ref = " master" ,
23 [switch ]$verbose = $False
34)
45
@@ -50,8 +51,13 @@ function Extract-BuildIdentifier($statuses, $forContext) {
5051}
5152
5253function Download-AppVeyor-Artifacts ($statuses , $downloadLocation ) {
54+ $prOrBranch = " branch"
5355
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 "
5561
5662 Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor build `" $buildIdentifier `" "
5763 $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) {
7177}
7278
7379function Download-Travis-Artifacts ($statuses , $downloadLocation ) {
80+ $prOrBranch = " push"
81+
82+ if ($ref.StartsWith (" pull/" )) {
83+ $prOrBranch = " pr"
84+ }
7485
75- $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/push "
86+ $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/$prOrBranch "
7687
7788 Write-Host - ForegroundColor " Yellow" " Retrieving Travis build `" $buildIdentifier `" "
7889 $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
96107Write-Host - ForegroundColor " Yellow" " Creating temporary folder at `" $path `" "
97108New-Item " $path " - type Directory > $null
98109
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+
100120Write-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
102122
103123Download- AppVeyor- Artifacts $statuses $path
104124Download- Travis- Artifacts $statuses $path
@@ -116,10 +136,10 @@ Add-Type -assembly "System.Io.Compression.Filesystem"
116136[Io.Compression.ZipFile ]::ExtractToDirectory(" $ ( $osxBins.FullName ) " , " $ ( $osxBins.FullName ) .ext" )
117137
118138Write-Host - ForegroundColor " Yellow" " Including non Windows build artifacts"
119- Move-Item " $ ( $linuxBins.FullName ) .ext\libgit2\linux\x86_64 \*.so" " $ ( $package.FullName ) .ext\libgit2 \linux\x86_64 "
120- Remove-Item " $ ( $package.FullName ) .ext\libgit2 \linux\x86_64 \addbinaries.here"
121- Move-Item " $ ( $osxBins.FullName ) .ext\libgit2\osx\*.dylib" " $ ( $package.FullName ) .ext\libgit2 \osx"
122- Remove-Item " $ ( $package.FullName ) .ext\libgit2 \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"
123143
124144Write-Host - ForegroundColor " Yellow" " Building final NuGet package"
125145Push-location " $ ( $package.FullName ) .ext"
0 commit comments