# publish.ps1 —— 一键构建并发布 AnxindeWiki 到 GitHub Pages # 在仓库根目录执行: powershell -ExecutionPolicy Bypass -File .\scripts\publish.ps1 $ErrorActionPreference = "Stop" $repo = Split-Path -Parent $PSScriptRoot Set-Location -LiteralPath $repo Write-Host "[1/3] 检查依赖 ..." -ForegroundColor Cyan python -c "import mkdocs" 2>$null if ($LASTEXITCODE -ne 0) { Write-Host "未检测到 mkdocs,正在安装 requirements.txt ..." -ForegroundColor Yellow python -m pip install -r requirements.txt } Write-Host "[2/3] 本地构建 ..." -ForegroundColor Cyan python -m mkdocs build if ($LASTEXITCODE -ne 0) { throw "构建失败,请检查上面的报错。" } Write-Host "[3/3] 发布到 GitHub Pages(gh-pages 分支)..." -ForegroundColor Cyan python -m mkdocs gh-deploy --force if ($LASTEXITCODE -ne 0) { throw "发布失败(检查网络 / GitHub 登录 / 推送权限)。" } Write-Host "完成!约 1 分钟后访问 https://wiki.anxinddecs.cn/" -ForegroundColor Green