pulumi/scripts/make_release.ps1
Matt Ellis 409477b951 Invoke node directly from the language host
Instead of using a shell script to jump from the language host into
node, just invoke node directly. This makes our start-up path a little
simpler to understand and indirectly fixes pulumi/home#156, where we
would fail on Windows if the `-exec` script was in a folder that had
spaces in it (due to a subtle interaction between how go launches cmd
files and how cmd.exe parses arguments).
2018-05-02 11:16:58 -07:00

54 lines
2.3 KiB
PowerShell

# make_release.ps1 will create a build package ready for publishing.
Set-StrictMode -Version 2.0
$ErrorActionPreference="Stop"
$NodeVersion = "v6.10.2"
$Root=Join-Path $PSScriptRoot ".."
$PublishDir=New-Item -ItemType Directory -Path "$env:TEMP\$([System.IO.Path]::GetRandomFileName())"
$GitHash=$(git rev-parse HEAD)
$PublishFile="$(Split-Path -Parent -Path $PublishDir)\$GitHash.zip"
$Version = $( & "$PSScriptRoot\get-version.cmd")
$Branch = $(if (Test-Path env:APPVEYOR_REPO_BRANCH) { $env:APPVEYOR_REPO_BRANCH } else { $(git rev-parse --abbrev-ref HEAD) })
$PublishTargets = @($GitHash, $Version, $Branch)
function RunGoBuild($goPackage) {
$binRoot = New-Item -ItemType Directory -Force -Path "$PublishDir\bin"
$outputName = Split-Path -Leaf $(go list -f "{{.Target}}" $goPackage)
go build -ldflags "-X github.com/pulumi/pulumi/pkg/version.Version=$Version" -o "$binRoot\$outputName" $goPackage
}
function CopyPackage($pathToModule, $moduleName) {
$moduleRoot = New-Item -ItemType Directory -Force -Path "$PublishDir\node_modules\$moduleName"
Copy-Item -Recurse $pathToModule\* $moduleRoot
if (Test-Path "$moduleRoot\node_modules") {
Remove-Item -Recurse -Force "$moduleRoot\node_modules"
}
if (Test-Path "$moduleRoot\tests") {
Remove-Item -Recurse -Force "$moduleRoot\tests"
}
}
RunGoBuild "github.com/pulumi/pulumi"
RunGoBuild "github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs"
CopyPackage "$Root\sdk\nodejs\bin" "pulumi"
Copy-Item "$Root\sdk\nodejs\dist\pulumi-resource-pulumi-nodejs.cmd" "$PublishDir\bin"
New-Item -ItemType Directory -Path "$PublishDir\bin\v6.10.2" | Out-Null
New-Item -ItemType Directory -Path "$PublishDir\bin\custom_node" | Out-Null
Copy-Item "$Root\sdk\nodejs\prebuilt\nativeruntime.node" "$PublishDir\bin\v6.10.2"
Copy-Item "$Root\sdk\nodejs\prebuilt\nativeruntime-v0.11.0.node" "$PublishDir\bin\v6.10.2"
Copy-Item "$Root\sdk\nodejs\prebuilt\pulumi-language-nodejs-node.exe" "$PublishDir\bin\custom_node\node.exe"
# By default, if the archive already exists, 7zip will just add files to it, so blow away the existing
# archive if it exists.
if (Test-Path $PublishFile) {
Remove-Item -Force $PublishFile
}
7z a "$PublishFile" "$PublishDir\." | Out-Null
Remove-Item -Recurse -Force $PublishDir
New-Object PSObject -Property @{ArchivePath=$PublishFile;Targets=$PublishTargets}