|
| 1 | +name: Publish Desktop App |
| 2 | +run-name: "${{ format('publish desktop {0}', github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name) }}" |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + tag: |
| 11 | + description: Git tag to publish |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: publish-desktop-${{ github.ref }} |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - os: macos-latest |
| 29 | + arch: arm64 |
| 30 | + platform: mac |
| 31 | + - os: macos-13 |
| 32 | + arch: x64 |
| 33 | + platform: mac |
| 34 | + - os: ubuntu-latest |
| 35 | + arch: x64 |
| 36 | + platform: linux |
| 37 | + - os: windows-latest |
| 38 | + arch: x64 |
| 39 | + platform: win |
| 40 | + |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }} |
| 48 | + |
| 49 | + - name: Setup Bun |
| 50 | + uses: oven-sh/setup-bun@v2 |
| 51 | + with: |
| 52 | + bun-version: 1.3.11 |
| 53 | + |
| 54 | + - name: Setup Node |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: 24 |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: bun install --frozen-lockfile |
| 61 | + |
| 62 | + - name: Build web app |
| 63 | + run: bun run build |
| 64 | + working-directory: apps/web |
| 65 | + |
| 66 | + - name: Build CLI sidecar binary |
| 67 | + run: bun run src/build.ts binary --single |
| 68 | + working-directory: apps/cli |
| 69 | + |
| 70 | + - name: Copy sidecar to desktop resources |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + mkdir -p apps/desktop/resources |
| 74 | + if [ "${{ matrix.platform }}" = "win" ]; then |
| 75 | + BINARY_NAME="executor.exe" |
| 76 | + else |
| 77 | + BINARY_NAME="executor" |
| 78 | + fi |
| 79 | +
|
| 80 | + PLATFORM="${{ matrix.platform == 'mac' && 'darwin' || matrix.platform == 'win' && 'windows' || 'linux' }}" |
| 81 | + ARCH="${{ matrix.arch }}" |
| 82 | + SRC="apps/cli/dist/executor-${PLATFORM}-${ARCH}/bin" |
| 83 | +
|
| 84 | + cp "${SRC}/${BINARY_NAME}" "apps/desktop/resources/${BINARY_NAME}" |
| 85 | + chmod +x "apps/desktop/resources/${BINARY_NAME}" 2>/dev/null || true |
| 86 | +
|
| 87 | + if [ -f "${SRC}/emscripten-module.wasm" ]; then |
| 88 | + cp "${SRC}/emscripten-module.wasm" "apps/desktop/resources/" |
| 89 | + fi |
| 90 | +
|
| 91 | + - name: Build desktop app (TypeScript) |
| 92 | + run: npx tsc -p tsconfig.json |
| 93 | + working-directory: apps/desktop |
| 94 | + |
| 95 | + - name: Build desktop distributables |
| 96 | + env: |
| 97 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + run: npx electron-builder --${{ matrix.platform }} --${{ matrix.arch }} --publish never |
| 99 | + working-directory: apps/desktop |
| 100 | + |
| 101 | + - name: Upload artifacts |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: desktop-${{ matrix.platform }}-${{ matrix.arch }} |
| 105 | + path: | |
| 106 | + apps/desktop/dist/*.dmg |
| 107 | + apps/desktop/dist/*.zip |
| 108 | + apps/desktop/dist/*.exe |
| 109 | + apps/desktop/dist/*.AppImage |
| 110 | + apps/desktop/dist/*.deb |
| 111 | + if-no-files-found: warn |
| 112 | + |
| 113 | + release: |
| 114 | + needs: build |
| 115 | + runs-on: ubuntu-latest |
| 116 | + |
| 117 | + steps: |
| 118 | + - name: Download all artifacts |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + path: artifacts |
| 122 | + merge-multiple: true |
| 123 | + |
| 124 | + - name: List artifacts |
| 125 | + run: find artifacts -type f | head -20 |
| 126 | + |
| 127 | + - name: Upload to GitHub Release |
| 128 | + env: |
| 129 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} |
| 131 | + run: | |
| 132 | + # Wait for the CLI release to create the GitHub release first |
| 133 | + for i in $(seq 1 30); do |
| 134 | + if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 135 | + echo "Release $TAG found" |
| 136 | + break |
| 137 | + fi |
| 138 | + echo "Waiting for release $TAG to be created... ($i/30)" |
| 139 | + sleep 10 |
| 140 | + done |
| 141 | +
|
| 142 | + # Upload desktop artifacts |
| 143 | + find artifacts -type f \( -name "*.dmg" -o -name "*.zip" -o -name "*.exe" -o -name "*.AppImage" -o -name "*.deb" \) | while read file; do |
| 144 | + echo "Uploading: $file" |
| 145 | + gh release upload "$TAG" "$file" --repo "$GITHUB_REPOSITORY" --clobber || true |
| 146 | + done |
0 commit comments