-
Notifications
You must be signed in to change notification settings - Fork 1
/
_deploy.sh
executable file
·29 lines (20 loc) · 1.08 KB
/
_deploy.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
#!/bin/sh
# Deploy site to server
set -e
umask 022
# Use a temporary directory for build files
TMPDIR="$(mktemp -d)"
# Calculate hashes to append as query parameters to the paths in /static
echo 'Calculating hashes…'
find static -type d -exec mkdir -p _data/hashes/{} \; >/dev/null
# This one replaces "." with "-" and prepends it if filename starts with a digit
find static -type f -not -name '.DS_Store' \
-exec sh -c 'echo "\"$(xxhsum -H0 "$1" | cut -d " " -f 1 | xxd -r -p | base64 | sed s/=//g | tr +/ -_)\"" > "_data/hashes/$(dirname "$1")/$(basename "$1" | cut -c 1 | sed "s/[[:digit:]]/-/" | grep "\-")$(basename "$1" | tr . -).json"' sh {} \;
cobalt build -d "$TMPDIR"
find "$TMPDIR" -name '*.css' -exec css-html-js-minify --quiet --overwrite {} \;
echo 'CSS minified.'
echo 'Precompressing…'
find -E "$TMPDIR" -type f -not '(' -regex '.*\.(png|zip|7z|jpeg|webp|br|gz|zst|html)' -or -size 1 ')' -exec ect -9 -gzip --mt-deflate {} \; -exec brotli {} \;
chmod -R a+rX "$TMPDIR"
echo 'Authenticating to webserver…'
rsync -r --progress --del "$TMPDIR"/ gtrr.artemislena.eu:/srv/www/gtrr/