diff --git a/package.json b/package.json index 80d1542..b4b9bcc 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "debug": "DEBUG=1 bun run dev", "dev": "bun run templates && rm -f pub/client/index.js && bun run --hot src/server/index.tsx", "remote:migrate": "bun run scripts/migrate.ts", + "remote:deploy": "./scripts/remote-deploy.sh", "remote:install": "./scripts/remote-install.sh", "remote:logs": "./scripts/remote-logs.sh", "remote:restart": "./scripts/remote-restart.sh", diff --git a/scripts/remote-deploy.sh b/scripts/remote-deploy.sh new file mode 100755 index 0000000..9cba36b --- /dev/null +++ b/scripts/remote-deploy.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Build a release tarball, upload it to the Pi, and install it. +# Usage: bun run remote:deploy + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT_DIR="$SCRIPT_DIR/.." + +source "$ROOT_DIR/scripts/config.sh" + +# Build release tarball +"$ROOT_DIR/scripts/release.sh" + +# Find the tarball +TARBALL=$(ls -1 "$ROOT_DIR"/dist/toes-*.tar.gz 2>/dev/null | head -1) +[ -f "$TARBALL" ] || { echo "ERROR: No tarball found in dist/"; exit 1; } +FILENAME=$(basename "$TARBALL") + +echo "" +echo ">> Uploading $FILENAME to $SSH_HOST" +scp "$TARBALL" "$SSH_HOST:/tmp/$FILENAME" + +echo ">> Installing on $SSH_HOST" +ssh "$SSH_HOST" bash <