Skip to content

Commit f71689b

Browse files
authored
fix(updater): prevent architecture mismatch updates (anomalyco#1715)
* fix(updater): prevent architecture mismatch updates * fix(updater): resolve recovery download from latest feed --------- Co-authored-by: src-opn <[email protected]>
1 parent 5073fed commit f71689b

7 files changed

Lines changed: 578 additions & 23 deletions

File tree

‎.github/workflows/release-macos-aarch64.yml‎

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ jobs:
281281
artifact: electron-windows-x64
282282
electron_args: "--win --x64"
283283
target_triple: x86_64-pc-windows-msvc
284+
- platform: windows-2022
285+
os_type: windows
286+
artifact: electron-windows-arm64
287+
electron_args: "--win --arm64"
288+
target_triple: aarch64-pc-windows-msvc
284289

285290
steps:
286291
- name: Checkout
@@ -374,44 +379,83 @@ jobs:
374379
TARGET: ${{ matrix.target_triple }}
375380
run: pnpm --filter @openwork/desktop build:electron
376381

377-
- name: Package + publish Electron (macOS, signed + notarized)
382+
- name: Package Electron (macOS, signed + notarized)
378383
if: matrix.os_type == 'macos' && env.MACOS_NOTARIZE == 'true'
379384
env:
380385
CSC_LINK: ${{ secrets.APPLE_CODESIGN_CERT_P12_BASE64 }}
381386
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CODESIGN_CERT_PASSWORD }}
382387
APPLE_API_KEY: ${{ secrets.APPLE_NOTARY_API_KEY_ID }}
383388
APPLE_API_ISSUER: ${{ secrets.APPLE_NOTARY_API_ISSUER_ID }}
384389
APPLE_API_KEY_PATH: ${{ env.NOTARY_KEY_PATH }}
385-
GH_TOKEN: ${{ github.token }}
386390
run: |
387391
set -euo pipefail
388392
pnpm --dir apps/desktop exec electron-builder \
389393
--config electron-builder.yml \
390394
${{ matrix.electron_args }} \
391-
--publish always
395+
--publish never
392396
393-
- name: Package + publish Electron (Linux)
397+
- name: Package Electron (Linux)
394398
if: matrix.os_type == 'linux'
395-
env:
396-
GH_TOKEN: ${{ github.token }}
397399
run: |
398400
set -euo pipefail
399401
pnpm --dir apps/desktop exec electron-builder \
400402
--config electron-builder.yml \
401403
${{ matrix.electron_args }} \
402-
--publish always
404+
--publish never
403405
404-
- name: Package + publish Electron (Windows)
406+
- name: Package Electron (Windows)
405407
if: matrix.os_type == 'windows'
406-
env:
407-
GH_TOKEN: ${{ github.token }}
408408
shell: bash
409409
run: |
410410
set -euo pipefail
411411
pnpm --dir apps/desktop exec electron-builder \
412412
--config electron-builder.yml \
413413
${{ matrix.electron_args }} \
414-
--publish always
414+
--publish never
415+
416+
- name: Upload Electron dist artifact
417+
uses: actions/upload-artifact@v4
418+
with:
419+
name: ${{ matrix.artifact }}
420+
path: apps/desktop/dist-electron/**
421+
if-no-files-found: error
422+
423+
publish-electron-assets:
424+
name: Publish Electron Assets
425+
needs: [resolve-release, verify-release, publish-electron]
426+
if: |
427+
always() &&
428+
needs.resolve-release.outputs.build_electron == 'true' &&
429+
needs.resolve-release.result == 'success' &&
430+
needs.verify-release.result == 'success' &&
431+
needs.publish-electron.result == 'success'
432+
runs-on: blacksmith-4vcpu-ubuntu-2404
433+
env:
434+
RELEASE_TAG: ${{ needs.resolve-release.outputs.release_tag }}
435+
steps:
436+
- name: Checkout
437+
uses: actions/checkout@v6
438+
with:
439+
# Dispatch-based release recovery uses the workflow ref so fixes to
440+
# release asset publishing can run without moving an already-shipped tag.
441+
ref: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || env.RELEASE_TAG }}
442+
fetch-depth: 0
443+
444+
- name: Setup Node
445+
uses: actions/setup-node@v6
446+
with:
447+
node-version-file: .nvmrc
448+
449+
- name: Download Electron dist artifacts
450+
uses: actions/download-artifact@v4
451+
with:
452+
pattern: electron-*
453+
path: ${{ runner.temp }}/electron-dist
454+
455+
- name: Upload release assets and merged updater manifests
456+
env:
457+
GH_TOKEN: ${{ github.token }}
458+
run: node scripts/release/publish-electron-assets.mjs "${{ runner.temp }}/electron-dist" "$RELEASE_TAG"
415459

416460
release-orchestrator-sidecars:
417461
name: Build + Upload openwork-orchestrator Sidecars
@@ -736,6 +780,7 @@ jobs:
736780
- resolve-release
737781
- verify-release
738782
- publish-electron
783+
- publish-electron-assets
739784
- release-orchestrator-sidecars
740785
- publish-npm
741786
- publish-daytona-snapshot
@@ -745,6 +790,7 @@ jobs:
745790
needs.resolve-release.result == 'success' &&
746791
needs.verify-release.result == 'success' &&
747792
(needs.publish-electron.result == 'success' || needs.publish-electron.result == 'skipped') &&
793+
(needs.publish-electron-assets.result == 'success' || needs.publish-electron-assets.result == 'skipped') &&
748794
(needs.release-orchestrator-sidecars.result == 'success' || needs.release-orchestrator-sidecars.result == 'skipped') &&
749795
(needs.publish-npm.result == 'success' || needs.publish-npm.result == 'skipped') &&
750796
(needs.publish-daytona-snapshot.result == 'success' || needs.publish-daytona-snapshot.result == 'skipped')

‎apps/app/src/app/lib/desktop.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ declare global {
3838
openExternal?: (url: string) => Promise<void>;
3939
relaunch?: () => Promise<void>;
4040
};
41+
system?: {
42+
getArchitectureInfo?: () => Promise<{
43+
appArch: string;
44+
appArchLabel: string;
45+
systemArch: string;
46+
systemArchLabel: string;
47+
mismatch: boolean;
48+
platform: "darwin" | "linux" | "windows";
49+
version: string;
50+
downloadUrl: string;
51+
releaseUrl: string;
52+
}>;
53+
};
4154
migration?: {
4255
readSnapshot?: () => Promise<unknown>;
4356
ackSnapshot?: () => Promise<{ ok: boolean; moved: boolean }>;
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/** @jsxImportSource react */
2+
import { useCallback, useEffect, useState, type ReactNode } from "react";
3+
4+
import { isDesktopRuntime } from "../../app/utils";
5+
import { useBootState } from "./boot-state";
6+
7+
type ArchitectureInfo = {
8+
appArch: string;
9+
appArchLabel: string;
10+
systemArch: string;
11+
systemArchLabel: string;
12+
mismatch: boolean;
13+
platform: "darwin" | "linux" | "windows";
14+
version: string;
15+
downloadUrl: string;
16+
releaseUrl: string;
17+
};
18+
19+
type ArchitectureMismatchGateProps = {
20+
children: ReactNode;
21+
};
22+
23+
function platformLabel(platform: ArchitectureInfo["platform"]): string {
24+
if (platform === "darwin") return "macOS";
25+
if (platform === "windows") return "Windows";
26+
return "Linux";
27+
}
28+
29+
export function ArchitectureMismatchGate({ children }: ArchitectureMismatchGateProps) {
30+
const { markRouteReady } = useBootState();
31+
const [info, setInfo] = useState<ArchitectureInfo | null>(null);
32+
const [checked, setChecked] = useState(!isDesktopRuntime());
33+
34+
useEffect(() => {
35+
let cancelled = false;
36+
const bridge = window.__OPENWORK_ELECTRON__?.system?.getArchitectureInfo;
37+
if (!bridge) {
38+
setChecked(true);
39+
return;
40+
}
41+
42+
void bridge()
43+
.then((nextInfo) => {
44+
if (cancelled) return;
45+
setInfo(nextInfo);
46+
})
47+
.catch((error) => {
48+
console.warn("[architecture-gate] failed to resolve runtime architecture", error);
49+
})
50+
.finally(() => {
51+
if (!cancelled) setChecked(true);
52+
});
53+
54+
return () => {
55+
cancelled = true;
56+
};
57+
}, []);
58+
59+
useEffect(() => {
60+
if (info?.mismatch) markRouteReady();
61+
}, [info?.mismatch, markRouteReady]);
62+
63+
const openDownload = useCallback(() => {
64+
const url = info?.downloadUrl || info?.releaseUrl;
65+
if (!url) return;
66+
void window.__OPENWORK_ELECTRON__?.shell?.openExternal?.(url);
67+
}, [info?.downloadUrl, info?.releaseUrl]);
68+
69+
const openRelease = useCallback(() => {
70+
if (!info?.releaseUrl) return;
71+
void window.__OPENWORK_ELECTRON__?.shell?.openExternal?.(info.releaseUrl);
72+
}, [info?.releaseUrl]);
73+
74+
if (!checked) return null;
75+
if (!info?.mismatch) return <>{children}</>;
76+
77+
return (
78+
<main className="min-h-screen bg-[#05070c] text-white">
79+
<div className="mx-auto flex min-h-screen w-full max-w-5xl items-center px-6 py-12">
80+
<section className="w-full overflow-hidden rounded-[32px] border border-white/10 bg-white/[0.04] shadow-2xl shadow-black/40">
81+
<div className="grid gap-0 lg:grid-cols-[1.05fr_0.95fr]">
82+
<div className="space-y-8 p-8 sm:p-10 lg:p-12">
83+
<div className="inline-flex rounded-full border border-amber-300/30 bg-amber-300/10 px-3 py-1 text-xs font-semibold uppercase tracking-[0.24em] text-amber-100">
84+
Architecture mismatch
85+
</div>
86+
<div className="space-y-4">
87+
<h1 className="max-w-2xl text-4xl font-semibold tracking-[-0.04em] text-white sm:text-5xl">
88+
Install the correct OpenWork build
89+
</h1>
90+
<p className="max-w-2xl text-base leading-7 text-white/72 sm:text-lg">
91+
Your application is running the {info.appArchLabel} version of OpenWork, but this {platformLabel(info.platform)} system is {info.systemArchLabel}. This may cause unpredictable issues.
92+
</p>
93+
</div>
94+
95+
<div className="grid gap-3 sm:grid-cols-2">
96+
<div className="rounded-2xl border border-white/10 bg-black/20 p-4">
97+
<div className="text-xs uppercase tracking-[0.2em] text-white/40">Running app</div>
98+
<div className="mt-2 text-2xl font-semibold text-white">{info.appArchLabel}</div>
99+
<div className="mt-1 font-mono text-xs text-white/45">{info.appArch}</div>
100+
</div>
101+
<div className="rounded-2xl border border-emerald-300/20 bg-emerald-300/10 p-4">
102+
<div className="text-xs uppercase tracking-[0.2em] text-emerald-100/70">Your system</div>
103+
<div className="mt-2 text-2xl font-semibold text-emerald-50">{info.systemArchLabel}</div>
104+
<div className="mt-1 font-mono text-xs text-emerald-100/55">{info.systemArch}</div>
105+
</div>
106+
</div>
107+
108+
<div className="flex flex-col gap-3 sm:flex-row">
109+
<button
110+
type="button"
111+
onClick={openDownload}
112+
className="inline-flex items-center justify-center rounded-full bg-white px-5 py-3 text-sm font-semibold text-black transition hover:bg-emerald-100"
113+
>
114+
Download correct version
115+
</button>
116+
<button
117+
type="button"
118+
onClick={openRelease}
119+
className="inline-flex items-center justify-center rounded-full border border-white/14 px-5 py-3 text-sm font-semibold text-white/85 transition hover:bg-white/10"
120+
>
121+
Open release page
122+
</button>
123+
</div>
124+
</div>
125+
126+
<aside className="border-t border-white/10 bg-gradient-to-br from-emerald-300/12 via-sky-300/8 to-transparent p-8 sm:p-10 lg:border-l lg:border-t-0 lg:p-12">
127+
<div className="space-y-5 rounded-[28px] border border-white/10 bg-black/25 p-6 text-sm leading-6 text-white/68">
128+
<div className="text-lg font-semibold text-white">Why OpenWork stopped here</div>
129+
<p>
130+
OpenWork blocks startup when the installed app architecture does not match the machine architecture. This prevents runtime sidecars, browser tooling, and update downloads from continuing on the wrong build.
131+
</p>
132+
<p>
133+
After installing the correct {info.systemArchLabel} build, quit this copy and launch OpenWork again. Your workspaces and settings are kept in the same app data folder.
134+
</p>
135+
<div className="rounded-2xl bg-white/[0.06] p-4 font-mono text-xs text-white/55">
136+
v{info.version} · {platformLabel(info.platform)} · {info.systemArch}
137+
</div>
138+
</div>
139+
</aside>
140+
</div>
141+
</section>
142+
</div>
143+
</main>
144+
);
145+
}

