|
| 1 | +param($buildVersion = $null) |
| 2 | + |
| 3 | +$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release") |
| 4 | +$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign") |
| 5 | +$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages") |
| 6 | + |
| 7 | +# Ensure that the release path exists and clear out old folders |
| 8 | +mkdir $releasePath -Force | Out-Null |
| 9 | + |
| 10 | +# Install prerequisite packages |
| 11 | +#Install-Package -Name "Nito.AsyncEx" -RequiredVersion "3.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force |
| 12 | +#Install-Package -Name "Newtonsoft.Json" -RequiredVersion "7.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force |
| 13 | + |
| 14 | +if ($buildVersion -eq $null) { |
| 15 | + # Get the current build status |
| 16 | + $headers = @{ "Content-Type" = "application/json" } |
| 17 | + $project = Invoke-RestMethod -Method Get -Uri "https://ci.appveyor.com/api/projects/PowerShell/PowerShellEditorServices/branch/master" -Headers $headers |
| 18 | + $buildVersion = $project.build.version |
| 19 | + if ($project.build.status -eq "success") { |
| 20 | + Write-Output "Latest build version on master is $buildVersion`r`n" |
| 21 | + } |
| 22 | + else { |
| 23 | + Write-Error "PowerShellEditorServices build $buildVersion was not successful!" -ErrorAction "Stop" |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +function Install-BuildPackage($packageName, $extension) { |
| 28 | + $uri = "https://ci.appveyor.com/nuget/powershelleditorservices/api/v2/package/{0}/{1}" -f $packageName.ToLower(), $buildVersion |
| 29 | + Write-Verbose "Fetching from URI: $uri" |
| 30 | + |
| 31 | + # Download the package and extract it |
| 32 | + $zipPath = "$releasePath\$packageName.zip" |
| 33 | + $packageContentPath = "$unpackedPackagesPath\$packageName" |
| 34 | + Invoke-WebRequest $uri -OutFile $zipPath -ErrorAction "Stop" |
| 35 | + Expand-Archive $zipPath -DestinationPath $packageContentPath -Force -ErrorAction "Stop" |
| 36 | + Remove-Item $zipPath -ErrorAction "Stop" |
| 37 | + |
| 38 | + # Copy the binary to the binary signing folder |
| 39 | + mkdir $binariesToSignPath -Force | Out-Null |
| 40 | + cp "$packageContentPath\lib\net45\$packageName.$extension" -Force -Destination $binariesToSignPath |
| 41 | + |
| 42 | + Write-Output "Extracted package $packageName ($buildVersion)" |
| 43 | +} |
| 44 | + |
| 45 | +# Pull the build packages from AppVeyor |
| 46 | +Install-BuildPackage "Microsoft.PowerShell.EditorServices" "dll" |
| 47 | +Install-BuildPackage "Microsoft.PowerShell.EditorServices.Protocol" "dll" |
| 48 | +Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "exe" |
| 49 | + |
| 50 | +# Open the BinariesToSign folder |
| 51 | +& start $binariesToSignPath |
0 commit comments