2017-09-07 20:07:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# make_release.sh will create a build package ready for publishing.
|
2017-09-22 04:10:33 +02:00
|
|
|
set -o nounset -o errexit -o pipefail
|
2017-09-07 20:07:52 +02:00
|
|
|
|
2017-09-08 06:52:58 +02:00
|
|
|
ROOT=$(dirname $0)/..
|
2017-09-07 20:07:52 +02:00
|
|
|
PUBDIR=$(mktemp -du)
|
2017-11-02 23:02:43 +01:00
|
|
|
GITHASH=$(git rev-parse HEAD)
|
|
|
|
PUBFILE=$(dirname ${PUBDIR})/${GITHASH}.tgz
|
2018-03-19 22:24:52 +01:00
|
|
|
VERSION=$($ROOT/scripts/get-version)
|
2017-09-21 01:18:17 +02:00
|
|
|
|
|
|
|
# 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)}
|
2017-11-02 23:02:43 +01:00
|
|
|
declare -a PUBTARGETS=(${GITHASH} ${VERSION} ${BRANCH})
|
2017-09-22 04:10:33 +02:00
|
|
|
|
|
|
|
# usage: run_go_build <path-to-package-to-build>
|
|
|
|
function run_go_build() {
|
2017-09-22 20:29:03 +02:00
|
|
|
local bin_suffix=""
|
|
|
|
local output_name=$(basename $(cd "$1" ; pwd))
|
2017-09-22 04:10:33 +02:00
|
|
|
if [ "$(go env GOOS)" = "windows" ]; then
|
2017-09-22 20:29:03 +02:00
|
|
|
bin_suffix=".exe"
|
2017-09-22 04:10:33 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${PUBDIR}/bin"
|
2017-12-14 06:38:11 +01:00
|
|
|
go build \
|
|
|
|
-ldflags "-X github.com/pulumi/pulumi/pkg/version.Version=${VERSION}" \
|
|
|
|
-o "${PUBDIR}/bin/${output_name}${bin_suffix}" \
|
|
|
|
"$1"
|
2017-09-22 04:10:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# usage: copy_package <path-to-module> <module-name>
|
|
|
|
copy_package() {
|
2017-11-17 23:16:03 +01:00
|
|
|
local module_root=${PUBDIR}/node_modules/$2
|
2017-09-22 04:10:33 +02:00
|
|
|
|
2017-11-17 23:16:03 +01:00
|
|
|
mkdir -p "${module_root}"
|
|
|
|
cp -R "$1" "${module_root}/"
|
|
|
|
if [ -e "${module_root}/node_modules" ]; then
|
|
|
|
rm -rf "${module_root}/node_modules"
|
2017-09-22 04:10:33 +02:00
|
|
|
fi
|
2017-11-17 23:16:03 +01:00
|
|
|
if [ -e "${module_root}/tests" ]; then
|
|
|
|
rm -rf "${module_root}/tests"
|
2017-11-12 01:20:56 +01:00
|
|
|
fi
|
2017-09-22 04:10:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Build binaries
|
2017-09-22 20:29:03 +02:00
|
|
|
run_go_build "${ROOT}"
|
2018-02-18 17:11:14 +01:00
|
|
|
run_go_build "${ROOT}/sdk/nodejs/cmd/pulumi-language-nodejs"
|
2018-03-17 18:41:37 +01:00
|
|
|
run_go_build "${ROOT}/sdk/python/cmd/pulumi-language-python"
|
2018-06-10 01:16:35 +02:00
|
|
|
run_go_build "${ROOT}/sdk/go/pulumi-language-go"
|
2017-09-22 04:10:33 +02:00
|
|
|
|
2018-03-17 18:41:37 +01:00
|
|
|
# Copy over the language and dynamic resource providers.
|
2018-02-12 04:22:23 +01:00
|
|
|
cp ${ROOT}/sdk/nodejs/dist/pulumi-resource-pulumi-nodejs ${PUBDIR}/bin/
|
2018-03-17 18:41:37 +01:00
|
|
|
cp ${ROOT}/sdk/python/cmd/pulumi-language-python-exec ${PUBDIR}/bin/
|
2017-09-22 04:10:33 +02:00
|
|
|
|
|
|
|
# Copy packages
|
2018-02-13 01:16:16 +01:00
|
|
|
copy_package "${ROOT}/sdk/nodejs/bin/." "@pulumi/pulumi"
|
2017-09-07 20:07:52 +02:00
|
|
|
|
|
|
|
# Tar up the file and then print it out for use by the caller or script.
|
|
|
|
tar -czf ${PUBFILE} -C ${PUBDIR} .
|
|
|
|
echo ${PUBFILE} ${PUBTARGETS[@]}
|