pulumi/scripts/make_release.sh
CyrusNajmabadi e7c0e4cdaa
Make many fixes to closure serialization (#944)
Make many fixes to closure serialization

Primary things that i've done as part of this change:

    Added support for cyclic objects.
    Properly serialize objects that are shared across different function. previously you would get multiple copies, now you properly reference the same copy.
    Remove the usages of 'hashes' for functions. Because we track identity of objects, we no longer need them.
    Serialize properties of functions (if they have any).
    Handle Objects/Functions with different __proto__s than normal. i.e. classes/constructors. but also anything the user may have done themselves to the object.
    Handle generator functions.
    Handle functions with 'computed' names.
    Handle functions with 'symbol' names.
    Handle serializing Promises as Promises.
    Removed the dual Closure/AsyncClosure tree. One existed solely so we could have a tree without promises (for use in testing maybe?). Because this all exists in a part of our codebase that is entirely async, it's fine to have promises in the tree, and to await them when serializing the Closure to a string.
    Handle serializing class-constructors and methods. Including properly handling 'super' calls.
2018-03-01 00:32:01 -08:00

64 lines
2 KiB
Bash
Executable file

#!/bin/bash
# make_release.sh will create a build package ready for publishing.
set -o nounset -o errexit -o pipefail
ROOT=$(dirname $0)/..
PUBDIR=$(mktemp -du)
GITHASH=$(git rev-parse HEAD)
PUBFILE=$(dirname ${PUBDIR})/${GITHASH}.tgz
VERSION=$(git describe --tags --dirty 2>/dev/null)
# 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".
BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
declare -a PUBTARGETS=(${GITHASH} ${VERSION} ${BRANCH})
# usage: run_go_build <path-to-package-to-build>
function run_go_build() {
local bin_suffix=""
local output_name=$(basename $(cd "$1" ; pwd))
if [ "$(go env GOOS)" = "windows" ]; then
bin_suffix=".exe"
fi
mkdir -p "${PUBDIR}/bin"
go build \
-ldflags "-X github.com/pulumi/pulumi/pkg/version.Version=${VERSION}" \
-o "${PUBDIR}/bin/${output_name}${bin_suffix}" \
"$1"
}
# usage: copy_package <path-to-module> <module-name>
copy_package() {
local 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
}
# Build binaries
run_go_build "${ROOT}"
run_go_build "${ROOT}/sdk/nodejs/cmd/pulumi-language-nodejs"
# Copy over the language and dynamic resource provider
cp ${ROOT}/sdk/nodejs/dist/pulumi-language-nodejs-exec ${PUBDIR}/bin/
cp ${ROOT}/sdk/nodejs/dist/pulumi-resource-pulumi-nodejs ${PUBDIR}/bin/
# Copy over our custom Node plugin
mkdir -p ${PUBDIR}/bin/$(node --version)
cp ${ROOT}/sdk/nodejs/runtime/native/build/Release/nativeruntime-v0.11.0.node ${PUBDIR}/bin/$(node --version)/nativeruntime-v0.11.0.node
# 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[@]}