Files
J621/deploy/build_desktop.sh
T
JakeBreath 3183a3bece Prune old desktop builds from release/ on every build
build_desktop.sh now reads the version first and removes anything in
desktop/release/ that is not that version (plus the regenerated unpacked
trees), so a version bump never leaves old installers lying around — the
same rule push_desktop.sh applies to the feed.
2026-09-20 21:16:56 -05:00

80 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Build the J621 desktop packages into desktop/release/ — Arch (.pkg.tar.zst),
# Debian (.deb) and the Windows NSIS installer. Nothing is published: install
# the package locally, hand the files out, or attach them to a Gitea release
# manually. Use push_desktop.sh when the in-app update feed should get them.
#
# Usage: ./build_desktop.sh [--linux | --win | --all]
# --linux Arch + Debian packages only
# --win Windows installer only (cross-built with wine)
# --all everything (default)
set -euo pipefail
cd "$(dirname "$0")/.."
TARGET="${1:---all}"
case "$TARGET" in
--linux) TARGET=linux ;;
--win) TARGET=win ;;
--all) TARGET=all ;;
*)
echo "usage: $0 [--linux|--win|--all]" >&2
exit 2
;;
esac
VERSION="$(node -p "require('./desktop/package.json').version")"
if [ ! -d desktop/node_modules ]; then
echo "==> Installing desktop dependencies ..."
npm --prefix desktop ci --no-audit --no-fund
fi
if [ "$TARGET" != "linux" ] && ! command -v wine >/dev/null 2>&1; then
echo "==> wine is not installed; the Windows installer needs it." >&2
exit 1
fi
# release/ should only ever hold the current version: old installers are
# rebuilt from git when needed, and the unpacked trees are regenerated.
shopt -s nullglob
stale=(desktop/release/*.deb desktop/release/*.pkg.tar.zst desktop/release/"J621 Setup "*.exe
desktop/release/*.blockmap desktop/release/latest*.yml)
for file in "${stale[@]}"; do
case "$(basename "$file")" in
*"$VERSION"*) ;;
*) echo " removing $(basename "$file")"; rm -f "$file" ;;
esac
done
rm -rf desktop/release/linux-unpacked desktop/release/win-unpacked
case "$TARGET" in
linux) npm --prefix desktop run dist:linux ;;
win) npm --prefix desktop run dist:win ;;
all) npm --prefix desktop run dist:all ;;
esac
case "$TARGET" in
linux) ARTIFACTS=(-name "*${VERSION}*.deb" -o -name "*${VERSION}*.pkg.tar.zst") ;;
win) ARTIFACTS=(-name "*${VERSION}*.exe") ;;
all) ARTIFACTS=(-name "*${VERSION}*.deb" -o -name "*${VERSION}*.pkg.tar.zst" -o -name "*${VERSION}*.exe") ;;
esac
echo
echo "==> Artifacts in desktop/release/:"
find desktop/release -maxdepth 1 -type f \( "${ARTIFACTS[@]}" \) \
-printf '%s\t%p\n' |
sort -rn |
while IFS=$'\t' read -r size file; do
printf ' %8s %s\n' "$(numfmt --to=iec "$size")" "$file"
done
echo
echo "==> SHA-256 (for release notes):"
find desktop/release -maxdepth 1 -type f \( "${ARTIFACTS[@]}" \) \
-exec sha256sum {} + | sed 's/^/ /'
echo
echo "==> J621 desktop $VERSION built."
echo " Install here: sudo pacman -U desktop/release/j621-desktop-*.pkg.tar.zst"
echo " Gitea release tag: desktop-v$VERSION"