Skip to content

Commit 9807185

Browse files
authored
ci(desktop): rewrite publish workflow + add PR smoke build (#781)
publish-desktop.yml was carrying the old desktop app's build steps (`bunx tsc` + downloading a CLI release asset into resources/), which don't apply to the new architecture. Rewrite to: - `bun run --filter @executor-js/local build` for the web app. - `bun ./scripts/build-sidecar.ts` (with BUN_TARGET set per matrix entry) to cross-compile the Bun sidecar binary and stage the web UI under `apps/desktop/resources/`. - `bunx electron-vite build` for main/preload/renderer. - `bunx electron-builder --<platform> --<arch> --publish never` and attach artifacts (dmg/zip/exe/AppImage/deb/rpm + latest*.yml metadata files for electron-updater) to the release. Also adds a `Desktop smoke build` job to ci.yml that runs the same sidecar + electron-vite build pipeline on Linux for every PR, so electron-vite/electron-builder breakage gets caught before merge. build-sidecar.ts now honors the `BUN_TARGET` env var so the same script works for native dev builds and for CI cross-compiling to the four release targets.
1 parent 19c893c commit 9807185

3 files changed

Lines changed: 67 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,28 @@ jobs:
7373
- run: bun install --frozen-lockfile
7474

7575
- run: bun run test
76+
77+
desktop-smoke:
78+
name: Desktop smoke build
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- uses: oven-sh/setup-bun@v2
84+
with:
85+
bun-version: 1.3.11
86+
87+
- run: bun install --frozen-lockfile
88+
89+
- name: Build web app
90+
run: bun run --filter @executor-js/local build
91+
92+
- name: Build sidecar + stage web UI
93+
env:
94+
BUN_TARGET: bun-linux-x64
95+
run: bun ./scripts/build-sidecar.ts
96+
working-directory: apps/desktop
97+
98+
- name: Build Electron main/preload/renderer
99+
run: bunx --bun electron-vite build
100+
working-directory: apps/desktop

.github/workflows/publish-desktop.yml

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Publish Desktop App
22
run-name: "${{ format('publish desktop {0}', github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name) }}"
33

4+
# Triggered manually or by publish-executor-package.yml after a CLI release
5+
# lands. Builds Electron distributables for mac/win/linux with the Bun-compiled
6+
# sidecar bundled in `resources/sidecar/`, then attaches them to the GitHub
7+
# release matching the tag so electron-updater can pick them up.
8+
49
on:
510
workflow_dispatch:
611
inputs:
@@ -27,19 +32,19 @@ jobs:
2732
- os: macos-latest
2833
arch: arm64
2934
platform: mac
30-
cli-asset: executor-darwin-arm64.zip
35+
bun-target: bun-darwin-arm64
3136
- os: macos-latest
3237
arch: x64
3338
platform: mac
34-
cli-asset: executor-darwin-x64.zip
39+
bun-target: bun-darwin-x64
3540
- os: ubuntu-latest
3641
arch: x64
3742
platform: linux
38-
cli-asset: executor-linux-x64.tar.gz
43+
bun-target: bun-linux-x64
3944
- os: windows-latest
4045
arch: x64
4146
platform: win
42-
cli-asset: executor-windows-x64.zip
47+
bun-target: bun-windows-x64
4348

4449
runs-on: ${{ matrix.os }}
4550

@@ -77,52 +82,25 @@ jobs:
7782
run: bun install --frozen-lockfile
7883

7984
- name: Build web app
80-
run: bun run build
81-
working-directory: apps/local
85+
run: bun run --filter @executor-js/local build
8286

83-
- name: Download and extract CLI sidecar (unix)
84-
if: matrix.platform != 'win'
87+
- name: Build sidecar binary + stage web UI
8588
env:
86-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87-
run: |
88-
mkdir -p apps/desktop/resources
89-
gh release download "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --pattern "${{ matrix.cli-asset }}" --dir /tmp/cli-download
90-
cd /tmp/cli-download
91-
if [[ "${{ matrix.cli-asset }}" == *.tar.gz ]]; then
92-
tar -xzf "${{ matrix.cli-asset }}"
93-
else
94-
unzip -o "${{ matrix.cli-asset }}"
95-
fi
96-
cp executor "${{ github.workspace }}/apps/desktop/resources/executor"
97-
chmod +x "${{ github.workspace }}/apps/desktop/resources/executor"
98-
if [ -f emscripten-module.wasm ]; then
99-
cp emscripten-module.wasm "${{ github.workspace }}/apps/desktop/resources/"
100-
fi
101-
102-
- name: Download and extract CLI sidecar (windows)
103-
if: matrix.platform == 'win'
104-
env:
105-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106-
shell: pwsh
107-
run: |
108-
New-Item -ItemType Directory -Force -Path "apps/desktop/resources"
109-
gh release download "$env:RELEASE_TAG" --repo "$env:GITHUB_REPOSITORY" --pattern "${{ matrix.cli-asset }}" --dir "$env:TEMP/cli-download"
110-
Expand-Archive -Path "$env:TEMP/cli-download/${{ matrix.cli-asset }}" -DestinationPath "$env:TEMP/cli-extract" -Force
111-
Copy-Item "$env:TEMP/cli-extract/executor.exe" "apps/desktop/resources/executor.exe"
112-
if (Test-Path "$env:TEMP/cli-extract/emscripten-module.wasm") {
113-
Copy-Item "$env:TEMP/cli-extract/emscripten-module.wasm" "apps/desktop/resources/"
114-
}
115-
116-
- name: Build desktop app (TypeScript)
117-
run: bunx tsc -p tsconfig.json
89+
BUN_TARGET: ${{ matrix.bun-target }}
90+
run: bun ./scripts/build-sidecar.ts
11891
working-directory: apps/desktop
11992

120-
- name: Prepare Linux package output directory
121-
if: matrix.platform == 'linux'
122-
run: mkdir -p apps/desktop/dist/@executor-js
93+
- name: Build Electron main/preload/renderer
94+
run: bunx --bun electron-vite build
95+
working-directory: apps/desktop
12396

12497
- name: Build desktop distributables
125-
run: npx electron-builder --${{ matrix.platform }} --${{ matrix.arch }}
98+
env:
99+
# electron-builder reads GH_TOKEN for the publish step. We use
100+
# --publish never here and attach assets explicitly in the release
101+
# job so we don't fight electron-updater's metadata expectations.
102+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
run: bunx --bun electron-builder --${{ matrix.platform }} --${{ matrix.arch }} --publish never --config electron-builder.config.ts
126104
working-directory: apps/desktop
127105

128106
- name: Upload artifacts
@@ -131,9 +109,12 @@ jobs:
131109
name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
132110
path: |
133111
apps/desktop/dist/*.dmg
112+
apps/desktop/dist/*.zip
134113
apps/desktop/dist/*.exe
135114
apps/desktop/dist/*.AppImage
136115
apps/desktop/dist/*.deb
116+
apps/desktop/dist/*.rpm
117+
apps/desktop/dist/latest*.yml
137118
if-no-files-found: warn
138119

139120
release:
@@ -168,7 +149,10 @@ jobs:
168149
env:
169150
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170151
run: |
171-
find artifacts -type f \( -name "*.dmg" -o -name "*.exe" -o -name "*.AppImage" -o -name "*.deb" \) | while read file; do
152+
find artifacts -type f \
153+
\( -name "*.dmg" -o -name "*.zip" -o -name "*.exe" \
154+
-o -name "*.AppImage" -o -name "*.deb" -o -name "*.rpm" \
155+
-o -name "latest*.yml" \) | while read file; do
172156
echo "Uploading: $file"
173157
gh release upload "$RELEASE_TAG" "$file" --repo "$GITHUB_REPOSITORY" --clobber || true
174158
done

apps/desktop/scripts/build-sidecar.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ const APPS_LOCAL_DIST = resolve(APPS_LOCAL, "dist");
3131
const EMBEDDED_MIGRATIONS_PATH = join(APPS_LOCAL, "src/server/embedded-migrations.gen.ts");
3232
const EMBEDDED_MIGRATIONS_STUB = `const migrations: Record<string, string> | null = null;\n\nexport default migrations;\n`;
3333

34-
const binaryName = process.platform === "win32" ? "executor-sidecar.exe" : "executor-sidecar";
34+
/**
35+
* Cross-compile target for `bun build --compile`. When unset we use Bun's
36+
* default `bun` target (the runner's own platform). CI passes a specific
37+
* value like `bun-darwin-x64` to produce binaries for other platforms from
38+
* a single matrix entry.
39+
*/
40+
const BUN_TARGET = process.env.BUN_TARGET ?? "bun";
41+
const targetIsWindows = BUN_TARGET.includes("windows") || process.platform === "win32";
42+
const binaryName = targetIsWindows ? "executor-sidecar.exe" : "executor-sidecar";
3543
const sidecarBinary = resolve(SIDECAR_OUT_DIR, binaryName);
3644

3745
const createEmbeddedMigrationsSource = async (): Promise<string> => {
@@ -74,8 +82,10 @@ await writeFile(EMBEDDED_MIGRATIONS_PATH, `${embeddedMigrations}\n`);
7482

7583
// oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: ensure the gen stub is restored even if compile fails
7684
try {
77-
console.log(`[build-sidecar] bun build --compile ${SIDECAR_ENTRY}${sidecarBinary}`);
78-
await $`bun build --compile --minify --sourcemap --target=bun --outfile ${sidecarBinary} ${SIDECAR_ENTRY}`.cwd(
85+
console.log(
86+
`[build-sidecar] bun build --compile --target=${BUN_TARGET} ${SIDECAR_ENTRY}${sidecarBinary}`,
87+
);
88+
await $`bun build --compile --minify --sourcemap --target=${BUN_TARGET} --outfile ${sidecarBinary} ${SIDECAR_ENTRY}`.cwd(
7989
REPO_ROOT,
8090
);
8191
} finally {

0 commit comments

Comments
 (0)