-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.ps1
27 lines (22 loc) · 997 Bytes
/
package.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
param (
[string]$dir = "$pwd\ChocolateStoreCore"
)
$dirRelease = "$dir\..\release"
$dirPackage = "$dir\..\ChocolateyPackages\chocolatestore"
$dirPackageBinaries = "$dirPackage\tools"
$dirPackageNuspec = "$dirPackage\chocolatestore.nuspec"
$installps1 = "$dirPackageBinaries\chocolateyInstall.ps1"
$zip = 'ChocolateStoreCore.zip'
If (Test-Path (Join-Path $dirRelease $zip)) {
Copy-Item (Join-Path $dirRelease $zip) -Destination (Join-Path $dirPackageBinaries $zip) -Force
} else {
Write-Error 'Zip archive not found.'
}
$hash = (Get-FileHash -Path (Join-Path $dirRelease $zip) -Algorithm SHA256).Hash
$content = Get-Content -Path $installps1
$newContent = $content -replace "(?<=checksum\s*=\s*')[^']*", $hash
$newContent | Set-Content -Path $installps1
[xml]$nuspecContent = Get-Content $dirPackageNuspec
$nuspecContent.package.metadata.version = [string](Get-Content "$dir\..\version.txt")
$nuspecContent.Save($dirPackageNuspec)
choco pack $dirPackageNuspec --outdir $dirRelease