diff options
Diffstat (limited to 'scripts/packages/chocolatey/build.ps1')
-rw-r--r-- | scripts/packages/chocolatey/build.ps1 | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/packages/chocolatey/build.ps1 b/scripts/packages/chocolatey/build.ps1 new file mode 100644 index 0000000000..daa24e12ce --- /dev/null +++ b/scripts/packages/chocolatey/build.ps1 @@ -0,0 +1,52 @@ +param( + [string] $version = "0.3.1", + [switch] $isRelease +) + +$tvVersion = $version +$tvFilename = "bazel_$($version)_windows_x86_64.zip" +if ($isRelease) { + $tvUri = "https://github.com/bazelbuild/bazel/releases/download/$($version)/$($tvFilename)" +} else { + $tvUri = "http://localhost:8000/$($tvFilename)" +} +write-host "download uri: $($tvUri)" + +rm -force -ErrorAction SilentlyContinue ./*.nupkg +rm -force -ErrorAction SilentlyContinue ./*.zip +rm -force -ErrorAction SilentlyContinue ./bazel.nuspec +rm -force -ErrorAction SilentlyContinue ./tools/chocolateyinstall.ps1 + +Add-Type -A System.IO.Compression.FileSystem +$outputDir = "$pwd/../../../output" +$zipFile = "$pwd/$($tvFilename)" +write-host "Creating zip package with $outputDir/bazel.exe: $zipFile" +Compress-Archive -Path "$outputDir/bazel.exe" -DestinationPath $zipFile +$tvChecksum = (get-filehash $zipFile -algorithm sha256).Hash +write-host "zip sha256: $tvChecksum" + +$nuspecTemplate = get-content "bazel.nuspec.template" | out-string +$nuspecExpanded = $ExecutionContext.InvokeCommand.ExpandString($nuspecTemplate) +add-content -value $nuspecExpanded -path bazel.nuspec + +$installerScriptTemplate = get-content "chocolateyinstall.ps1.template" | out-string +$installerScriptExpanded = $ExecutionContext.InvokeCommand.ExpandString($installerScriptTemplate) +$installerScriptExpanded = $installerScriptExpanded -replace "ps_var_","$" +$installerScriptExpanded = $installerScriptExpanded -replace "escape_char","``" +add-content -value $installerScriptExpanded -path ./tools/chocolateyinstall.ps1 + +$uninstallerScriptTemplate = get-content "chocolateyuninstall.ps1.template" | out-string +$uninstallerScriptExpanded = $ExecutionContext.InvokeCommand.ExpandString($uninstallerScriptTemplate) +$uninstallerScriptExpanded = $uninstallerScriptExpanded -replace "ps_var_","$" +$uninstallerScriptExpanded = $uninstallerScriptExpanded -replace "escape_char","``" +add-content -value $uninstallerScriptExpanded -path ./tools/chocolateyuninstall.ps1 + +write-host "Copying LICENSE.txt from repo-root to tools directory" +$licenseHeader = @" +From: https://github.com/bazelbuild/bazel/blob/master/LICENSE.txt + +"@ +add-content -value $licenseHeader -path "./tools/LICENSE.txt" +add-content -value (get-content "../../../LICENSE.txt") -path "./tools/LICENSE.txt" + +choco pack ./bazel.nuspec |