‎apps/app/src/react-app/shell/providers.tsx‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { RestrictionNoticeProvider } from "../domains/cloud/restriction-notice-p
1010
import { StatusToastsProvider } from "../domains/shell-feedback/status-toasts";
1111
import { LocalProvider } from "../kernel/local-provider";
1212
import { ServerProvider } from "../kernel/server-provider";
13+
import { ArchitectureMismatchGate } from "./architecture-mismatch-gate";
1314
import { BootStateProvider } from "./boot-state";
1415
import { DesktopRuntimeBoot } from "./desktop-runtime-boot";
1516
import { startDebugLogger, stopDebugLogger } from "./debug-logger";
@@ -61,18 +62,20 @@ export function AppProviders({ children }: AppProvidersProps) {
6162
return (
6263
<BootStateProvider>
6364
<ServerProvider defaultUrl={defaultUrl}>
64-
<DesktopRuntimeBoot />
65-
<DenAuthProvider>
66-
<DesktopConfigProvider>
67-
<RestrictionNoticeProvider>
68-
<LocalProvider>
69-
<StatusToastsProvider>
70-
<ReloadCoordinatorProvider>{children}</ReloadCoordinatorProvider>
71-
</StatusToastsProvider>
72-
</LocalProvider>
73-
</RestrictionNoticeProvider>
74-
</DesktopConfigProvider>
75-
</DenAuthProvider>
65+
<ArchitectureMismatchGate>
66+
<DesktopRuntimeBoot />
67+
<DenAuthProvider>
68+
<DesktopConfigProvider>
69+
<RestrictionNoticeProvider>
70+
<LocalProvider>
71+
<StatusToastsProvider>
72+
<ReloadCoordinatorProvider>{children}</ReloadCoordinatorProvider>
73+
</StatusToastsProvider>
74+
</LocalProvider>
75+
</RestrictionNoticeProvider>
76+
</DesktopConfigProvider>
77+
</DenAuthProvider>
78+
</ArchitectureMismatchGate>
7679
</ServerProvider>
7780
</BootStateProvider>
7881
);

0 commit comments

Comments
 (0)