-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdo_build.sh
More file actions
executable file
·44 lines (34 loc) · 1.56 KB
/
Copy pathdo_build.sh
File metadata and controls
executable file
·44 lines (34 loc) · 1.56 KB
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
#!/bin/bash
set -e
# Load build env if present
if [ -f build.env ]; then
source build.env
fi
TRUSTED_HOST=${TRUSTED_HOST:?"TRUSTED_HOST must be set (e.g. https://www.glowscript.org)"}
BUCKET=${BUCKET:-"gs://rswvprunner"}
echo "=== Building rsWVPRunner ==="
echo "Trusted host: $TRUSTED_HOST"
echo "Bucket: $BUCKET"
# Assemble deploy/ from ONLY the assets the runner serves in production.
# Everything else in the repo is build/dev-only and must never be published:
# build-tools/ __pycache__/ build.env* build_package.py do_build.sh serve.sh
# README.md config.json .vscode/ .DS_Store and other dotfiles, plus the
# untrusted/ template, editor backups and samples.
rm -rf deploy
mkdir -p deploy/untrusted
# Runtime asset directories (served as-is).
cp -r css lib package shaders deploy/
# Runtime root files.
cp favicon.ico index.html deploy/
# untrusted/: only the files the runner loads (not the template/backups/samples).
cp untrusted/run.js deploy/untrusted/
[ -d untrusted/images ] && cp -r untrusted/images deploy/untrusted/
# Generate run.html from template (TRUSTED_HOST baked in) and stamp run.js.
sed "s|TRUSTED_HOST_TEMPLATE|$TRUSTED_HOST|g" untrusted/run.html.template > deploy/untrusted/run.html
BUILD_DATE=$(date +%Y%m%d%H%M)
sed -i '' "s|PACKAGE_BUILD_TEMPLATE|$BUILD_DATE|g" deploy/untrusted/run.js
# Upload to GCS. NOTE: cp is additive — it does not remove objects already in the
# bucket, so stale files from earlier full-repo deploys must be cleaned out once.
echo "Uploading to $BUCKET..."
gsutil -m cp -r deploy/* $BUCKET/
echo "=== Deploy complete! ==="