| 123456789101112131415161718192021222324252627282930313233 |
- # deepseek-tray 构建脚本:格式检查 -> 静态检查 -> 单元测试 -> 构建
- # 版本号唯一维护点(README 的版本历史与此保持一致)
- $Version = '2.6.0'
- $ErrorActionPreference = 'Stop'
- Push-Location $PSScriptRoot
- try {
- Write-Host ('deepseek-tray v' + $Version) -ForegroundColor Cyan
- Write-Host '[1/4] gofmt 检查'
- $unformatted = gofmt -l .
- if ($unformatted) { throw ('以下文件未格式化: ' + ($unformatted -join ', ')) }
- Write-Host '[2/4] go vet'
- go vet ./...
- if ($LASTEXITCODE -ne 0) { throw 'go vet 失败' }
- Write-Host '[3/4] go test'
- go test ./...
- if ($LASTEXITCODE -ne 0) { throw 'go test 失败' }
- Write-Host '[4/4] go build'
- go build -trimpath -ldflags "-H=windowsgui -s -w -X main.appVersion=$Version" -o deepseek-tray.exe .
- if ($LASTEXITCODE -ne 0) { throw 'go build 失败' }
- # 目标 exe 被运行中的实例占用时,Go 会留下 .exe~ 备份(约 5 MB),顺手清理
- Get-ChildItem -Filter '*.exe~' -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
- $size = [math]::Round((Get-Item 'deepseek-tray.exe').Length / 1KB, 0)
- Write-Host ('构建成功: deepseek-tray.exe (' + $size + ' KB, v' + $Version + ')') -ForegroundColor Green
- } finally {
- Pop-Location
- }
|