summaryrefslogtreecommitdiff
path: root/pack-for-share.sh
blob: f5b380cd129d9c965c4a0de5cec74ce854a584e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Build LocalSend artifacts in dist/ and ~/Downloads/
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DIST="$ROOT/dist"
DOWNLOADS="${DOWNLOADS:-$HOME/Downloads}"
VIDEO_DIR="${VIDEO_DIR:-$HOME/Videos/Screensavers/Aerial}"
CODE_ZIP="$DIST/aerial-screensaver-linux.zip"
VIDEO_ZIP="$DIST/aerial-videos-lite.zip"

mkdir -p "$DIST" "$DOWNLOADS"

echo "Building code zip..."
rm -f "$CODE_ZIP"
(
  cd "$(dirname "$ROOT")"
  zip -r "$CODE_ZIP" "$(basename "$ROOT")" \
    -x "$(basename "$ROOT")/.git/*" \
    -x "$(basename "$ROOT")/__pycache__/*" \
    -x "$(basename "$ROOT")/dist/*" \
    -x "$(basename "$ROOT")/*.log"
)

echo "Building videos zip from $VIDEO_DIR ..."
mapfile -t clips < <(find "$VIDEO_DIR" -maxdepth 1 -type f -name '*.mp4' | sort)
if [[ ${#clips[@]} -eq 0 ]]; then
  echo "No .mp4 clips in $VIDEO_DIR — skip video zip" >&2
else
  rm -f "$VIDEO_ZIP"
  (
    cd "$VIDEO_DIR"
    zip -r "$VIDEO_ZIP" ./*.mp4
  )
fi

cp -f "$CODE_ZIP" "$DOWNLOADS/aerial-screensaver-linux.zip"
[[ -f "$VIDEO_ZIP" ]] && cp -f "$VIDEO_ZIP" "$DOWNLOADS/aerial-videos-lite.zip"

echo
echo "Ready for LocalSend:"
ls -lh "$DOWNLOADS/aerial-screensaver-linux.zip"
[[ -f "$DOWNLOADS/aerial-videos-lite.zip" ]] && ls -lh "$DOWNLOADS/aerial-videos-lite.zip"
echo
echo "Recipient:"
echo "  unzip aerial-screensaver-linux.zip && cd aerial-screensaver-linux"
echo "  ./install.sh --videos-zip ~/Downloads/aerial-videos-lite.zip"