AnyBot/deploy/ci/package-linux.sh

45 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/sh
# Package the Linux builds for a release (run from app/ after the release builds):
# dist/AnyBot-<version>-ubuntu-x86_64.tar.gz the app with its window (menu entry, icon)
# dist/AnyBot-<version>-headless-x86_64.tar.gz for a computer without a screen (hands, or a brain)
# dist/AnyBot-<version>-server-x86_64.tar.gz account server + brain on one server (Docker)
set -e
VERSION=${1:?version}
ARCH=$(uname -m)
OUT=dist
rm -rf "$OUT" && mkdir -p "$OUT"
BIN=${CARGO_TARGET_DIR:-target}/release/anybot
RELAY=${CARGO_TARGET_DIR:-relay/target}/release/anybot-relay
strip "$BIN" "$RELAY" 2>/dev/null || true
# Ubuntu (with a window)
D="$OUT/AnyBot-$VERSION-ubuntu-$ARCH"
mkdir -p "$D"
cp "$BIN" deploy/linux/anybot.desktop icons/anybot.svg "$D/"
cp deploy/ci/linux-install.sh "$D/install.sh"
printf 'AnyBot %s(Ubuntu 22.04 以後、Debian 12 以後)\n\n ./install.sh 安裝,之後從選單打開 AnyBot\n' "$VERSION" > "$D/讀我.txt"
tar -C "$OUT" -czf "$D.tar.gz" "$(basename "$D")"
# Without a screen (hands, or a brain)
D="$OUT/AnyBot-$VERSION-headless-$ARCH"
mkdir -p "$D"
cp "$BIN" "$D/"
cp deploy/ci/linux-install.sh "$D/install.sh"
cp deploy/linux/hands.sh "$D/hands.sh"
printf 'AnyBot %s:沒有螢幕的 Linux\n\n ./install.sh\n 然後在手機或電腦的 AnyBot 按「加一台電腦」,把那一行貼到這台執行。\n 想讓 Bot 看這台的畫面(虛擬螢幕):先執行 ./hands.sh --deps\n' "$VERSION" > "$D/讀我.txt"
tar -C "$OUT" -czf "$D.tar.gz" "$(basename "$D")"
# Server: account server + brain, from these binaries (no compiling on the server)
D="$OUT/AnyBot-$VERSION-server-$ARCH"
mkdir -p "$D/bin" "$D/deploy/server" "$D/relay"
cp "$BIN" "$RELAY" "$D/bin/"
cp deploy/server/setup.sh deploy/server/.env.example "$D/deploy/server/"
cp deploy/ci/server-compose.yml "$D/deploy/server/docker-compose.yml"
cp deploy/ci/Dockerfile.server-relay deploy/ci/Dockerfile.server-anybot "$D/deploy/server/"
cp relay/Caddyfile "$D/relay/Caddyfile"
printf 'AnyBot %s 伺服器(帳號伺服器 + 大腦 + HTTPS,用 Docker)\n\n cd deploy/server && ./setup.sh\n' "$VERSION" > "$D/讀我.txt"
tar -C "$OUT" -czf "$D.tar.gz" "$(basename "$D")"
find "$OUT" -maxdepth 1 -type d -name 'AnyBot-*' -exec rm -rf {} +
ls -la "$OUT"