Permalink
Browse files

Add checksum to chocolatey packages

  • Loading branch information...
1 parent fa6d81b commit 96849304b35d45b07adf64be44ed8f8b7261f993 @laedit laedit committed Aug 26, 2016
@@ -66,47 +66,57 @@ function SetVersion
return New-Object PsObject -Property @{version=$version ; tag=$tag}
}
+function ReplaceChocoInstInfos($chocoInstPath, $version, $path, $zipPathForChecksum)
+{
+ $chochoInst = gc $chocoInstPath
+ $chochoInst = $chochoInst.replace('{{version}}', $version)
+ $chochoInst = $chochoInst.replace('{{tag}}', $tag)
+ $chochoInst = $chochoInst.replace('{{checksum}}', (Get-FileHash $zipPathForChecksum -Algorithm SHA256).Hash)
+ $chochoInst | sc $chocoInstPath
+}
+
# Packaging
function CreatePackage($versionInfos)
{
$version = $versionInfos.version
$tag = $versionInfos.tag
CreateCleanDirectory chocoTemp
-
+
+ # create Pretzel zip
+ RemoveIfExists Pretzel.$version.zip
+ 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\*.dll
+ 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\Pretzel.exe
+ 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\Pretzel.exe.config
+ 7z a $artifacts\Pretzel.$version.zip ReleaseNotes.md
+
# build Pretzel nupkg
mkdir chocoTemp\Pretzel\tools
Copy-Item $tools\chocolatey\Pretzel\pretzel.nuspec chocoTemp\Pretzel\pretzel.nuspec
Copy-Item $tools\chocolatey\Pretzel\chocolateyInstall.ps1 chocoTemp\Pretzel\tools\chocolateyInstall.ps1
Copy-Item $tools\chocolatey\Pretzel\chocolateyUninstall.ps1 chocoTemp\Pretzel\tools\chocolateyUninstall.ps1
-
- (gc chocoTemp\Pretzel\tools\chocolateyInstall.ps1).replace('{{version}}', $version).replace('{{tag}}', $tag)|sc chocoTemp\Pretzel\tools\chocolateyInstall.ps1
-
+
+ ReplaceChocoInstInfos chocoTemp\Pretzel\tools\chocolateyInstall.ps1 $version $tag $artifacts\Pretzel.$version.zip
+
nuget pack chocoTemp\Pretzel\pretzel.nuspec -OutputDirectory $artifacts -Version $version -NoPackageAnalysis
+
+ # create Pretzel.ScriptCs zip
+ get-childitem $src\Pretzel.ScriptCs\bin\Release -filter *.dll | % { $_.Name } | out-file $artifacts\Pretzel.ScriptCs.Files.txt
- # create Pretzel zip
- RemoveIfExists Pretzel.$version.zip
- 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\*.dll
- 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\Pretzel.exe
- 7z a $artifacts\Pretzel.$version.zip $src\Pretzel\bin\Release\Pretzel.exe.config
- 7z a $artifacts\Pretzel.$version.zip ReleaseNotes.md
-
+ RemoveIfExists Pretzel.ScriptCs.$version.zip
+ 7z a $artifacts\Pretzel.ScriptCs.$version.zip $src\Pretzel.ScriptCs\bin\Release\*.dll
+ 7z a $artifacts\Pretzel.ScriptCs.$version.zip $artifacts\Pretzel.ScriptCs.Files.txt
+
# build Pretzel.ScriptCs nupkg
mkdir chocoTemp\Pretzel.ScriptCs\tools
Copy-Item $tools\chocolatey\Pretzel.ScriptCs\pretzel.scriptcs.nuspec chocoTemp\Pretzel.ScriptCs\pretzel.scriptcs.nuspec
Copy-Item $tools\chocolatey\Pretzel.ScriptCs\chocolateyInstall.ps1 chocoTemp\Pretzel.ScriptCs\tools\chocolateyInstall.ps1
Copy-Item $tools\chocolatey\Pretzel.ScriptCs\chocolateyUninstall.ps1 chocoTemp\Pretzel.ScriptCs\tools\chocolateyUninstall.ps1
- (gc chocoTemp\Pretzel.ScriptCs\tools\chocolateyInstall.ps1).replace('{{version}}',$version).replace('{{tag}}',$tag)|sc chocoTemp\Pretzel.ScriptCs\tools\chocolateyInstall.ps1
+ ReplaceChocoInstInfos chocoTemp\Pretzel.ScriptCs\tools\chocolateyInstall.ps1 $version $tag $artifacts\Pretzel.ScriptCs.$version.zip
+
nuget pack chocoTemp\Pretzel.ScriptCs\pretzel.scriptcs.nuspec -OutputDirectory $artifacts -Version $version -NoPackageAnalysis
-
- # create Pretzel.ScriptCs zip
- get-childitem $src\Pretzel.ScriptCs\bin\Release -filter *.dll | % { $_.Name } | out-file $artifacts\Pretzel.ScriptCs.Files.txt
-
- RemoveIfExists Pretzel.ScriptCs.$version.zip
- 7z a $artifacts\Pretzel.ScriptCs.$version.zip $src\Pretzel.ScriptCs\bin\Release\*.dll
- 7z a $artifacts\Pretzel.ScriptCs.$version.zip $artifacts\Pretzel.ScriptCs.Files.txt
-
+
# build Pretzel.Logic nupkg
nuget pack $src\Pretzel.Logic\Pretzel.Logic.csproj -OutputDirectory $artifacts -Version $version -symbols
}
@@ -4,4 +4,4 @@ $url = 'https://github.com/Code52/Pretzel/releases/download/{{tag}}/Pretzel.Scri
$binRoot = Get-BinRoot
$pretzelPath = "$binRoot\Pretzel"
-Install-ChocolateyZipPackage "$packageName" "$url" $pretzelPath
+Install-ChocolateyZipPackage "$packageName" "$url" $pretzelPath -checksum {{checksum}} -checksumType sha256
@@ -4,5 +4,5 @@ $url = 'https://github.com/Code52/Pretzel/releases/download/{{tag}}/Pretzel.{{ve
$binRoot = Get-BinRoot
$pretzelPath = "$binRoot\$packageName"
-Install-ChocolateyZipPackage "$packageName" "$url" $pretzelPath
+Install-ChocolateyZipPackage "$packageName" "$url" $pretzelPath -checksum {{checksum}} -checksumType sha256
Install-ChocolateyPath $pretzelPath

0 comments on commit 9684930

Please sign in to comment.