This commit is contained in:
41
bin/build
Executable file
41
bin/build
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
dither_dir="${repo_root}/bin/dither"
|
||||
|
||||
pushd "${dither_dir}" >/dev/null
|
||||
bundle install
|
||||
ROOT="${repo_root}/content" KEY="${repo_root}/secret.key" bundle exec rackup -p 4567 &
|
||||
dither_pid=$!
|
||||
popd >/dev/null
|
||||
|
||||
cleanup() {
|
||||
if kill -0 "${dither_pid}" 2>/dev/null; then
|
||||
kill "${dither_pid}" 2>/dev/null || true
|
||||
wait "${dither_pid}" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
for _ in {1..50}; do
|
||||
if (echo >/dev/tcp/localhost/4567) >/dev/null 2>&1; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
if [[ "${ready:-0}" -ne 1 ]]; then
|
||||
echo "dither server did not start on port 4567" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "${repo_root}" >/dev/null
|
||||
rm -rf public
|
||||
HUGO_PARAMS_GIT_COMMIT="$(git rev-parse HEAD)" \
|
||||
DITHER_SERVER=http://localhost:4567 \
|
||||
hugo --minify
|
||||
find public -name "*.enc" -type f -delete
|
||||
find public/elsewhere -name "*.gmi" -type f -delete
|
||||
popd >/dev/null
|
||||
Reference in New Issue
Block a user