selectively build assets during deploy

pull/5100/head
Thibault Duplessis 2019-05-11 14:04:35 +07:00
parent a01884c78b
commit 4d1966da13
2 changed files with 28 additions and 24 deletions

View File

@ -1,20 +1,22 @@
#!/bin/sh -e
. bin/lilarc
mode=$1
if [ -z $mode ]; then
to=$1
mode=${2-build} # build | css | js
if [ -z $to ]; then
echo "Empty deploy target"
exit 1
elif [ $mode = "main" ]; then
elif [ $to = "main" ]; then
REMOTE="leess"
REMOTE_DIR="/home/lichess-deploy"
elif [ $mode = "stage" ]; then
elif [ $to = "stage" ]; then
REMOTE="khiaw"
REMOTE_DIR="/home/lichess-stage"
elif [ $mode = "greco" ]; then
elif [ $to = "greco" ]; then
REMOTE="greco"
REMOTE_DIR="/home/lichess-deploy"
elif [ $mode = "leess" ]; then
elif [ $to = "leess" ]; then
REMOTE="leess"
REMOTE_DIR="/home/lichess-deploy"
else
@ -22,9 +24,9 @@ else
exit 1
fi
lilalog "Deploy assets to $mode server $REMOTE:$REMOTE_DIR"
lilalog "Deploy prod $mode assets to $to server $REMOTE:$REMOTE_DIR"
./ui/build prod
./ui/build prod $mode
lilalog "Rsync scripts"
rsync --archive --no-o --no-g --progress --exclude '*.dev.css' public $REMOTE:$REMOTE_DIR
@ -35,9 +37,9 @@ rsync --archive --no-o --no-g --progress --exclude '*.dev.css' public $REMOTE:$R
lilalog "Deploy complete"
if [ $mode = "main" ]; then
if [ $to = "main" ]; then
xdg-open https://lichess.org/dev/cli
fi
if [ $mode = "stage" ]; then
if [ $to = "stage" ]; then
xdg-open https://lichess.dev/dev/cli
fi

View File

@ -1,7 +1,7 @@
#!/bin/bash -ea
target=${1-dev}
mode=${2-build} # use "upgrade" to upgrade all deps
mode=${2-build} # build | upgrade | css | js
echo "building ui modules with target=$target and mode=$mode"
echo "node: $(node --version)"
@ -36,23 +36,25 @@ build() {
}
if [ $mode != "upgrade" ]; then
if [ $mode != "upgrade" ] && [ $mode != "js" ]; then
echo "build css"
(cd ui && gulp "css-$target")
touch public/css/*.min.css # they have an off by 12h modification time!!
fi
if type -p parallel; then # parallel execution!
if [ -z "$P_OPTS" -a ! -e ~/.parallel/config ]; then
P_OPTS="-j+4 --halt 2"
[ "$TRAVIS" = "true" ] || P_OPTS+=" --bar"
if [ $mode != "css" ]; then
if type -p parallel; then # parallel execution!
if [ -z "$P_OPTS" -a ! -e ~/.parallel/config ]; then
P_OPTS="-j+4 --halt 2"
[ "$TRAVIS" = "true" ] || P_OPTS+=" --bar"
fi
set -x
parallel --gnu $P_OPTS build_ts ::: $ts_apps1
parallel --gnu $P_OPTS build_ts ::: $ts_apps2
parallel --gnu $P_OPTS build ::: $apps
else # sequential execution
echo "For faster builds, install GNU parallel."
for app in $ts_apps1 $ts_apps2; do (build_ts $app); done
for app in $apps; do (build $app); done
fi
set -x
parallel --gnu $P_OPTS build_ts ::: $ts_apps1
parallel --gnu $P_OPTS build_ts ::: $ts_apps2
parallel --gnu $P_OPTS build ::: $apps
else # sequential execution
echo "For faster builds, install GNU parallel."
for app in $ts_apps1 $ts_apps2; do (build_ts $app); done
for app in $apps; do (build $app); done
fi