diff --git a/msvs/setups/CreatePackages.ps1 b/msvs/setups/CreatePackages.ps1 index 9baab1ad..479eda9f 100644 --- a/msvs/setups/CreatePackages.ps1 +++ b/msvs/setups/CreatePackages.ps1 @@ -1,25 +1,36 @@ -$CurDir = split-path -parent $MyInvocation.MyCommand.Definition +$ErrorActionPreference = "Stop" -$ChocolateyDir = $CurDir + "\chocolatey" -$NugetDir = $CurDir + "\nuget" -$PackagesDir = $CurDir + "\packages" +$CurDir = split-path -parent $MyInvocation.MyCommand.Definition +$PackagesDir = $CurDir + "\packages" +$ChocolateySrcDir = $CurDir + "\chocolatey" +$ChocolateyDestDir = $PackagesDir + "\chocolatey" +$NugetSrcDir = $CurDir + "\nuget" +$NugetDestDir = $PackagesDir + "\nuget" If (Test-Path $PackagesDir){ Remove-Item $PackagesDir -recurse | Out-Null } -New-Item $PackagesDir -type directory | Out-Null -New-Item ($PackagesDir+"\Chocolatey") -type directory | Out-Null -New-Item ($PackagesDir+"\NuGet") -type directory | Out-Null +New-Item $PackagesDir -type directory | Out-Null +New-Item $ChocolateyDestDir -type directory | Out-Null +New-Item $NugetDestDir -type directory | Out-Null -Set-Location $ChocolateyDir +Set-Location $ChocolateySrcDir invoke-expression "chocolatey pack Redis.nuspec" -Copy-Item *.nupkg ..\packages\Chocolatey +if ($LASTEXITCODE -eq 0) { + Copy-Item *.nupkg $ChocolateyDestDir + Write-Host "Chocolatey package copied to the destination folder." -foregroundcolor black -backgroundcolor green +} else { + Write-Host "FAILED to create the Chocolatey package." -foregroundcolor white -backgroundcolor red +} -Set-Location $NugetDir -invoke-expression "NuGet Pack Redis.nuspec" -Copy-Item *.nupkg ..\packages\NuGet +Set-Location $NugetSrcDir +invoke-expression "nuget pack Redis.nuspec" +if ($LASTEXITCODE -eq 0) { + Copy-Item *.nupkg $NugetDestDir + Write-Host "NuGet package copied to the destination folder." -foregroundcolor black -backgroundcolor green +} else { + Write-Host "FAILED to create the NuGet package." -foregroundcolor white -backgroundcolor red +} +Write-Host "Run PushPackages to push the packages." -foregroundcolor red -backgroundcolor yellow Set-Location $CurDir - -Write-Host "The .nupkg files are in the 'packages' directory." -foregroundcolor black -backgroundcolor green -Write-Host "Run PushPackages to push them." -foregroundcolor red -backgroundcolor yellow diff --git a/msvs/setups/PullBinaries.ps1 b/msvs/setups/PullBinaries.ps1 index c65b8c51..eb0464d9 100644 --- a/msvs/setups/PullBinaries.ps1 +++ b/msvs/setups/PullBinaries.ps1 @@ -1,17 +1,32 @@ +param ( + [string] $Version = $(throw 'Redis version to download is required') +) + +$ErrorActionPreference = "Stop" [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null -$CurDir = split-path -parent $MyInvocation.MyCommand.Definition +$ZipFilename = "redis-x64-" + $Version + ".zip" +$CurDir = split-path -parent $MyInvocation.MyCommand.Definition +$SourceZip = [System.IO.Path]::Combine($CurDir, $ZipFilename ) +$DestinationDir = [System.IO.Path]::Combine($CurDir, "signed_binaries" ) +$GithubUrl = "https://github.com/MSOpenTech/redis/releases/download/win-" + $Version + "/" + $ZipFilename -$SourceZip = [System.IO.Path]::Combine($CurDir, "..\..\bin\Release\redis-2.8.16.zip" ) -$Destination = [System.IO.Path]::Combine($CurDir, "signed_binaries" ) +[System.IO.File]::Delete($SourceZip) +[System.IO.Directory]::CreateDirectory($DestinationDir) | Out-Null -[System.IO.Directory]::CreateDirectory($Destination) | Out-Null - -ForEach( $file in [System.IO.Directory]::EnumerateFiles($Destination) ) { +ForEach( $file in [System.IO.Directory]::EnumerateFiles($DestinationDir) ) { [System.IO.File]::Delete($file) } -[System.IO.Compression.ZipFile]::ExtractToDirectory($SourceZip,$Destination) +Write-Host "Downloading zip file from $GithubUrl" +(New-Object Net.WebClient).DownloadFile($GithubUrl, $SourceZip); +Write-Host "Download complete." -foregroundcolor black -backgroundcolor green -Write-Host "Binaries copied from $SourceZip to $Destination" -foregroundcolor black -backgroundcolor green -Write-Host "Sign these and then run CreatePackages.ps1" -foregroundcolor red -backgroundcolor yellow +Write-Host "Extracting files to $DestinationDir" +[System.IO.Compression.ZipFile]::ExtractToDirectory($SourceZip,$DestinationDir) +Write-Host "Extraction complete." -foregroundcolor black -backgroundcolor green + +# Clean up +[System.IO.File]::Delete($SourceZip) + +Write-Host "Sign the binaries and then run CreatePackages.ps1" -foregroundcolor red -backgroundcolor yellow diff --git a/msvs/setups/PushPackages.ps1 b/msvs/setups/PushPackages.ps1 index e61f8f54..d6a29010 100644 --- a/msvs/setups/PushPackages.ps1 +++ b/msvs/setups/PushPackages.ps1 @@ -2,6 +2,8 @@ param ( [string] $Version = $(throw 'Redis version to push is required') ) +$ErrorActionPreference = "Stop" + Write-Host "Ensure that the api keys have been set for chocolatey and nuget" -foregroundcolor red -backgroundcolor yellow Write-Host " NuGet SetApiKey -source http://chocolatey.org/" -foregroundcolor red -backgroundcolor yellow Write-Host " NuGet SetApiKey " -foregroundcolor red -backgroundcolor yellow @@ -9,17 +11,26 @@ Write-Host " NuGet SetApiKey " -foregroundcolor red -backgroundc $CurDir = split-path -parent $MyInvocation.MyCommand.Definition $PackagesDir = $CurDir + "\packages" -$ChocolateyDir = $PackagesDir + "\Chocolatey" -$NugetDir = $PackagesDir + "\Nuget" +$ChocolateyDir = $PackagesDir + "\chocolatey" +$NugetDir = $PackagesDir + "\nuget" Set-Location $ChocolateyDir $ChocolateyCommand = "chocolatey push Redis-64." + $Version + ".nupkg" invoke-expression $ChocolateyCommand +if ($LASTEXITCODE -eq 0) { + Write-Host "Chocolatey package pushed successfully." -foregroundcolor black -backgroundcolor green +} else { + Write-Host "FAILED to push the Chocolatey package." -foregroundcolor white -backgroundcolor red +} Set-Location $NugetDir $NugetCommand = "NuGet push Redis-64." + $Version + ".nupkg" invoke-expression $NugetCommand +if ($LASTEXITCODE -eq 0) { + Write-Host "NuGet package pushed successfully" -foregroundcolor black -backgroundcolor green +} else { + Write-Host "FAILED to push the NuGet package." -foregroundcolor white -backgroundcolor red +} Set-Location $CurDir -Write-Host "The .nupkg files have been pushed!" -foregroundcolor black -backgroundcolor green diff --git a/msvs/setups/chocolatey/Redis.nuspec b/msvs/setups/chocolatey/Redis.nuspec index dc05feb5..5b454662 100644 --- a/msvs/setups/chocolatey/Redis.nuspec +++ b/msvs/setups/chocolatey/Redis.nuspec @@ -18,6 +18,5 @@ - diff --git a/msvs/setups/nuget/Redis.nuspec b/msvs/setups/nuget/Redis.nuspec index dc05feb5..5b454662 100644 --- a/msvs/setups/nuget/Redis.nuspec +++ b/msvs/setups/nuget/Redis.nuspec @@ -18,6 +18,5 @@ -