Files
goldenChart/scripts/reconcile-desktop-latest-json.sh
T

44 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# signed updater bundle → latest.json (deploy/checkout 후 placeholder 복구)
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
UPDATES_DIR="${UPDATES_DIR:-${WORK_TREE:-$ROOT}/frontend/public/desktop/updates}"
CONF="$ROOT/desktop/src-tauri/tauri.conf.json"
BASE_URL="${DESKTOP_UPDATE_BASE_URL:-https://exdev.co.kr/desktop/updates}"
if [[ ! -d "$UPDATES_DIR" ]]; then
echo "[reconcile-latest] skip — no $UPDATES_DIR"
exit 0
fi
VERSION="$(node -p "require('$CONF').version" 2>/dev/null || echo '0.1.0')"
LATEST_JSON="$UPDATES_DIR/latest.json"
if [[ -f "$LATEST_JSON" ]]; then
EXISTING="$(node -p "
const fs=require('fs'); const v=require('$LATEST_JSON').version||'0.0.0';
const c='$VERSION'.split('.').map(Number); const e=v.split('.').map(Number);
for (let i=0;i<3;i++){ if((e[i]||0)>(c[i]||0)){ console.log(v); process.exit(0);} if((e[i]||0)<(c[i]||0)) break;}
console.log('$VERSION');
" 2>/dev/null || echo "$VERSION")"
VERSION="$EXISTING"
fi
NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}"
set +e
node "$ROOT/scripts/generate-desktop-latest-json.mjs" \
--version "$VERSION" \
--dir "$UPDATES_DIR" \
--base-url "$BASE_URL" \
--notes "$NOTES"
RC=$?
set -e
if [[ "$RC" -eq 0 ]]; then
echo "[reconcile-latest] updated $UPDATES_DIR/latest.json"
elif [[ "$RC" -eq 2 ]]; then
echo "[reconcile-latest] no signed bundles — keeping existing latest.json"
else
exit "$RC"
fi