build-binary.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: Build Binaries
  2. # 多平台单文件二进制构建(Nuitka)。
  3. # 触发:打 v* tag 时自动构建并附到 GitHub Release;也可手动 workflow_dispatch。
  4. # 不在每次 push 跑 —— 二进制编译慢且耗 runner 分钟。
  5. on:
  6. push:
  7. tags: ["v*"]
  8. workflow_dispatch:
  9. inputs:
  10. onefile:
  11. description: "1=单文件(默认) / 0=standalone 目录"
  12. required: false
  13. default: "1"
  14. permissions:
  15. contents: write # 需要写 Release 附件
  16. jobs:
  17. build:
  18. name: build (${{ matrix.label }})
  19. runs-on: ${{ matrix.os }}
  20. continue-on-error: ${{ matrix.experimental }}
  21. strategy:
  22. fail-fast: false
  23. matrix:
  24. include:
  25. - os: macos-14 # Apple Silicon
  26. label: macos-arm64
  27. experimental: false
  28. - os: macos-13 # Intel
  29. label: macos-x86_64
  30. experimental: false
  31. - os: ubuntu-latest # Linux x86_64
  32. label: linux-x86_64
  33. experimental: false
  34. - os: windows-latest # Windows x86_64(实验性:脚本面向 *nix,可能需适配)
  35. label: windows-x86_64
  36. experimental: true
  37. steps:
  38. - uses: actions/checkout@v4
  39. - name: Set up Python 3.11
  40. uses: actions/setup-python@v5
  41. with:
  42. python-version: "3.11"
  43. - name: Set up Node 20
  44. uses: actions/setup-node@v4
  45. with:
  46. node-version: "20"
  47. cache: npm
  48. cache-dependency-path: webui/package-lock.json
  49. # 前端静态产物(vite build → 仓库根 webui-dist/,供二进制内嵌)
  50. - name: Build web UI
  51. working-directory: webui
  52. run: |
  53. npm ci
  54. npm run build
  55. # Linux: Nuitka standalone 需要 patchelf
  56. - name: Install patchelf (Linux)
  57. if: runner.os == 'Linux'
  58. run: sudo apt-get update && sudo apt-get install -y patchelf
  59. - name: Build binary
  60. shell: bash
  61. env:
  62. ONEFILE: ${{ github.event.inputs.onefile || '1' }}
  63. PROVIDERS: "anthropic openai"
  64. run: |
  65. chmod +x setup.sh scripts/build_binary.sh
  66. # Windows runner 只有 `python`,*nix 用 `python3`
  67. if [ "${{ runner.os }}" = "Windows" ]; then PY=python; else PY=python3; fi
  68. bash scripts/build_binary.sh "$PY"
  69. - name: Package artifact
  70. shell: bash
  71. run: |
  72. mkdir -p out
  73. cd dist-binary
  74. # 单文件 → 直接打 tar.gz;目录模式 → 整目录打 tar.gz
  75. if ls *.app >/dev/null 2>&1; then
  76. tar -czf "../out/agentpaas-${{ matrix.label }}.tar.gz" *.app
  77. else
  78. tar -czf "../out/agentpaas-${{ matrix.label }}.tar.gz" agentpaas* 2>/dev/null || \
  79. tar -czf "../out/agentpaas-${{ matrix.label }}.tar.gz" *
  80. fi
  81. ls -lh ../out
  82. - name: Upload build artifact
  83. uses: actions/upload-artifact@v4
  84. with:
  85. name: agentpaas-${{ matrix.label }}
  86. path: out/*.tar.gz
  87. if-no-files-found: error
  88. release:
  89. name: Attach to Release
  90. needs: build
  91. if: startsWith(github.ref, 'refs/tags/')
  92. runs-on: ubuntu-latest
  93. steps:
  94. - name: Download all artifacts
  95. uses: actions/download-artifact@v4
  96. with:
  97. path: artifacts
  98. - name: Attach binaries to GitHub Release
  99. uses: softprops/action-gh-release@v2
  100. with:
  101. files: artifacts/**/*.tar.gz
  102. fail_on_unmatched_files: false