forked from vitessce/vitessce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-demos.sh
executable file
·85 lines (67 loc) · 2.45 KB
/
push-demos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -o errexit
set -o pipefail
BRANCH=`git rev-parse --abbrev-ref HEAD`
DATE=`date "+%Y-%m-%d"`
HASH=`git rev-parse --short HEAD`
BUCKET="vitessce-data"
DEMO_URL_PATH="$BUCKET/demos/$DATE/$HASH"
ROOT_DOCS_URL_PATH="$BUCKET/docs-root/$DATE/$HASH"
VERSIONED_DOCS_URL_PATH="docs/$DATE/$HASH"
die() { set +v; echo "$*" 1>&2 ; exit 1; }
git diff --quiet || die 'Uncommitted changes: Stash or commit before pushing.'
# Update version information.
echo '{
"note": "This file is regenerated by push-demo.sh.",
"branch": "'$BRANCH'",
"date": "'$DATE'",
"hash": "'$HASH'"
}' > src/version.json
# Build demo...
npm run build-demo:prod
# Finalize demo...
DEMO_DIST_DIR='dist-demo/'
# and add an error page for dev.vitessce.io
cp error.html $DEMO_DIST_DIR
# and add a robots.txt since we do not want to publicize dev.vitessce.io
echo 'User-agent: *
Disallow: /' > $DEMO_DIST_DIR/robots.txt
# and push to S3.
aws s3 cp --recursive $DEMO_DIST_DIR s3://$DEMO_URL_PATH
DEMO_TARGET_URL="https://s3.amazonaws.com/$DEMO_URL_PATH/index.html"
echo "- $DATE: [$BRANCH]($DEMO_TARGET_URL)" >> DEMOS.md
echo "Deployed dev site"
# Build library...
npm run build-lib:esm
# Build docs site...
cd docs
npm install
cd ..
npm link docs/node_modules/react
cd docs
# We need to build the docs site twice:
# 1. With baseUrl: "/" which may be copied to vitessce.io (by running ./copy-prod.sh).
# 2. With baseUrl: "/vitessce-data/docs/2020-12-19/b416e16/" for the staging and versioned access.
export VITESSCE_DOCS_BASE_URL="/"
npm run build-root
export VITESSCE_DOCS_BASE_URL="/$VERSIONED_DOCS_URL_PATH/"
npm run build-versioned
# Un-set the base url exported variable.
unset VITESSCE_DOCS_BASE_URL
# The following lines are relative to docs/ directory.
ROOT_DIST_DIR='dist-root/'
VERSIONED_DIST_DIR='dist-versioned/'
# and add an error page for vitessce.io...
cp ../error.html $ROOT_DIST_DIR
cp ../error.html $VERSIONED_DIST_DIR
# and push to S3.
aws s3 cp --recursive $ROOT_DIST_DIR s3://$ROOT_DOCS_URL_PATH
aws s3 cp --recursive $VERSIONED_DIST_DIR s3://$BUCKET/$VERSIONED_DOCS_URL_PATH
VERSIONED_TARGET_URL="http://$BUCKET.s3-website-us-east-1.amazonaws.com/$VERSIONED_DOCS_URL_PATH/index.html"
COPY_TARGET_URL="https://s3.amazonaws.com/$ROOT_DOCS_URL_PATH/index.html"
echo "- $DATE: [$BRANCH]($VERSIONED_TARGET_URL)" >> ../DOCS.md
echo "Deployed docs site"
echo "Copy dev to $DEMO_TARGET_URL"
echo "Copy docs to $COPY_TARGET_URL"
# Open in browser and see if it works:
open "$VERSIONED_TARGET_URL"