build.ps1 861 B

12345678910111213141516171819202122232425
  1. # deepseek-tray 构建脚本:格式检查 -> 静态检查 -> 单元测试 -> 构建
  2. $ErrorActionPreference = 'Stop'
  3. Push-Location $PSScriptRoot
  4. try {
  5. Write-Host '[1/4] gofmt 检查'
  6. $unformatted = gofmt -l .
  7. if ($unformatted) { throw ('以下文件未格式化: ' + ($unformatted -join ', ')) }
  8. Write-Host '[2/4] go vet'
  9. go vet ./...
  10. if ($LASTEXITCODE -ne 0) { throw 'go vet 失败' }
  11. Write-Host '[3/4] go test'
  12. go test ./...
  13. if ($LASTEXITCODE -ne 0) { throw 'go test 失败' }
  14. Write-Host '[4/4] go build'
  15. go build -trimpath -ldflags '-H=windowsgui -s -w' -o deepseek-tray.exe .
  16. if ($LASTEXITCODE -ne 0) { throw 'go build 失败' }
  17. $size = [math]::Round((Get-Item 'deepseek-tray.exe').Length / 1KB, 0)
  18. Write-Host ('构建成功: deepseek-tray.exe (' + $size + ' KB)')
  19. } finally {
  20. Pop-Location
  21. }