|
| 1 | +name: Build Multi-Platform Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-macos-intel: |
| 9 | + runs-on: macos-latest |
| 10 | + outputs: |
| 11 | + artifact_id: ${{ steps.upload.outputs.artifact-id }} |
| 12 | + artifact_url: ${{ steps.upload.outputs.artifact-url }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - name: Setup Flutter |
| 16 | + uses: subosito/flutter-action@v2 |
| 17 | + with: |
| 18 | + flutter-version: '3.32.0' |
| 19 | + - name: Install dependencies |
| 20 | + run: flutter pub get |
| 21 | + - name: Setup Dart |
| 22 | + uses: dart-lang/setup-dart@v1 |
| 23 | + - name: Build macOS Intel |
| 24 | + run: dart compile exe bin/main.dart -o api_tool_macos_intel |
| 25 | + - name: Upload Artifact |
| 26 | + id: upload |
| 27 | + uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: api_tool_macos_intel |
| 30 | + path: api_tool_macos_intel |
| 31 | + |
| 32 | + build-macos-arm64: |
| 33 | + runs-on: macos-latest |
| 34 | + outputs: |
| 35 | + artifact_id: ${{ steps.upload.outputs.artifact-id }} |
| 36 | + artifact_url: ${{ steps.upload.outputs.artifact-url }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + - name: Setup Flutter |
| 40 | + uses: subosito/flutter-action@v2 |
| 41 | + with: |
| 42 | + flutter-version: '3.32.0' |
| 43 | + - name: Install dependencies |
| 44 | + run: flutter pub get |
| 45 | + - name: Setup Dart |
| 46 | + uses: dart-lang/setup-dart@v1 |
| 47 | + - name: Build macOS ARM64 |
| 48 | + run: dart compile exe bin/main.dart -o api_tool_macos_arm64 --target-os=macos --target-arch=arm64 |
| 49 | + - name: Upload Artifact |
| 50 | + id: upload |
| 51 | + uses: actions/upload-artifact@v4 |
| 52 | + with: |
| 53 | + name: api_tool_macos_arm64 |
| 54 | + path: api_tool_macos_arm64 |
| 55 | + |
| 56 | + build-linux-x64: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + outputs: |
| 59 | + artifact_id: ${{ steps.upload.outputs.artifact-id }} |
| 60 | + artifact_url: ${{ steps.upload.outputs.artifact-url }} |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - name: Setup Flutter |
| 64 | + uses: subosito/flutter-action@v2 |
| 65 | + with: |
| 66 | + flutter-version: '3.32.0' |
| 67 | + - name: Install dependencies |
| 68 | + run: flutter pub get |
| 69 | + - name: Setup Dart |
| 70 | + uses: dart-lang/setup-dart@v1 |
| 71 | + - name: Build Linux x64 |
| 72 | + run: dart compile exe bin/main.dart -o api_tool_linux |
| 73 | + - name: Upload Artifact |
| 74 | + id: upload |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: api_tool_linux |
| 78 | + path: api_tool_linux |
| 79 | + |
| 80 | + build-windows-x64: |
| 81 | + runs-on: windows-latest |
| 82 | + outputs: |
| 83 | + artifact_id: ${{ steps.upload.outputs.artifact-id }} |
| 84 | + artifact_url: ${{ steps.upload.outputs.artifact-url }} |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + - name: Setup Flutter |
| 88 | + uses: subosito/flutter-action@v2 |
| 89 | + with: |
| 90 | + flutter-version: '3.32.0' |
| 91 | + - name: Install dependencies |
| 92 | + run: flutter pub get |
| 93 | + - name: Setup Dart |
| 94 | + uses: dart-lang/setup-dart@v1 |
| 95 | + - name: Build Windows x64 |
| 96 | + run: dart compile exe bin/main.dart -o api_tool_windows |
| 97 | + - name: Upload Artifact |
| 98 | + id: upload |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: api_tool_windows |
| 102 | + path: api_tool_windows |
| 103 | + |
| 104 | + comment-on-pr: |
| 105 | + needs: [build-macos-intel, build-macos-arm64, build-linux-x64, build-windows-x64] |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - name: Find Comment |
| 109 | + id: find-comment |
| 110 | + uses: peter-evans/find-comment@v3 |
| 111 | + with: |
| 112 | + issue-number: ${{ github.event.pull_request.number }} |
| 113 | + comment-author: 'github-actions[bot]' |
| 114 | + body-includes: 编译完成,产物如下 |
| 115 | + |
| 116 | + - name: Create or Update PR Comment |
| 117 | + uses: peter-evans/create-or-update-comment@v4 |
| 118 | + with: |
| 119 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 120 | + issue-number: ${{ github.event.pull_request.number }} |
| 121 | + body: | |
| 122 | + ✅ 编译完成,产物如下: |
| 123 | + - [api_tool_macos_intel](${{ needs.build-macos-intel.outputs.artifact_url }}) |
| 124 | + - [api_tool_macos_arm64](${{ needs.build-macos-arm64.outputs.artifact_url }}) |
| 125 | + - [api_tool_linux](${{ needs.build-linux-x64.outputs.artifact_url }}) |
| 126 | + - [api_tool_windows](${{ needs.build-windows-x64.outputs.artifact_url }}) |
| 127 | + edit-mode: replace |
0 commit comments