Skip to content

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

Merged
Soulter merged 8 commits intoAstrBotDevs:masterfrom
EterUltimate:master
Apr 28, 2026
Merged

feat: add one-line deploy script (deploy-cli.sh)#7631
Soulter merged 8 commits intoAstrBotDevs:masterfrom
EterUltimate:master

Conversation

@EterUltimate
Copy link
Copy Markdown
Contributor

@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 thread docs/scripts/deploy-cli.sh Outdated
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 Outdated
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
@Soulter Soulter force-pushed the master branch 2 times, most recently from faf411f to 0068960 Compare April 19, 2026 09:50
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 28, 2026
Comment thread astrbot/core/config/astrbot_config.py Fixed
Comment thread astrbot/core/config/astrbot_config.py Dismissed
Comment thread astrbot/core/config/astrbot_config.py Dismissed
@Soulter Soulter merged commit e218620 into AstrBotDevs:master Apr 28, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants