summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
authorKyren223 <contact@kyren.codes>2026-10-10 05:29:54 +0300
committerKyren223 <contact@kyren.codes>2026-10-10 05:29:54 +0300
commit805c0a7b9d252a5e588c063fff84e34b1b0f637b (patch)
treed8c0737309bfae3ba9e7059d1a857f8c00850128 /deploy.sh
parent332051138391a86325e4e780895aa4148f81c5d5 (diff)
Added deploy script and some other stuff
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh27
1 files changed, 27 insertions, 0 deletions
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"