From 805c0a7b9d252a5e588c063fff84e34b1b0f637b Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 10 Oct 2026 05:29:54 +0300 Subject: Added deploy script and some other stuff --- deploy.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 deploy.sh (limited to 'deploy.sh') diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..7953b10 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +SERVER="website@kyren.codes" +REMOTE_DIR="/var/lib/website" + +echo "Generating Tailwind and Templ..." + +templ generate +tailwindcss -i ./public/styles/main.css -o ./public/styles/style.css + +echo "Cross compiling Golang binary..." +GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o website . + +echo "Copying binary to server..." +rsync -avzP --delete website ${SERVER}:${REMOTE_DIR}/website.new + +echo "Swapping to new binary" +ssh ${SERVER} << 'EOF' + cp /var/lib/website/website /var/lib/website/website.old 2>/dev/null || true + mv /var/lib/website/website.new /var/lib/website/website + chmod +x /var/lib/website/website + systemctl --user restart website || sudo systemctl restart website + # rm /var/lib/website/website.old +EOF + +echo "Finished deploying new binary" -- cgit v1.3.1