pulumi/scripts/publish.sh
joeduffy fc1cd2c01e Make a publish script; fix sed for multi-OS compat
This change creates a scripts/ folder, moves our existing shell
script, gocover.sh, underneath it, and factors the publish logic
out of the Makefile and into the publish.sh file.

The syntax for sed differs between Mac OS X and GNU versions of
the tool, which is rather annoying.  This fixes it by leveraging
the fact that `sed -i.bak ...` works, although we now need to
clean up the *.bak file left behind.  (No big deal and way better
than maintaining OS-dependent logic.)
2017-07-21 09:37:14 -07:00

39 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
set -ex
LUMIROOT=/usr/local/lumi
LUMILIB=${LUMIROOT}/packs
PUBDIR=$(mktemp -du)
GITVER=$(git rev-parse HEAD)
PUBFILE=$(dirname ${PUBDIR})/${GITVER}.tgz
PUBTARGET=s3://eng.pulumi.com/releases/${GITVER}.tgz
ROOT=$(dirname $0)/..
# Make sure the repo isn't dirty.
git diff-index --quiet HEAD -- || \
test -n "${PUBFORCE}" || \
(echo "error: Cannot publish a dirty repo; set PUBFORCE=true to override" && exit 99)
# If it isn't, or publication was forced, do it.
echo Publishing to: ${PUBTARGET}
mkdir -p ${PUBDIR}/cmd ${PUBDIR}/packs
# Copy the binaries and packs.
cp ${GOPATH}/bin/lumi ${PUBDIR}/cmd
cp ${ROOT}/cmd/lumijs/lumijs ${PUBDIR}/cmd
cp -R ${ROOT}/cmd/lumijs/bin/ ${PUBDIR}/cmd/lumijs.bin
cp -R ${ROOT}/cmd/lumijs/node_modules/ ${PUBDIR}/cmd/lumijs.bin/node_modules/
cp -R ${LUMILIB}/lumirt ${PUBDIR}/packs/lumirt
cp -R ${LUMILIB}/lumijs ${PUBDIR}/packs/lumijs
cp -R ${LUMILIB}/lumi ${PUBDIR}/packs/lumi
# Fix up the LumiJS script so that it can run in place.
sed -i.bak 's/"\.\/bin\/cmd"/"\.\/lumijs.bin\/cmd"/g' ${PUBDIR}/cmd/lumijs
rm ${PUBDIR}/cmd/lumijs.bak
# Tar up the release and upload it to our S3 bucket.
tar -czf ${PUBFILE} -C ${PUBDIR} .
aws s3 cp ${PUBFILE} ${PUBTARGET}