Skip to content

Commit 04c7709

Browse files
committed
[Setup] Updated the scripts to create/push the NuGet/Chocolatey packages.
- [Change] The binaries added to the packages are now downloaded from the github release. - [Change] Redis.nuspec: don't copy the files from the "documentation" folder since the documentation is already included in the source folder along with the binaries. - [Fix] PullBinaries.ps1: replaced hardcoded Redis version number with input parameter. - [Fix] Improved error handling.
1 parent 32aea31 commit 04c7709

File tree

5 files changed

+64
-29
lines changed

5 files changed

+64
-29
lines changed

msvs/setups/CreatePackages.ps1

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
1-
$CurDir = split-path -parent $MyInvocation.MyCommand.Definition
1+
$ErrorActionPreference = "Stop"
22

3-
$ChocolateyDir = $CurDir + "\chocolatey"
4-
$NugetDir = $CurDir + "\nuget"
5-
$PackagesDir = $CurDir + "\packages"
3+
$CurDir = split-path -parent $MyInvocation.MyCommand.Definition
4+
$PackagesDir = $CurDir + "\packages"
5+
$ChocolateySrcDir = $CurDir + "\chocolatey"
6+
$ChocolateyDestDir = $PackagesDir + "\chocolatey"
7+
$NugetSrcDir = $CurDir + "\nuget"
8+
$NugetDestDir = $PackagesDir + "\nuget"
69

710
If (Test-Path $PackagesDir){
811
Remove-Item $PackagesDir -recurse | Out-Null
912
}
10-
New-Item $PackagesDir -type directory | Out-Null
11-
New-Item ($PackagesDir+"\Chocolatey") -type directory | Out-Null
12-
New-Item ($PackagesDir+"\NuGet") -type directory | Out-Null
13+
New-Item $PackagesDir -type directory | Out-Null
14+
New-Item $ChocolateyDestDir -type directory | Out-Null
15+
New-Item $NugetDestDir -type directory | Out-Null
1316

14-
Set-Location $ChocolateyDir
17+
Set-Location $ChocolateySrcDir
1518
invoke-expression "chocolatey pack Redis.nuspec"
16-
Copy-Item *.nupkg ..\packages\Chocolatey
19+
if ($LASTEXITCODE -eq 0) {
20+
Copy-Item *.nupkg $ChocolateyDestDir
21+
Write-Host "Chocolatey package copied to the destination folder." -foregroundcolor black -backgroundcolor green
22+
} else {
23+
Write-Host "FAILED to create the Chocolatey package." -foregroundcolor white -backgroundcolor red
24+
}
1725

18-
Set-Location $NugetDir
19-
invoke-expression "NuGet Pack Redis.nuspec"
20-
Copy-Item *.nupkg ..\packages\NuGet
26+
Set-Location $NugetSrcDir
27+
invoke-expression "nuget pack Redis.nuspec"
28+
if ($LASTEXITCODE -eq 0) {
29+
Copy-Item *.nupkg $NugetDestDir
30+
Write-Host "NuGet package copied to the destination folder." -foregroundcolor black -backgroundcolor green
31+
} else {
32+
Write-Host "FAILED to create the NuGet package." -foregroundcolor white -backgroundcolor red
33+
}
2134

35+
Write-Host "Run PushPackages to push the packages." -foregroundcolor red -backgroundcolor yellow
2236
Set-Location $CurDir
23-
24-
Write-Host "The .nupkg files are in the 'packages' directory." -foregroundcolor black -backgroundcolor green
25-
Write-Host "Run PushPackages to push them." -foregroundcolor red -backgroundcolor yellow

msvs/setups/PullBinaries.ps1

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
1+
param (
2+
[string] $Version = $(throw 'Redis version to download is required')
3+
)
24

3-
$CurDir = split-path -parent $MyInvocation.MyCommand.Definition
5+
$ErrorActionPreference = "Stop"
6+
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
47

5-
$SourceZip = [System.IO.Path]::Combine($CurDir, "..\..\bin\Release\redis-2.8.16.zip" )
6-
$Destination = [System.IO.Path]::Combine($CurDir, "signed_binaries" )
8+
$ZipFilename = "redis-x64-" + $Version + ".zip"
9+
$CurDir = split-path -parent $MyInvocation.MyCommand.Definition
10+
$SourceZip = [System.IO.Path]::Combine($CurDir, $ZipFilename )
11+
$DestinationDir = [System.IO.Path]::Combine($CurDir, "signed_binaries" )
12+
$GithubUrl = "https://github.com/MSOpenTech/redis/releases/download/win-" + $Version + "/" + $ZipFilename
713

