Files
builds/deploy.sh
2026-03-15 19:47:44 -04:00

37 lines
953 B
Bash

#!/usr/bin/env bash
# Upload a build to Hetzner Object Storage.
# Usage: ./deploy.sh ./dist [version]
#
# If version is omitted, uses the current git short hash.
# Requires: s3cmd configured for Hetzner Object Storage.
set -euo pipefail
BUILD_DIR="${1:?Usage: ./deploy.sh <build-dir> [version]}"
VERSION="${2:-$(git rev-parse --short HEAD 2>/dev/null || date +%s)}"
# Configure these for your setup
BUCKET="s3://ksys-builds"
PREFIX="builds"
SITE_URL="https://builds.kill.systems"
# Hetzner Object Storage endpoint
S3CMD_OPTS="--host=fsn1.your-objectstorage.com --host-bucket=%(bucket)s.fsn1.your-objectstorage.com"
if [[ ! -d "$BUILD_DIR" ]]; then
echo "ERROR: $BUILD_DIR is not a directory"
exit 1
fi
echo "Uploading build $VERSION..."
s3cmd sync \
$S3CMD_OPTS \
--acl-public \
--no-mime-magic \
--guess-mime-type \
"$BUILD_DIR/" \
"${BUCKET}/${PREFIX}/${VERSION}/"
echo ""
echo "Build uploaded:"
echo " ${SITE_URL}/${VERSION}/"