mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-07-29 07:17:38 +03:00
62 lines
2.3 KiB
Bash
62 lines
2.3 KiB
Bash
#!/bin/sh
|
|
# Publish hub download artifacts (Session Studio jar + latest OTA .apk) to BE downloads mount.
|
|
set -eu
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
# shellcheck source=/dev/null
|
|
. "$ROOT/scripts/lib/common.sh"
|
|
load_cluster_env
|
|
|
|
DOWNLOADS_ROOT="${APP_ROOT:-/var/www/localhost/htdocs/apps/app/androidcast_project}/downloads"
|
|
OTA_ROOT="${APP_ROOT:-/var/www/localhost/htdocs/apps/app/androidcast_project}/ota-artifacts/v0/ota"
|
|
WS="${AC_WORKSPACE_ROOT:-/var/www/ac/workspace}"
|
|
STUDIO_JAR="${WS}/ac-session-studio/build/libs/ac-session-studio.jar"
|
|
|
|
mkdir -p "$DOWNLOADS_ROOT"
|
|
|
|
if [ -f "$STUDIO_JAR" ]; then
|
|
install -m 644 "$STUDIO_JAR" "${DOWNLOADS_ROOT}/ac-session-studio.jar"
|
|
log "installed Session Studio jar → ${DOWNLOADS_ROOT}/ac-session-studio.jar"
|
|
else
|
|
log "WARN: Session Studio jar not built at ${STUDIO_JAR}"
|
|
fi
|
|
|
|
# Prefer staging channel APK; fall back to stable.
|
|
apk_src=""
|
|
for ch in staging stable; do
|
|
channel_json="${OTA_ROOT}/channel/${ch}.json"
|
|
[ -f "$channel_json" ] || continue
|
|
manifest_url="$(sed -n 's/.*"manifestUrl"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$channel_json" | head -1)"
|
|
[ -n "$manifest_url" ] || continue
|
|
manifest_path="${OTA_ROOT}/${manifest_url#*\/v0\/ota\/}"
|
|
[ -f "$manifest_path" ] || continue
|
|
browser_url="$(sed -n 's/.*"browserApkUrl"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$manifest_path" | head -1)"
|
|
if [ -n "$browser_url" ]; then
|
|
candidate="${OTA_ROOT}/${browser_url#*\/v0\/ota\/}"
|
|
if [ -f "$candidate" ]; then
|
|
apk_src="$candidate"
|
|
break
|
|
fi
|
|
fi
|
|
otapkg_url="$(sed -n 's/.*"apkUrl"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$manifest_path" | head -1)"
|
|
if [ -n "$otapkg_url" ]; then
|
|
candidate="${OTA_ROOT}/${otapkg_url#*\/v0\/ota\/}"
|
|
if [ -f "$candidate" ]; then
|
|
apk_src="$candidate"
|
|
break
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ -n "$apk_src" ]; then
|
|
install -m 644 "$apk_src" "${DOWNLOADS_ROOT}/android_cast-latest.apk"
|
|
base="$(basename "$apk_src" .otapkg)"
|
|
base="$(basename "$base" .apk)"
|
|
install -m 644 "$apk_src" "${DOWNLOADS_ROOT}/${base}.apk"
|
|
log "installed APK → ${DOWNLOADS_ROOT}/android_cast-latest.apk (from ${apk_src})"
|
|
else
|
|
log "WARN: no OTA .apk/.otapkg found under ${OTA_ROOT}/channel/{staging,stable}.json"
|
|
fi
|
|
|
|
chown -R nginx:nginx "$DOWNLOADS_ROOT" 2>/dev/null || true
|
|
log "Hub downloads dir: ${DOWNLOADS_ROOT}"
|