#!/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 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 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 VERSION="$(node -p "require('./desktop/package.json').version")" 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"