oliverdavies.uk/run
Oliver Davies 8e8a4fe980 Add publish task
Add a `publish` task to generate a production version of the website and
upload it via rsync.
2024-01-03 23:06:04 +00:00

62 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -o nounset
set -o pipefail
function clean {
rm -fr output_*/ source/build/
}
function generate {
local args=()
if [[ "${APP_ENV:-}" == "production" ]]; then
args=(--env="prod")
else
args=(--server --watch)
fi
sculpin generate "${args[@]}"
}
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function npm:build:css {
local args=()
if [[ "${NODE_ENV:-}" == "production" ]]; then
args=(--minify)
else
args=(--watch)
fi
npx tailwindcss \
--config assets/tailwind.config.ts \
--output source/build/tailwind.css "${args[@]}"
}
function publish {
export NODE_ENV=production
export APP_ENV=production
git stash
clean
npm:build:css
generate
rsync --archive --verbose --compress --update --delete \
output_prod/ ssh.oliverdavies.uk:/srv/oliverdavies.uk-sculpin
git stash pop
}
TIMEFORMAT="Task completed in %3lR"
time "${@:-help}"