#!/bin/bash # Build the J621 desktop packages and publish them to the update feed. # # Locally the feed is deploy/data/desktop, which the frontend nginx mounts # read-only and serves at /desktop/. With --host the same directory is also # copied to a remote deploy checkout (rsync, or tar over ssh when the server # has no rsync). electron-updater reads latest-linux.yml / latest.yml from # there; the feed URL comes from desktop/electron-builder.yml. # # Usage: ./push_desktop.sh [--win] [--no-build] [--host user@server:/path] # --win also cross-build the Windows NSIS installer (needs wine) # --no-build publish what is already in desktop/release/ # --host remote deploy checkout, e.g. jakerasp:/home/jake/servers/J621 set -euo pipefail cd "$(dirname "$0")/.." BUILD=1 WIN=0 REMOTE="" while [ $# -gt 0 ]; do case "$1" in --win) WIN=1 ;; --no-build) BUILD=0 ;; --host) REMOTE="${2:?--host needs user@server:/path}"; shift ;; *) echo "usage: $0 [--win] [--no-build] [--host user@server:/path]" >&2 exit 2 ;; esac shift done if [ -n "$REMOTE" ] && [ "$REMOTE" = "${REMOTE#*:}" ]; then echo "--host needs user@server:/path (got '$REMOTE')" >&2 exit 2 fi if [ "$BUILD" = 1 ]; then echo "==> Building Linux packages (deb + pacman) ..." npm --prefix desktop run dist:linux if [ "$WIN" = 1 ]; then echo "==> Cross-building the Windows installer (wine) ..." npm --prefix desktop run dist:win fi fi FEED=deploy/data/desktop mkdir -p "$FEED" shopt -s nullglob deb=(desktop/release/*.deb) zst=(desktop/release/*.pkg.tar.zst) linux_meta=(desktop/release/latest-linux.yml) win_exe=("desktop/release/J621 Setup "*.exe) win_meta=(desktop/release/latest.yml) blockmaps=(desktop/release/*.blockmap) if [ "${#deb[@]}" -eq 0 ] && [ "${#zst[@]}" -eq 0 ]; then echo "No artifacts in desktop/release/ — run without --no-build first." >&2 exit 1 fi # Replace the previous release's metadata before copying the new artifacts. rm -f "$FEED"/latest-linux.yml "$FEED"/latest.yml cp -f "${deb[@]}" "${zst[@]}" "${linux_meta[@]}" "$FEED"/ 2>/dev/null || true if [ "${#win_exe[@]}" -gt 0 ]; then cp -f "${win_exe[@]}" "${win_meta[@]}" "${blockmaps[@]}" "$FEED"/ 2>/dev/null || true fi echo "==> Published to $FEED:" ls -1sh "$FEED" | sed 's/^/ /' if [ -n "$REMOTE" ]; then REMOTE_TARGET="${REMOTE%%:*}" REMOTE_ROOT="${REMOTE#*:}" REMOTE_FEED="${REMOTE_ROOT%/}/deploy/data/desktop" echo echo "==> Copying the feed to $REMOTE_TARGET:$REMOTE_FEED ..." transferred=0 if command -v rsync >/dev/null 2>&1; then if rsync -a --info=progress2 "$FEED"/ "$REMOTE_TARGET:$REMOTE_FEED/"; then transferred=1 else echo "==> rsync did not work (missing on the server?); trying tar over ssh ..." fi fi if [ "$transferred" -eq 0 ]; then if ! ssh "$REMOTE_TARGET" "mkdir -p '$REMOTE_FEED'"; then echo "ssh to $REMOTE_TARGET failed; nothing was copied." >&2 exit 1 fi if ! tar -C "$FEED" -cf - . | ssh "$REMOTE_TARGET" "tar -C '$REMOTE_FEED' -xf -"; then echo "Copy to $REMOTE_TARGET:$REMOTE_FEED failed." >&2 exit 1 fi fi echo "==> Feed live at $REMOTE_TARGET:$REMOTE_FEED (no restart needed)." fi echo echo "Served read-only by the frontend nginx at /desktop/ (no restart needed):" echo " https:///desktop/latest-linux.yml"