Skip to content

Commit a7621ac

Browse files
author
Edward Thomson
committed
build artifacts: allow to create from any branch
Take the branch name or a pull request number.
1 parent 6f62aae commit a7621ac

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

download.build.artifacts.and.package.ps1

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Param(
2+
[string]$ref = "master",
23
[switch]$verbose = $False
34
)
45

@@ -50,8 +51,13 @@ function Extract-BuildIdentifier($statuses, $forContext) {
5051
}
5152

5253
function 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

7379
function 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
96107
Write-Host -ForegroundColor "Yellow" "Creating temporary folder at `"$path`""
97108
New-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+
100120
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
102122

103123
Download-AppVeyor-Artifacts $statuses $path
104124
Download-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

118138
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"
123143

124144
Write-Host -ForegroundColor "Yellow" "Building final NuGet package"
125145
Push-location "$($package.FullName).ext"

0 commit comments

Comments
 (0)