Files
AstrBot/scripts/deploy-cli.ps1
EterUltimate e218620a37 feat: add one-line deploy script (deploy-cli.sh) (#7631)
* feat: add one-line deploy script (deploy-cli.sh) and update cli.md

- 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

* fix: address PR review feedback for deploy-cli.sh

- 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

* feat: add Windows PowerShell deploy script and update docs

- 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

* refactor: standardize log messages and improve clarity in various modules

Co-authored-by: Copilot <copilot@github.com>

* docs: 移除一行命令快速部署部分,简化安装说明

* feat: 添加脚本以复制部署 CLI 文件并更新构建命令

* refactor: 更新日志消息以提高可读性,统一英文提示信息

---------

Co-authored-by: Soulter <905617992@qq.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Weilong Liao <37870767+Soulter@users.noreply.github.com>
2026-04-28 14:49:50 +08:00

87 lines
2.2 KiB
PowerShell

# deploy-cli.ps1 - Install astrbot with uv on Windows PowerShell.
#Requires -Version 7.0
$ErrorActionPreference = 'Stop'
$UseColor = [string]::IsNullOrEmpty($env:NO_COLOR) -and [Console]::IsOutputRedirected -eq $false
function Write-Status {
param(
[string]$Prefix,
[string]$Message,
[string]$Color
)
if ($UseColor) {
Write-Host "$Prefix $Message" -ForegroundColor $Color
} else {
Write-Host "$Prefix $Message"
}
}
function Info { Write-Status "[INFO]" "$args" "Cyan" }
function Warn { Write-Status "[WARN]" "$args" "Yellow" }
function Ok { Write-Status "[OK]" "$args" "Green" }
function Err { Write-Status "[ERROR]" "$args" "Red" }
function Test-Command {
param([string]$Name)
$null = Get-Command $Name -ErrorAction SilentlyContinue
return $?
}
function Update-UvPath {
$candidateDirs = @()
if ($HOME) {
$candidateDirs += Join-Path $HOME ".local\bin"
}
if ($env:USERPROFILE) {
$candidateDirs += Join-Path $env:USERPROFILE ".local\bin"
}
if ($env:LOCALAPPDATA) {
$candidateDirs += Join-Path $env:LOCALAPPDATA "uv"
}
foreach ($dir in $candidateDirs) {
if ((Test-Path $dir) -and (($env:PATH -split ';') -notcontains $dir)) {
$env:PATH = "$dir;$env:PATH"
}
}
}
function Install-Uv {
Info "uv was not found. Installing uv..."
$tempScript = [System.IO.Path]::GetTempFileName() + ".ps1"
try {
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1" -OutFile $tempScript -UseBasicParsing
& $tempScript
Update-UvPath
} catch {
Err "Failed to install uv."
Err "Please install uv manually: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
} finally {
Remove-Item $tempScript -ErrorAction SilentlyContinue
}
}
if (-not (Test-Command "uv")) {
Install-Uv
}
Update-UvPath
if (-not (Test-Command "uv")) {
Err "uv was not found after installation."
Err "Please install uv manually: https://docs.astral.sh/uv/getting-started/installation/"
exit 1
}
Ok (& uv --version)
Info "Installing AstrBot with Python 3.12..."
uv tool install --python 3.12 astrbot
Ok "AstrBot has been installed."