Change deploy script to use assets from npm

This commit is contained in:
Jamie Wong 2018-09-04 20:50:30 -07:00
parent a0eba8d434
commit 64e290c9fc
3 changed files with 24 additions and 20 deletions

View File

@ -59,13 +59,16 @@ Try `speedscope sample/profiles/stackcollapse/simple.txt`, which should immediat
## Deploying the website ## Deploying the website
This step must follow the "Publish to npm" step, since it uses assets from
the npm publish.
https://www.speedscope.app/ is hosted on GitHub pages, and is published via pushing https://www.speedscope.app/ is hosted on GitHub pages, and is published via pushing
to the `gh-pages` branch. The `gh-pages` branch has totally different contents than to the `gh-pages` branch. The `gh-pages` branch has totally different contents than
other branches of this repository: https://github.com/jlfwong/speedscope/tree/gh-pages. other branches of this repository: https://github.com/jlfwong/speedscope/tree/gh-pages.
It's populated by a deploy script which is invoked by running `npm run deploy` script. It's populated by a deploy script which is invoked by running `npm run deploy` script. This populate a directory with assets pulled from npm, and
This will do a build of the static resources, and boot a local server for you to test boot a local server for you to test the compiled assets. Please do not skip
the compiled assets. Please do not skip the manual testing in this step. the manual testing in this step.
If everything looks good, you should be able to hit Ctrl+C, and you should see this prompt: If everything looks good, you should be able to hit Ctrl+C, and you should see this prompt:
@ -80,8 +83,10 @@ which includes the version, the date, and the commit of the deploy.
## Upload a release to GitHub ## Upload a release to GitHub
To make a zipfile suitable for uploading to GitHub as a release, run `scripts/prepare-zip-file.sh`. Note that this step must follow the "Publish to npm" step, This step must follow the "Publish to npm" step, since it uses assets from
since it uses assets from the npm publish. the npm publish.
To make a zipfile suitable for uploading to GitHub as a release, run `scripts/prepare-zip-file.sh`.
Once that's done, you should have a zip file in `dist/release/` Once that's done, you should have a zip file in `dist/release/`

View File

@ -1,26 +1,28 @@
#!/bin/bash #!/bin/bash
# #
# type check, do a release build, then do a shallow clone of the # Do a shallow clone of the repository into a temporary directory and copy the
# repository into a temporary directory and copy the release build # artifacts pulled from npm into the shallow clone to commit & push to the
# artifacts into there to commit & push to the gh-pages branch # gh-pages branch.
set -euxo pipefail set -euxo pipefail
OUTDIR=`pwd`/dist/release SRCDIR=`pwd`
echo $OUTDIR OUTDIR=`mktemp -d -t speedscope-unpacked`
./scripts/build-release.sh # Untar the package
pushd "$OUTDIR"
PACKEDNAME=`npm pack speedscope | tail -n1`
tar -xvvf "$PACKEDNAME"
# Create a shallow clone of the repository # Create a shallow clone of the repository
TMPDIR=`mktemp -d -t speedscope-release` TMPDIR=`mktemp -d -t speedscope-deploy`
echo "Entering $TMPDIR"
pushd "$TMPDIR" pushd "$TMPDIR"
git clone --depth 1 git@github.com:jlfwong/speedscope.git -b gh-pages git clone --depth 1 git@github.com:jlfwong/speedscope.git -b gh-pages
# Copy the build artifacts into the shallow clone # Copy the build artifacts into the shallow clone
pushd speedscope pushd speedscope
rm -rf * rm -rf *
cp -R "$OUTDIR"/* . cp -R "$OUTDIR"/package/dist/release/** .
# Set the CNAME record # Set the CNAME record
echo www.speedscope.app > CNAME echo www.speedscope.app > CNAME
@ -35,17 +37,14 @@ function ctrl_c() {
if [[ $REPLY =~ ^yes$ ]] if [[ $REPLY =~ ^yes$ ]]
then then
git add --all git add --all
git commit -m 'Release' git commit -m "Deploy $PACKEDNAME"
git push origin HEAD:gh-pages git push origin HEAD:gh-pages
popd
rm -rf "$TMPDIR" rm -rf "$TMPDIR"
exit 0 exit 0
else else
set +x set +x
echo "Aborting release." echo "Aborting release."
set -x set -x
popd
rm -rf "$TMPDIR" rm -rf "$TMPDIR"
exit 1 exit 1
fi fi

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Prepare a mock installation of speedscope to test it before the actual npm # Create a zip file containing a standalone copy of speedscope
# publish # based on the contents of the package published to npm
set -euxo pipefail set -euxo pipefail