|
| 1 | +name: Build Engine |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' # 触发:推送 v1.2.3 格式的 tag |
| 7 | + workflow_dispatch: # 允许手动触发(调试用) |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write # 允许创建 Release 并上传附件 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build (${{ matrix.os }}) |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: windows-latest |
| 21 | + artifact_name: testpilot-engine-windows.exe |
| 22 | + exe_path: dist/testpilot-engine.exe |
| 23 | + - os: macos-latest |
| 24 | + artifact_name: testpilot-engine-macos |
| 25 | + exe_path: dist/testpilot-engine |
| 26 | + - os: ubuntu-latest |
| 27 | + artifact_name: testpilot-engine-linux |
| 28 | + exe_path: dist/testpilot-engine |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Python 3.10 |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.10' |
| 38 | + |
| 39 | + - name: Install Poetry |
| 40 | + uses: snok/install-poetry@v1 |
| 41 | + with: |
| 42 | + version: '1.8.5' |
| 43 | + virtualenvs-create: true |
| 44 | + virtualenvs-in-project: true |
| 45 | + |
| 46 | + - name: Cache Poetry venv |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: .venv |
| 50 | + key: venv-${{ runner.os }}-py310-${{ hashFiles('poetry.lock') }} |
| 51 | + restore-keys: | |
| 52 | + venv-${{ runner.os }}-py310- |
| 53 | +
|
| 54 | + - name: Install dependencies |
| 55 | + run: poetry install --no-interaction --no-root |
| 56 | + |
| 57 | + - name: Install Playwright browsers |
| 58 | + run: poetry run playwright install chromium |
| 59 | + |
| 60 | + - name: Install PyInstaller |
| 61 | + run: poetry run pip install pyinstaller --quiet |
| 62 | + |
| 63 | + - name: Build with PyInstaller |
| 64 | + run: poetry run pyinstaller testpilot_engine.spec --clean --noconfirm |
| 65 | + |
| 66 | + - name: Rename artifact (Windows) |
| 67 | + if: matrix.os == 'windows-latest' |
| 68 | + run: mv dist/testpilot-engine.exe dist/${{ matrix.artifact_name }} |
| 69 | + shell: bash |
| 70 | + |
| 71 | + - name: Rename artifact (macOS/Linux) |
| 72 | + if: matrix.os != 'windows-latest' |
| 73 | + run: mv dist/testpilot-engine dist/${{ matrix.artifact_name }} |
| 74 | + |
| 75 | + - name: Upload artifact |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: ${{ matrix.artifact_name }} |
| 79 | + path: dist/${{ matrix.artifact_name }} |
| 80 | + retention-days: 7 |
| 81 | + |
| 82 | + release: |
| 83 | + name: Create Release |
| 84 | + needs: build |
| 85 | + runs-on: ubuntu-latest |
| 86 | + if: startsWith(github.ref, 'refs/tags/') |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Download all artifacts |
| 90 | + uses: actions/download-artifact@v4 |
| 91 | + with: |
| 92 | + path: artifacts/ |
| 93 | + |
| 94 | + - name: Create GitHub Release |
| 95 | + uses: softprops/action-gh-release@v2 |
| 96 | + with: |
| 97 | + name: TestPilot Engine ${{ github.ref_name }} |
| 98 | + body: | |
| 99 | + ## TestPilot AI 引擎 ${{ github.ref_name }} |
| 100 | +
|
| 101 | + 下载对应平台的引擎文件,放到任意目录后双击运行即可。 |
| 102 | + 无需安装 Python、Node.js 或任何依赖。 |
| 103 | +
|
| 104 | + | 平台 | 文件 | 说明 | |
| 105 | + |------|------|------| |
| 106 | + | Windows | `testpilot-engine-windows.exe` | 双击运行 | |
| 107 | + | macOS | `testpilot-engine-macos` | `chmod +x` 后运行 | |
| 108 | + | Linux | `testpilot-engine-linux` | `chmod +x` 后运行 | |
| 109 | +
|
| 110 | + 引擎启动后在 `http://127.0.0.1:8900` 提供服务,VS Code 插件会自动连接。 |
| 111 | + files: | |
| 112 | + artifacts/testpilot-engine-windows.exe/testpilot-engine-windows.exe |
| 113 | + artifacts/testpilot-engine-macos/testpilot-engine-macos |
| 114 | + artifacts/testpilot-engine-linux/testpilot-engine-linux |
| 115 | + draft: false |
| 116 | + prerelease: false |
0 commit comments