File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 "test:coverage" : " NODE_ENV=test c8 mocha tests --test-reporter=spec" ,
1111 "test:coverage:ci" : " NODE_ENV=test c8 mocha tests --test-reporter=spec --timeout=20000" ,
1212 "build" : " npm run build:ts; npm run build:webpack" ,
13+ "deploy" : " bash scripts/deploy.sh" ,
1314 "build:ts" : " tsc" ,
1415 "build:webpack" : " webpack" ,
1516 "lint" : " eslint ." ,
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Deploy to gh-pages.
3+ set -euo pipefail
4+
5+ scriptsFolder=$( cd $( dirname " $0 " ) ; pwd)
6+ cd " $scriptsFolder /.."
7+
8+ MAIN_BRANCH=" main"
9+ BRANCH=" $( git rev-parse --abbrev-ref HEAD) "
10+ if [ " $BRANCH " != " $MAIN_BRANCH " ]; then
11+ echo " ERROR: Deploy only allowed from '$MAIN_BRANCH ' (current: $BRANCH )."
12+ exit 1
13+ fi
14+
15+ if [ -n " $( git status --porcelain) " ]; then
16+ echo " ERROR: Working tree is not clean."
17+ git status --short
18+ exit 1
19+ fi
20+
21+ if [ ! -d dist/.git ]; then
22+ echo " ERROR: dist/ is not a gh-pages checkout. Run 'npm run setup' first."
23+ exit 1
24+ fi
25+
26+ COMMIT_SHORT=" $( git rev-parse --short HEAD) "
27+ COMMIT_FULL=" $( git rev-parse HEAD) "
28+ echo " Deploying commit $COMMIT_SHORT ..."
29+
30+ echo " Building..."
31+ npm run build
32+ echo " Build OK."
33+
34+ # Generate version.json
35+ cat > dist/version.json << VEOF
36+ {
37+ "commit": "$COMMIT_FULL ",
38+ "commitShort": "$COMMIT_SHORT ",
39+ "branch": "$MAIN_BRANCH ",
40+ "buildDate": "$( date -u +%Y-%m-%dT%H:%M:%SZ) "
41+ }
42+ VEOF
43+ git -C dist add -A
44+ if git -C dist diff --cached --quiet; then
45+ echo " No changes in dist/ — nothing to deploy."
46+ exit 0
47+ fi
48+ git -C dist commit -m " deploy $COMMIT_SHORT ($COMMIT_FULL )"
49+ git -C dist push
50+
51+ echo " Deployed $COMMIT_SHORT to gh-pages."
You can’t perform that action at this time.
0 commit comments