Files
task_pilot/scripts/build-release.ps1
T
CNWei 1914d38451 feat: 本地 uv 与托管 Python 环境管理
- 新增 uv 管理:只认程序目录副本或指定路径,支持从科大镜像下载并按 sha256 校验

- uv 环境变量(UV_*)可配置,默认相对程序目录(python / uv-cache),同时注入 uv 调用与任务进程

- 新增托管虚拟环境与 Python 版本管理:用 uv 下载解释器、预创建环境、查看已装包

- 新建任务保存时自动创建 .venv,运行期只校验、不再自动装依赖;镜像只在装包时使用

- 前端改为顶部品牌栏 + 三栏工作台,uv / 镜像源 / 虚拟环境各自独立弹窗

- 发布包构建后去掉工作区继承的低完整性标签

- 修复调度集成测试并发时误取 skipped 运行的问题
2026-11-07 16:57:27 +08:00

61 lines
2.7 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
$releaseRoot = [System.IO.Path]::GetFullPath((Join-Path $projectRoot 'release\TaskPilot'))
$expectedPrefix = [System.IO.Path]::GetFullPath((Join-Path $projectRoot 'release')).TrimEnd('\') + '\'
if (-not $releaseRoot.StartsWith($expectedPrefix, [System.StringComparison]::OrdinalIgnoreCase)) {
throw "Refusing to build outside release directory: $releaseRoot"
}
# 与 check.ps1 一致:临时目录放在仓库内,避免系统 %TEMP% 权限策略让 aws-lc-sys 的 cc 构建失败。
$scratch = Join-Path $projectRoot '.tmp'
[void](New-Item -ItemType Directory -Path $scratch -Force)
$env:TMP = $scratch
$env:TEMP = $scratch
function Assert-ExitCode {
param([string]$Step)
if ($LASTEXITCODE -ne 0) {
throw "$Step failed with exit code $LASTEXITCODE"
}
}
Push-Location $projectRoot
try {
# 前端依赖同级 stash-ui(file:../../stash-ui):发布包要求先有组件库产物
$stashUiDist = [System.IO.Path]::GetFullPath((Join-Path $projectRoot '..\stash-ui\dist\stash-ui.js'))
if (-not (Test-Path -LiteralPath $stashUiDist)) {
throw "Missing @stash/ui build output: $stashUiDist. Run 'npm --prefix ..\stash-ui install' and 'npm --prefix ..\stash-ui run build' first."
}
pnpm --dir frontend build
Assert-ExitCode 'Frontend build'
cargo build --release --bin task-pilot-backend --manifest-path backend\Cargo.toml
Assert-ExitCode 'Rust release build'
if (Test-Path -LiteralPath $releaseRoot) {
Remove-Item -LiteralPath $releaseRoot -Recurse -Force
}
[void](New-Item -ItemType Directory -Path $releaseRoot -Force)
[void](New-Item -ItemType Directory -Path (Join-Path $releaseRoot 'web') -Force)
# uv 管理页默认从这个目录找自己下载的 uv.exe
[void](New-Item -ItemType Directory -Path (Join-Path $releaseRoot 'uv') -Force)
[void](New-Item -ItemType Directory -Path (Join-Path $releaseRoot 'data') -Force)
[void](New-Item -ItemType Directory -Path (Join-Path $releaseRoot 'logs') -Force)
Copy-Item -LiteralPath 'backend\target\release\task-pilot-backend.exe' -Destination $releaseRoot
Copy-Item -LiteralPath 'scripts\start.ps1' -Destination $releaseRoot
Copy-Item -Path 'frontend\dist\*' -Destination (Join-Path $releaseRoot 'web') -Recurse
Copy-Item -LiteralPath 'docs\RELEASE.md' -Destination (Join-Path $releaseRoot 'README.md')
# 发布包不该继承工作区的低完整性标签:带着它启动的进程写不了 uv 缓存和用户文件。
& icacls $releaseRoot /setintegritylevel '(OI)(CI)M' /T | Out-Null
Assert-ExitCode 'Release integrity label'
Write-Host "Release package: $releaseRoot"
}
finally {
Pop-Location
}