8-
[System.IO.Directory]::CreateDirectory($Destination) | Out-Null
14+
[System.IO.File]::Delete($SourceZip)
15+
[System.IO.Directory]::CreateDirectory($DestinationDir) | Out-Null
916

10-
ForEach( $file in [System.IO.Directory]::EnumerateFiles($Destination) ) {
17+
ForEach( $file in [System.IO.Directory]::EnumerateFiles($DestinationDir) ) {
1118
[System.IO.File]::Delete($file)
1219
}
1320

14-
[System.IO.Compression.ZipFile]::ExtractToDirectory($SourceZip,$Destination)
21+
Write-Host "Downloading zip file from $GithubUrl"
22+
(New-Object Net.WebClient).DownloadFile($GithubUrl, $SourceZip);
23+
Write-Host "Download complete." -foregroundcolor black -backgroundcolor green
24+
25+
Write-Host "Extracting files to $DestinationDir"
26+
[System.IO.Compression.ZipFile]::ExtractToDirectory($SourceZip,$DestinationDir)
27+
Write-Host "Extraction complete." -foregroundcolor black -backgroundcolor green
28+
29+
# Clean up
30+
[System.IO.File]::Delete($SourceZip)
1531

16-
Write-Host "Binaries copied from $SourceZip to $Destination" -foregroundcolor black -backgroundcolor green
17-
Write-Host "Sign these and then run CreatePackages.ps1" -foregroundcolor red -backgroundcolor yellow
32+
Write-Host "Sign the binaries and then run CreatePackages.ps1" -foregroundcolor red -backgroundcolor yellow

msvs/setups/PushPackages.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@ param (
22
[string] $Version = $(throw 'Redis version to push is required')
33
)
44

5+
$ErrorActionPreference = "Stop"
6+
57
Write-Host "Ensure that the api keys have been set for chocolatey and nuget" -foregroundcolor red -backgroundcolor yellow
68
Write-Host " NuGet SetApiKey <your key here> -source http://chocolatey.org/" -foregroundcolor red -backgroundcolor yellow
79
Write-Host " NuGet SetApiKey <your key here>" -foregroundcolor red -backgroundcolor yellow
810

911
$CurDir = split-path -parent $MyInvocation.MyCommand.Definition
1012

1113
$PackagesDir = $CurDir + "\packages"
12-
$ChocolateyDir = $PackagesDir + "\Chocolatey"
13-
$NugetDir = $PackagesDir + "\Nuget"
14+
$ChocolateyDir = $PackagesDir + "\chocolatey"
15+
$NugetDir = $PackagesDir + "\nuget"
1416

1517
Set-Location $ChocolateyDir
1618
$ChocolateyCommand = "chocolatey push Redis-64." + $Version + ".nupkg"
1719
invoke-expression $ChocolateyCommand
20+
if ($LASTEXITCODE -eq 0) {
21+
Write-Host "Chocolatey package pushed successfully." -foregroundcolor black -backgroundcolor green
22+
} else {
23+
Write-Host "FAILED to push the Chocolatey package." -foregroundcolor white -backgroundcolor red
24+
}
1825

1926
Set-Location $NugetDir
2027
$NugetCommand = "NuGet push Redis-64." + $Version + ".nupkg"
2128
invoke-expression $NugetCommand
29+
if ($LASTEXITCODE -eq 0) {
30+
Write-Host "NuGet package pushed successfully" -foregroundcolor black -backgroundcolor green
31+
} else {
32+
Write-Host "FAILED to push the NuGet package." -foregroundcolor white -backgroundcolor red
33+
}
2234

2335
Set-Location $CurDir
2436

25-
Write-Host "The .nupkg files have been pushed!" -foregroundcolor black -backgroundcolor green

msvs/setups/chocolatey/Redis.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818
</metadata>
1919
<files>
2020
<file src="..\signed_binaries\*.*" target=".\" />
21-
<file src="..\documentation\*.*" target=".\" />
2221
</files>
2322
</package>

msvs/setups/nuget/Redis.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818
</metadata>
1919
<files>
2020
<file src="..\signed_binaries\*.*" target=".\" />
21-
<file src="..\documentation\*.*" target=".\" />
2221
</files>
2322
</package>

0 commit comments

Comments
 (0)