From f68b58383142f853bb8d7ff871fd48a4dfa95734 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 10 May 2021 11:11:08 +0100 Subject: [PATCH] Using goreleaser as the publishing mechanism for Windows binaries (#6975) --- .github/workflows/master.yml | 8 --- .github/workflows/prerelease.yml | 10 +-- .github/workflows/release.yml | 10 +-- .gitignore | 6 ++ .goreleaser.prerelease.yml | 71 ++++++++++++++++++++ .goreleaser.yml | 74 ++++++++++++++++++++- build.proj | 19 ------ scripts/build-sdk.cmd | 2 - scripts/build-sdk.ps1 | 82 ----------------------- scripts/build-sdk.sh | 111 ------------------------------- scripts/make_release.ps1 | 56 ---------------- scripts/make_release.sh | 74 --------------------- scripts/prep-for-goreleaser.sh | 7 +- scripts/publish.cmd | 2 - scripts/publish.ps1 | 20 ------ scripts/publish_tgz.sh | 33 --------- 16 files changed, 165 insertions(+), 420 deletions(-) delete mode 100644 scripts/build-sdk.cmd delete mode 100644 scripts/build-sdk.ps1 delete mode 100755 scripts/build-sdk.sh delete mode 100644 scripts/make_release.ps1 delete mode 100755 scripts/make_release.sh delete mode 100644 scripts/publish.cmd delete mode 100644 scripts/publish.ps1 delete mode 100755 scripts/publish_tgz.sh diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index fc1efdff8..8aef72934 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -287,14 +287,6 @@ jobs: run: | cd src\github.com\${{ github.repository }} dotnet msbuild /t:Tests /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" - - name: Publish Binary - run: | - cd src\github.com\${{ github.repository }} - dotnet msbuild /t:Publish /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" - - run: | - cd src\github.com\${{ github.repository }} - git status - git --no-pager diff verify-containers: name: Run Container Tests needs: [publish-binaries, publish-sdks] diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index e04d6444d..4fefc7e93 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -78,7 +78,7 @@ jobs: publish-binaries: name: Publish Binaries runs-on: macos-latest - needs: [build-and-test, windows-release] + needs: [build-and-test, windows-build] strategy: matrix: go-version: [ 1.16.x ] @@ -200,8 +200,8 @@ jobs: PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules PULUMI_LOCAL_NUGET: ${{ runner.temp }}/opt/pulumi/nuget PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi - windows-release: - name: Windows Build + Release + windows-build: + name: Windows Build strategy: matrix: go-version: [ 1.16.x ] @@ -279,10 +279,10 @@ jobs: cd tests go mod download popd - - name: Publish Binary + - name: Build Binary run: | cd src\github.com\${{ github.repository }} - dotnet msbuild /t:ReleaseProcess /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" + dotnet msbuild /t:Build /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" verify-containers: name: Run Container Tests needs: [publish-binaries, publish-sdks] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b73f12db5..ef82caa42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -173,7 +173,7 @@ jobs: publish-binaries: name: Publish Binaries runs-on: macos-latest - needs: [build-and-test, windows-release] + needs: [build-and-test, windows-build] strategy: matrix: go-version: [ 1.16.x ] @@ -295,8 +295,8 @@ jobs: PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules PULUMI_LOCAL_NUGET: ${{ runner.temp }}/opt/pulumi/nuget PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi - windows-release: - name: Windows Build + Release + windows-build: + name: Windows Build strategy: matrix: go-version: [1.16.x] @@ -374,10 +374,10 @@ jobs: cd tests go mod download popd - - name: Publish Binary + - name: Build Binary run: | cd src\github.com\${{ github.repository }} - dotnet msbuild /t:ReleaseProcess /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" + dotnet msbuild /t:Build /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" verify-containers: name: Run Container Tests needs: [publish-binaries, publish-sdks] diff --git a/.gitignore b/.gitignore index 45c159e65..afc5fdafd 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,9 @@ pulumi-resource-pulumi-python pulumi-analyzer-policy pulumi-analyzer-policy-python pulumi-language-python-exec +pulumi-resource-pulumi-nodejs.cmd +pulumi-resource-pulumi-python.cmd +pulumi-python3-shim.cmd +pulumi-python-shim.cmd +pulumi-analyzer-policy.cmd +pulumi-analyzer-policy-python.cmd diff --git a/.goreleaser.prerelease.yml b/.goreleaser.prerelease.yml index 321f012bf..46bf3a44a 100644 --- a/.goreleaser.prerelease.yml +++ b/.goreleaser.prerelease.yml @@ -18,6 +18,57 @@ release: changelog: skip: true builds: +# Windows builds +- id: pulumi-windows + binary: pulumi + dir: pkg + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./cmd/pulumi +- id: pulumi-language-nodejs-windows + binary: pulumi-language-nodejs + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./nodejs/cmd/pulumi-language-nodejs +- id: pulumi-language-python-windows + binary: pulumi-language-python + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./python/cmd/pulumi-language-python +- id: pulumi-language-dotnet-windows + binary: pulumi-language-dotnet + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./dotnet/cmd/pulumi-language-dotnet +- id: pulumi-language-go-windows + binary: pulumi-language-go + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./go/pulumi-language-go # UNIX builds - id: pulumi-unix binary: pulumi @@ -99,6 +150,26 @@ archives: - pulumi-analyzer-policy-python - pulumi-language-python-exec name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" +- id: pulumi-windows + wrap_in_directory: pulumi/bin + builds: + - pulumi-language-dotnet-windows + - pulumi-language-go-windows + - pulumi-language-python-windows + - pulumi-language-nodejs-windows + - pulumi-windows + replacements: + amd64: x64 + format: zip + files: + - pulumi-resource-pulumi-nodejs.cmd + - pulumi-resource-pulumi-python.cmd + - pulumi-python3-shim.cmd + - pulumi-python-shim.cmd + - pulumi-analyzer-policy.cmd + - pulumi-analyzer-policy-python.cmd + - pulumi-language-python-exec + name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" snapshot: name_template: "{{ .Version }}-SNAPSHOT" checksum: diff --git a/.goreleaser.yml b/.goreleaser.yml index c71ff42a9..21672fcca 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,6 +13,57 @@ blobs: provider: s3 region: us-west-2 builds: +# Windows builds +- id: pulumi-windows + binary: pulumi + dir: pkg + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./cmd/pulumi +- id: pulumi-language-nodejs-windows + binary: pulumi-language-nodejs + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./nodejs/cmd/pulumi-language-nodejs +- id: pulumi-language-python-windows + binary: pulumi-language-python + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./python/cmd/pulumi-language-python +- id: pulumi-language-dotnet-windows + binary: pulumi-language-dotnet + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./dotnet/cmd/pulumi-language-dotnet +- id: pulumi-language-go-windows + binary: pulumi-language-go + dir: sdk + goarch: + - amd64 + goos: + - windows + ldflags: + - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} + main: ./go/pulumi-language-go # UNIX builds - id: pulumi-unix binary: pulumi @@ -75,10 +126,9 @@ builds: - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}} main: ./go/pulumi-language-go - archives: - id: pulumi-unix - wrap_in_directory: "pulumi" + wrap_in_directory: pulumi builds: - pulumi-language-dotnet-unix - pulumi-language-go-unix @@ -94,6 +144,26 @@ archives: - pulumi-analyzer-policy-python - pulumi-language-python-exec name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" +- id: pulumi-windows + wrap_in_directory: pulumi/bin + builds: + - pulumi-language-dotnet-windows + - pulumi-language-go-windows + - pulumi-language-python-windows + - pulumi-language-nodejs-windows + - pulumi-windows + replacements: + amd64: x64 + format: zip + files: + - pulumi-resource-pulumi-nodejs.cmd + - pulumi-resource-pulumi-python.cmd + - pulumi-python3-shim.cmd + - pulumi-python-shim.cmd + - pulumi-analyzer-policy.cmd + - pulumi-analyzer-policy-python.cmd + - pulumi-language-python-exec + name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" snapshot: name_template: "{{ .Version }}-SNAPSHOT" checksum: diff --git a/build.proj b/build.proj index 1a6d2af86..c2c385cef 100644 --- a/build.proj +++ b/build.proj @@ -258,18 +258,6 @@ DependsOnTargets="BuildDotNetSDK;BuildGoSDK;BuildNodeJSSDK;BuildPythonSDK;InstallPulumiPlugin"> - - - - @@ -337,13 +325,6 @@ Condition="$(IntegrationTestExitCode) != 0"/> - - - - - - diff --git a/scripts/build-sdk.cmd b/scripts/build-sdk.cmd deleted file mode 100644 index b7a22076b..000000000 --- a/scripts/build-sdk.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -powershell -noprofile -executionPolicy Unrestricted -file "%~dpn0.ps1" %* \ No newline at end of file diff --git a/scripts/build-sdk.ps1 b/scripts/build-sdk.ps1 deleted file mode 100644 index 277880935..000000000 --- a/scripts/build-sdk.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -param ( - $VersionTag, - $PulumiRef -) - -Set-StrictMode -Version 2.0 -$ErrorActionPreference = "Stop" - -$S3ProdBucketRoot="s3://get.pulumi.com/releases/" -$S3EngBucketRoot="s3://eng.pulumi.com/releases/" -$S3PublishFolderSdk="${S3ProdBucketRoot}sdk/" - -function New-TemporaryDirectory { - New-Item -ItemType Directory -Path (Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())) -} - -function New-TemporaryFile { - New-Item -ItemType File -Path (Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())) -} - -function Download-Release ($repoName, $repoCommit, [ValidateSet("zip", "tgz")]$ext) { - Write-Host "downloading $repoName@$repoCommit" - - $file="${repoCommit}.${ext}" - $s3File="${S3EngBucketRoot}${repoName}/windows/amd64/${file}" - - aws s3 cp --only-show-errors "$s3File" ".\$file" - - switch($ext) { - "zip" { 7z x ${file} } - "tgz" { cmd /C "7z x ${file} -tgzip -so | 7z x -ttar -si" } - default { Write-Error "Unknown extention type $ext" } - } - - Remove-Item -Force "$file" -} - -if (!$VersionTag) { $VersionTag=Get-Date -UFormat '%Y%m%d_%H%M%S' } -if (!$PulumiRef) { $PulumiRef="master" } - -$SdkFileName="pulumi-$($VersionTag -replace '\+.', '')-windows-x64.zip" - -$PulumiFolder=(Join-Path (New-TemporaryDirectory) "Pulumi") - -New-Item -ItemType Directory -Path $PulumiFolder | Out-Null - -Push-Location "$PulumiFolder" | Out-Null - -Write-Host "pulumi: $PulumiRef" -Write-Host "" - -Download-Release "pulumi" $PulumiRef "zip" - -Remove-Item -Recurse -Force -Path "$PulumiFolder\node_modules" - -$SdkPackagePath=(Join-Path ([System.IO.Path]::GetTempPath()) $SdkFileName) - -if (Test-Path $SdkPackagePath) { - Remove-Item -Force -Path $SdkPackagePath -} - -7z a -tzip "$SdkPackagePath" "$(Join-Path (Split-Path -Parent $PulumiFolder) '.')" - -Write-Host "uploading SDK to ${S3PublishFolderSdk}${SdkFileName}" - -$AWSCreds=((aws sts assume-role ` - --role-arn "arn:aws:iam::058607598222:role/UploadPulumiReleases" ` - --role-session-name "upload-sdk" ` - --external-id "upload-pulumi-release") | ConvertFrom-Json) - -$env:AWS_ACCESS_KEY_ID=$AWSCreds.Credentials.AccessKeyId -$env:AWS_SECRET_ACCESS_KEY=$AWSCreds.Credentials.SecretAccessKey -$env:AWS_SECURITY_TOKEN=$AWSCreds.Credentials.SessionToken - -aws s3 cp --acl public-read --only-show-errors "$SdkPackagePath" "${S3PublishFolderSdk}${SdkFileName}" - -Pop-Location | Out-Null - -Remove-Item -Path $SdkPackagePath -Remove-Item -Path (Split-Path -Parent $PulumiFolder) -Force -Recurse - -Write-Host "done" diff --git a/scripts/build-sdk.sh b/scripts/build-sdk.sh deleted file mode 100755 index a96721969..000000000 --- a/scripts/build-sdk.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# Usage build-sdk.sh [version-tag] [pulumi-cloud-ref-name] -# -# version-tag defaults to current date and time -# ref-name defaults to master (can be a branch or tag name) -set -o nounset -set -o errexit -set -o pipefail - -readonly SCRIPT_DIR="$( cd "$( dirname "${0}" )" && pwd )" -readonly S3_PROD_BUCKET_ROOT="s3://get.pulumi.com/releases" -readonly S3_ENG_BUCKET_ROOT="s3://eng.pulumi.com/releases" -readonly S3_PUBLISH_FOLDER_SDK="${S3_PROD_BUCKET_ROOT}/sdk" - -# This function downloads a specific release and into the current working directory -# usage: download_release -download_release() { - local -r repo_name="${1}" - local -r repo_commit="${2}" - - echo "downloading ${repo_name}@${repo_commit}" - - local -r file=${repo_commit}.tgz - local -r s3_file=${S3_ENG_BUCKET_ROOT}/${repo_name}/${OS}/amd64/${file} - - # Use AWS CLI to download the package corresponding to the component from S3 bucket - if ! aws s3 cp --only-show-errors "${s3_file}" "./${file}" 2> /dev/null; then - >&2 echo "failed to download ${s3_file}" - exit 1 - fi -} - -# This function downloads and extracts a specific release and into the current working directory -# usage: download_and_extract_release -download_and_extract_release() { - local -r repo_name="${1}" - local -r repo_commit="${2}" - local -r file="${repo_commit}.tgz" - - download_release "${repo_name}" "${repo_commit}" - - if ! tar -xzf "${file}" 2> /dev/null; then - >&2 echo "failed to untar ${file}" - exit 1 - fi - - rm "./${file}" -} - -# get the OS version -OS="" -case $(uname) in - "Linux") OS=linux;; - "Darwin") OS=darwin;; - *) echo "error: unknown host os $(uname)" ; exit 1;; -esac - -readonly SDK_FILENAME=pulumi-${1:-$(date +"%Y%m%d_%H%M%S")}-${OS}-x64.tar.gz -readonly PULUMI_REF=${2:-master} - -# setup temporary folder to process the package -readonly PULUMI_FOLDER=$(mktemp -d)/pulumi -mkdir -p "${PULUMI_FOLDER}" - -cd "${PULUMI_FOLDER}" - -download_and_extract_release pulumi "${PULUMI_REF}" - -# All node packages are now delivered via npm, so remove the node_modules folder. -rm -rf "${PULUMI_FOLDER}/node_modules" - -# Promote the binaries to the top level and delete the bin folder. -mv "${PULUMI_FOLDER}/bin"/* "${PULUMI_FOLDER}/" -rm -rf "${PULUMI_FOLDER}/bin" - -readonly SDK_PACKAGE_PATH=$(mktemp) - -echo "compressing package to ${SDK_PACKAGE_PATH}" - -cd .. - -if ! tar -zcf "${SDK_PACKAGE_PATH}" pulumi; then - >&2 echo "failed to compress package" - exit 1 -fi - -echo "${SDK_PACKAGE_PATH}" -# rel.pulumi.com is in our production account, so assume that role first. -readonly CREDS_JSON=$(aws sts assume-role \ - --role-arn "arn:aws:iam::058607598222:role/UploadPulumiReleases" \ - --role-session-name "upload-sdk" \ - --external-id "upload-pulumi-release") - -# Extract the assumed role's credentials into specific env vars. -AWS_ACCESS_KEY_ID=$(echo "${CREDS_JSON}" | jq ".Credentials.AccessKeyId" --raw-output) -export AWS_ACCESS_KEY_ID - -AWS_SECRET_ACCESS_KEY=$(echo "${CREDS_JSON}" | jq ".Credentials.SecretAccessKey" --raw-output) -export AWS_SECRET_ACCESS_KEY - -AWS_SECURITY_TOKEN=$(echo "${CREDS_JSON}" | jq ".Credentials.SessionToken" --raw-output) -export AWS_SECURITY_TOKEN - -aws s3 cp --acl public-read --only-show-errors "${SDK_PACKAGE_PATH}" "${S3_PUBLISH_FOLDER_SDK}/${SDK_FILENAME}" - -rm "${SDK_PACKAGE_PATH}" -rm -rf "${PULUMI_FOLDER:?}" - -echo "done" - -exit 0 diff --git a/scripts/make_release.ps1 b/scripts/make_release.ps1 deleted file mode 100644 index a6d6375f9..000000000 --- a/scripts/make_release.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -# make_release.ps1 will create a build package ready for publishing. -Set-StrictMode -Version 2.0 -$ErrorActionPreference="Stop" - -$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 = $(pulumictl get version) -$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, $dir, $outputName) { - $binRoot = New-Item -ItemType Directory -Force -Path "$PublishDir\bin" - Push-Location $dir - go build -ldflags "-X github.com/pulumi/pulumi/pkg/v3/version.Version=v$Version" -o "$binRoot\$outputName" $goPackage - Pop-Location -} - -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/pkg/v3/cmd/pulumi" "pkg" "pulumi.exe" -RunGoBuild "github.com/pulumi/pulumi/sdk/v3/nodejs/cmd/pulumi-language-nodejs" "sdk" "pulumi-language-nodejs.exe" -RunGoBuild "github.com/pulumi/pulumi/sdk/v3/python/cmd/pulumi-language-python" "sdk" "pulumi-language-python.exe" -RunGoBuild "github.com/pulumi/pulumi/sdk/v3/dotnet/cmd/pulumi-language-dotnet" "sdk" "pulumi-language-dotnet.exe" -RunGoBuild "github.com/pulumi/pulumi/sdk/v3/go/pulumi-language-go" "sdk" "pulumi-language-go.exe" -CopyPackage "$Root\sdk\nodejs\bin" "pulumi" - -Copy-Item "$Root\sdk\nodejs\dist\pulumi-resource-pulumi-nodejs.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\python\dist\pulumi-python-shim.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\python\dist\pulumi-python3-shim.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\python\dist\pulumi-resource-pulumi-python.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\nodejs\dist\pulumi-analyzer-policy.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\python\dist\pulumi-analyzer-policy-python.cmd" "$PublishDir\bin" -Copy-Item "$Root\sdk\python\cmd\pulumi-language-python-exec" "$PublishDir\bin" - -# 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} diff --git a/scripts/make_release.sh b/scripts/make_release.sh deleted file mode 100755 index acc6729d7..000000000 --- a/scripts/make_release.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# make_release.sh will create a build package ready for publishing. -set -o nounset -set -o errexit -set -o pipefail - -readonly ROOT=$(dirname "${0}")/.. -readonly PUBDIR=$(mktemp -d) -readonly GITHASH=$(git rev-parse HEAD) -readonly PUBFILE=$(dirname "${PUBDIR})/${GITHASH}.tgz") -readonly VERSION=$(pulumictl get version) - -echo $VERSION -exit 1 - -# Figure out which branch we're on. Prefer $TRAVIS_BRANCH, if set, since -# Travis leaves us at detached HEAD and `git rev-parse` just returns "HEAD". -readonly BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)} -declare -a PUBTARGETS=(${GITHASH} ${VERSION} ${BRANCH}) - -# usage: run_go_build -run_go_build() { - local bin_suffix="" - local -r output_name=$(basename $(cd "${1}" ; pwd)) - if [ "$(go env GOOS)" = "windows" ]; then - bin_suffix=".exe" - fi - - mkdir -p "${PUBDIR}/bin" - pushd "$2" > /dev/null && go build \ - -ldflags "-X github.com/pulumi/pulumi/pkg/v3/version.Version=${VERSION}" \ - -o "${PUBDIR}/bin/${output_name}${bin_suffix}" \ - "$1" - popd > /dev/null -} - -# usage: copy_package -copy_package() { - local -r module_root="${PUBDIR}/node_modules/${2}" - - mkdir -p "${module_root}" - cp -r "${1}" "${module_root}/" - if [[ -e "${module_root}/node_modules" ]]; then - rm -rf "${module_root}/node_modules" - fi - if [[ -e "${module_root}/tests" ]]; then - rm -rf "${module_root}/tests" - fi -} - -readonly PULUMI_ROOT=$PWD - -# Build binaries -run_go_build "${PULUMI_ROOT}/pkg/cmd/pulumi" "pkg" -run_go_build "${PULUMI_ROOT}/sdk/nodejs/cmd/pulumi-language-nodejs" "sdk" -run_go_build "${PULUMI_ROOT}/sdk/python/cmd/pulumi-language-python" "sdk" -run_go_build "${PULUMI_ROOT}/sdk/dotnet/cmd/pulumi-language-dotnet" "sdk" -run_go_build "${PULUMI_ROOT}/sdk/go/pulumi-language-go" "sdk" - -# Copy over the language and dynamic resource providers. -cp "${ROOT}/sdk/nodejs/dist/pulumi-resource-pulumi-nodejs" "${PUBDIR}/bin/" -cp "${ROOT}/sdk/python/dist/pulumi-resource-pulumi-python" "${PUBDIR}/bin/" -cp "${ROOT}/sdk/nodejs/dist/pulumi-analyzer-policy" "${PUBDIR}/bin/" -cp "${ROOT}/sdk/python/dist/pulumi-analyzer-policy-python" "${PUBDIR}/bin/" -cp "${ROOT}/sdk/python/cmd/pulumi-language-python-exec" "${PUBDIR}/bin/" - -# Copy packages -copy_package "${ROOT}/sdk/nodejs/bin/." "@pulumi/pulumi" - -# Tar up the file and then print it out for use by the caller or script. -tar -czf "${PUBFILE}" -C ${PUBDIR} . -echo ${PUBFILE} ${PUBTARGETS[@]} - -exit 0 diff --git a/scripts/prep-for-goreleaser.sh b/scripts/prep-for-goreleaser.sh index 6c29c5d85..63ef2b39a 100755 --- a/scripts/prep-for-goreleaser.sh +++ b/scripts/prep-for-goreleaser.sh @@ -11,8 +11,13 @@ go mod download popd cp sdk/nodejs/dist/pulumi-resource-pulumi-nodejs . -cp sdk/nodejs/dist/pulumi-resource-pulumi-nodejs . +cp sdk/nodejs/dist/pulumi-resource-pulumi-nodejs.cmd . cp sdk/python/dist/pulumi-resource-pulumi-python . +cp sdk/python/dist/pulumi-resource-pulumi-python.cmd . +cp sdk/python/dist/pulumi-python3-shim.cmd . +cp sdk/python/dist/pulumi-python-shim.cmd . cp sdk/nodejs/dist/pulumi-analyzer-policy . +cp sdk/nodejs/dist/pulumi-analyzer-policy.cmd . cp sdk/python/dist/pulumi-analyzer-policy-python . +cp sdk/python/dist/pulumi-analyzer-policy-python.cmd . cp sdk/python/cmd/pulumi-language-python-exec . diff --git a/scripts/publish.cmd b/scripts/publish.cmd deleted file mode 100644 index ff647de4b..000000000 --- a/scripts/publish.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -powershell -noprofile -executionPolicy Unrestricted -file "%~dpn0.ps1" %* diff --git a/scripts/publish.ps1 b/scripts/publish.ps1 deleted file mode 100644 index 0a3987f24..000000000 --- a/scripts/publish.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -# publish.ps1 builds and publishes a release. -Set-StrictMode -Version 2.0 -$ErrorActionPreference="Stop" - -$PublishScript="$(go env GOPATH)\src\github.com\pulumi\scripts\ci\publish.ps1" -$BuildSdkScript="$(go env GOPATH)\src\github.com\pulumi\pulumi\scripts\build-sdk.ps1" - -if (!(Test-Path $PublishScript)) { - Write-Error "Missing publish script at $PublishScript" -} - -$ReleaseInfo=& $PSScriptRoot\make_release.ps1 - -$PublishTargets=${ReleaseInfo}.Targets -& $PublishScript $ReleaseInfo.ArchivePath "pulumi/windows/amd64" @PublishTargets - -Remove-Item -Force $ReleaseInfo.ArchivePath - -$Version = "v" + $(pulumictl get version) -& $BuildSdkScript $Version "$(git rev-parse HEAD)" diff --git a/scripts/publish_tgz.sh b/scripts/publish_tgz.sh deleted file mode 100755 index ccfec67a1..000000000 --- a/scripts/publish_tgz.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# publish.sh builds and publishes the tarballs that our other repositories consume. -set -o nounset -set -o errexit -set -o pipefail - -# We run multiple legs on Linux, but only want to publish the tgz's from the one that publishes -# our NPM and PyPI packages. Otherwise, we may race with other legs when publishing to S3 which -# leads to issues about values being out of range. -if [ "${TRAVIS_OS_NAME:-}" = "linux" ] && [ "${TRAVIS_PUBLISH_PACKAGES:-}" != "true" ]; then - exit 0 -fi - -readonly ROOT=$(dirname "${0}")/.. -readonly PUBLISH="${GOPATH}/src/github.com/pulumi/scripts/ci/publish.sh" -readonly PUBLISH_GOARCH=("amd64") -readonly PUBLISH_PROJECT="pulumi" - -if [[ ! -f "${PUBLISH}" ]]; then - >&2 echo "error: Missing publish script at $PUBLISH" - exit 1 -fi - -readonly OS=$(go env GOOS) - -echo "Publishing SDK build to s3://eng.pulumi.com/:" -for ARCH in "${PUBLISH_GOARCH[@]}"; do - export GOARCH="${ARCH}" - RELEASE_INFO=($($(dirname "${0}")/make_release.sh)) - "${PUBLISH}" ${RELEASE_INFO[0]} "${PUBLISH_PROJECT}/${OS}/${ARCH}" ${RELEASE_INFO[@]:1} -done - -exit 0