Skip to content

feat: add one-line deploy script (deploy-cli.sh)#7631

Open
EterUltimate wants to merge 3 commits intoAstrBotDevs:masterfrom
EterUltimate:master
Open

feat: add one-line deploy script (deploy-cli.sh)#7631
EterUltimate wants to merge 3 commits intoAstrBotDevs:masterfrom
EterUltimate:master

Conversation

@EterUltimate
Copy link
Copy Markdown

@EterUltimate EterUltimate commented Apr 17, 2026

概述

添加一行命令快速部署脚本,简化源码部署流程。

变更内容

新增 docs/scripts/deploy-cli.sh

  • 支持 Linux / macOS / WSL 一行命令部署
  • 自动检测 git、Python >=3.10、uv 依赖
  • 自动克隆仓库 -> uv sync -> 启动 AstrBot

用法:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/AstrBotDevs/AstrBot/master/docs/scripts/deploy-cli.sh)"

修改 docs/zh/deploy/astrbot/cli.md

  • 新增「一行命令快速部署」板块
  • 引用仓库内 docs/scripts/deploy-cli.sh
  • 提供本地运行方式提示
  • Windows 板块改为 WSL 调用同一脚本,并引导原生用户走手动步骤或 Docker 部署

测试

  • 脚本语法检查 (bash -n deploy-cli.sh 通过)
  • 实际 Linux 环境测试
  • macOS 环境测试

Summary by Sourcery

Add a one-line deployment script for AstrBot and document its usage for Linux, macOS, WSL, and Windows users.

New Features:

  • Introduce a bash deployment script that automates cloning the AstrBot repository, installing dependencies with uv, and starting the service.
  • Add a one-command remote execution option for deploying AstrBot via curl and bash on Unix-like environments.

Documentation:

  • Update the Chinese CLI deployment guide to document the new one-line deployment method and adjust Windows instructions to use WSL or alternative deployment paths.

- Add docs/scripts/deploy-cli.sh for one-command deployment (Linux/macOS/WSL)
- Update docs/zh/deploy/astrbot/cli.md to reference local script
- Replace non-existent https://astrbot.app/deploy.sh with raw.githubusercontent.com URL
- Add local run tip and WSL-based Windows support
@auto-assign auto-assign bot requested review from LIghtJUNction and anka-afk April 17, 2026 15:20
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 17, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a one-command deployment script (deploy-cli.sh) and updates the documentation to include instructions for its use across Linux, macOS, and Windows (via WSL). The script automates the process of checking for dependencies, installing the uv package manager, cloning the repository, and starting the application. Review feedback highlighted a portability issue with sort -V on macOS, a discrepancy between the script's Python version check and the project's actual requirements (3.12), and a logic flaw that could cause nested directory cloning if the script is run from within the repository.

Comment thread docs/scripts/deploy-cli.sh Outdated
Comment on lines +36 to +39
if [ "$(printf '%s\n' "3.10" "$PY_VER" | sort -V | head -n1)" != "3.10" ]; then
err "Python 版本过低: $PY_VER,需要 >= 3.10"
exit 1
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

此处使用的 sort -V (version sort) 是 GNU 扩展,在 macOS 默认的 BSD sort 中并不支持,会导致脚本在 macOS 上运行失败。此外,脚本检查的是 Python >= 3.10,但 pyproject.toml 中定义的 requires-python>=3.12。由于后续 uv sync 会严格遵守 pyproject.toml 的约束,建议将检查版本提升至 3.12,并使用 Python 自身进行版本比较以提高兼容性。

Suggested change
if [ "$(printf '%s\n' "3.10" "$PY_VER" | sort -V | head -n1)" != "3.10" ]; then
err "Python 版本过低: $PY_VER,需要 >= 3.10"
exit 1
fi
if ! $PY -c 'import sys; exit(0 if sys.version_info >= (3, 12) else 1)'; then
err "Python 版本过低: $PY_VER,需要 >= 3.12"
exit 1
fi

Comment thread docs/scripts/deploy-cli.sh Outdated
Comment on lines +55 to +62
INSTALL_DIR="${1:-AstrBot}"
if [ ! -d "$INSTALL_DIR/.git" ]; then
info "正在克隆 AstrBot 仓库到 $INSTALL_DIR ..."
git clone --depth=1 https://github.com/AstrBotDevs/AstrBot.git "$INSTALL_DIR"
else
info "目录 $INSTALL_DIR 已存在,跳过克隆"
fi
cd "$INSTALL_DIR"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

当按照文档建议在已克隆的仓库目录内运行此脚本时(例如 cd AstrBot; bash docs/scripts/deploy-cli.sh),脚本会因为在当前目录下找不到 ./AstrBot/.git 而尝试再次克隆,导致出现嵌套目录(如 AstrBot/AstrBot)。建议增加对当前目录是否已是项目根目录的检测。

