|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, dev] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: [main, dev] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + # 多平台二进制构建 |
| 13 | + build-binary: |
| 14 | + name: Build ${{ matrix.target }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + # Linux builds |
| 21 | + - os: ubuntu-latest |
| 22 | + target: linux-x64 |
| 23 | + artifact: memo-linux-x64 |
| 24 | + - os: ubuntu-latest |
| 25 | + target: linux-arm64 |
| 26 | + artifact: memo-linux-arm64 |
| 27 | + |
| 28 | + # macOS builds |
| 29 | + - os: macos-latest |
| 30 | + target: darwin-x64 |
| 31 | + artifact: memo-darwin-x64 |
| 32 | + - os: macos-latest |
| 33 | + target: darwin-arm64 |
| 34 | + artifact: memo-darwin-arm64 |
| 35 | + |
| 36 | + # Windows build |
| 37 | + - os: windows-latest |
| 38 | + target: windows-x64 |
| 39 | + artifact: memo-windows-x64.exe |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Setup Bun |
| 46 | + uses: oven-sh/setup-bun@v1 |
| 47 | + |
| 48 | + - name: Install ripgrep (Linux) |
| 49 | + if: runner.os == 'Linux' |
| 50 | + run: sudo apt-get update && sudo apt-get install -y ripgrep |
| 51 | + |
| 52 | + - name: Install ripgrep (macOS) |
| 53 | + if: runner.os == 'macOS' |
| 54 | + run: brew install ripgrep |
| 55 | + |
| 56 | + - name: Install ripgrep (Windows) |
| 57 | + if: runner.os == 'Windows' |
| 58 | + run: choco install ripgrep -y |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: bun install |
| 62 | + |
| 63 | + - name: Build binary (Unix) |
| 64 | + if: runner.os != 'Windows' |
| 65 | + run: bun build packages/cli/src/index.tsx --target=bun --compile --outfile=${{ matrix.artifact }} |
| 66 | + |
| 67 | + - name: Build binary (Windows) |
| 68 | + if: runner.os == 'Windows' |
| 69 | + run: bun build packages/cli/src/index.tsx --target=bun --compile --outfile=${{ matrix.artifact }} |
| 70 | + |
| 71 | + - name: Test binary (Unix) |
| 72 | + if: runner.os != 'Windows' |
| 73 | + run: ./${{ matrix.artifact }} --help |
| 74 | + |
| 75 | + - name: Test binary (Windows) |
| 76 | + if: runner.os == 'Windows' |
| 77 | + run: .\${{ matrix.artifact }} --help |
| 78 | + |
| 79 | + - name: Upload artifact |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: ${{ matrix.artifact }} |
| 83 | + path: ${{ matrix.artifact }} |
| 84 | + retention-days: 7 |
| 85 | + |
| 86 | + # 汇总构建结果 |
| 87 | + build-summary: |
| 88 | + name: Build Summary |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: build-binary |
| 91 | + if: always() |
| 92 | + steps: |
| 93 | + - name: Check build status |
| 94 | + run: | |
| 95 | + echo "All builds completed" |
| 96 | + if [ "${{ needs.build-binary.result }}" != "success" ]; then |
| 97 | + echo "Some builds failed" |
| 98 | + exit 1 |
| 99 | + fi |
0 commit comments