speedscope/deploy.sh

68 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# type check, do a release build, then do a shallow clone of the
# repository into a temporary directory and copy the release build
# artifacts into there to commit & push to the gh-pages branch
# Fail on first error
set -e
OUTDIR=`pwd`/dist/release
echo $OUTDIR
# Typecheck
node_modules/.bin/tsc --noEmit
# Clean out the release directory
rm -rf "$OUTDIR"
mkdir -p "$OUTDIR"
2018-04-05 10:50:45 +03:00
# Place info about the current commit into the build dir to easiy identify releases
date > "$OUTDIR"/release.txt
git rev-parse HEAD >> "$OUTDIR"/release.txt
# Build the compiled assets
2018-04-05 10:58:32 +03:00
node_modules/.bin/parcel build index.html --out-dir "$OUTDIR" --public-url /speedscope/ --detailed-report
# Create a shallow clone of the repository
TMPDIR=`mktemp -d -t speedscope-release`
echo "Entering $TMPDIR"
pushd "$TMPDIR"
git clone --depth 1 git@github.com:jlfwong/speedscope.git -b gh-pages
# Copy the build artifacts into the shallow clone
2018-04-05 10:58:32 +03:00
pushd speedscope
rm -rf *
cp -R "$OUTDIR"/* .
2018-04-05 10:58:32 +03:00
popd
# Set up a handler to run on Ctrl+C
trap ctrl_c INT
function ctrl_c() {
read -p "Commit release? [yes/no]: "
if [[ $REPLY =~ ^yes$ ]]
then
2018-04-05 10:58:32 +03:00
pushd speedscope
git add --all
git commit -m 'Release'
git push origin HEAD:gh-pages
popd
2018-04-05 10:58:32 +03:00
popd
rm -rf "$TMPDIR"
exit 0
else
echo "Aborting release."
popd
rm -rf "$TMPDIR"
exit 1
fi
}
# Start a local server for verification of the build
echo
echo
2018-04-05 10:58:32 +03:00
echo "Build complete. Starting server on http://localhost:4444/speedscope/"
echo "Hit Ctrl+C to complete or cancel the release"
echo
echo
python -m SimpleHTTPServer 4444 .