Suggested change
INSTALL_DIR="${1:-AstrBot}"
if [ ! -d "$INSTALL_DIR/.git" ]; then
info "正在克隆 AstrBot 仓库到 $INSTALL_DIR ..."
git clone --depth=1 https://github.com/AstrBotDevs/AstrBot.git "$INSTALL_DIR"
else
info "目录 $INSTALL_DIR 已存在,跳过克隆"
fi
cd "$INSTALL_DIR"
if [ -f "main.py" ] && [ -d ".git" ]; then
info "检测到已在项目目录中,跳过克隆"
else
INSTALL_DIR="${1:-AstrBot}"
if [ ! -d "$INSTALL_DIR/.git" ]; then
info "正在克隆 AstrBot 仓库到 $INSTALL_DIR ..."
git clone --depth=1 https://github.com/AstrBotDevs/AstrBot.git "$INSTALL_DIR"
else
info "目录 $INSTALL_DIR 已存在,跳过克隆"
fi
cd "$INSTALL_DIR"
fi

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • When the script is run from an already-cloned repo (as shown in the "本地运行脚本" example), INSTALL_DIR="${1:-AstrBot}" combined with if [ ! -d "$INSTALL_DIR/.git" ] will cause a nested AstrBot/AstrBot clone; consider detecting an existing .git in the current directory and skipping the INSTALL_DIR cloning logic in that case.
  • The script currently hardcodes the GitHub repo URL and default directory name; consider allowing these to be overridden via environment variables or flags so that forks or mirrors can reuse the same deployment script.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When the script is run from an already-cloned repo (as shown in the "本地运行脚本" example), `INSTALL_DIR="${1:-AstrBot}"` combined with `if [ ! -d "$INSTALL_DIR/.git" ]` will cause a nested `AstrBot/AstrBot` clone; consider detecting an existing `.git` in the current directory and skipping the `INSTALL_DIR` cloning logic in that case.
- The script currently hardcodes the GitHub repo URL and default directory name; consider allowing these to be overridden via environment variables or flags so that forks or mirrors can reuse the same deployment script.

## Individual Comments

### Comment 1
<location path="docs/scripts/deploy-cli.sh" line_range="18-19" />
<code_context>
+# ── 1. 检测并安装依赖 ──
+info "正在检测运行环境..."
+
+if ! has git; then
+    err "未检测到 git,请先安装: https://git-scm.com/downloads"
+    exit 1
+fi
+
</code_context>
<issue_to_address>
**suggestion:** Consider checking for `curl` explicitly since the script depends on it for both the install and the recommended one-liner usage.

Currently only `git` and `python` are validated, but the script also relies on `curl` (for install and the one-liner). On systems without `curl`, users will just see `command not found`. Consider adding a `curl` check similar to the `git` check, with a clear error message and possibly guidance (e.g., how to install `curl` or an optional `wget` fallback).

```suggestion
# ── 1. 检测并安装依赖 ──
info "正在检测运行环境..."

if ! has git; then
    err "未检测到 git,请先安装: https://git-scm.com/downloads"
    exit 1
fi

if ! has curl; then
    err "未检测到 curl,请先安装 curl 后重试(例如:macOS 使用 'brew install curl',Ubuntu/Debian 使用 'sudo apt install curl')。"
    exit 1
fi
```
</issue_to_address>

### Comment 2
<location path="docs/scripts/deploy-cli.sh" line_range="55-56" />
<code_context>
+ok "uv $(uv --version)"
+
+# ── 2. 克隆仓库 ──
+INSTALL_DIR="${1:-AstrBot}"
+if [ ! -d "$INSTALL_DIR/.git" ]; then
+    info "正在克隆 AstrBot 仓库到 $INSTALL_DIR ..."
+    git clone --depth=1 https://github.com/AstrBotDevs/AstrBot.git "$INSTALL_DIR"
</code_context>
<issue_to_address>
**issue:** Cloning into an existing non-git directory will fail silently from the script's perspective; consider handling that case explicitly.

Right now you only check for `$INSTALL_DIR/.git`. If `$INSTALL_DIR` already exists but isn’t a git repo (e.g., user-created or used for other files), `git clone ... "$INSTALL_DIR"` will fail because the directory is non-empty and only surface as a git error. It would help to explicitly handle the case where `$INSTALL_DIR` exists without `.git` by either aborting with a clearer message, prompting for a different directory, or supporting a `--force`/env flag to overwrite or reuse it.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread docs/scripts/deploy-cli.sh
Comment thread docs/scripts/deploy-cli.sh Outdated
- Replace sort -V with Python-native version check (macOS BSD compat)
- Bump Python requirement from >=3.10 to >=3.12 (match pyproject.toml)
- Detect current directory as project root (avoid nested clone)
- Handle existing non-git directory explicitly
- Add curl dependency check
- Support ASTRBOT_REPO and ASTRBOT_DIR env vars for forks/mirrors
- Update cli.md version description to match
- Add deploy-cli.ps1 for Windows native environment (PowerShell 7+)
- Update cli.md to document Windows one-liner deployment
- Add local script execution instructions for both bash and ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant