Skip to content

Commit 72ef366

Browse files
committed
fix(release): allow signed releases without Windows
1 parent 106f213 commit 72ef366

3 files changed

Lines changed: 67 additions & 17 deletions

File tree

.github/scripts/create-desktop-update-manifest.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ const platformArtifacts = [
2323
'darwin-x86_64',
2424
),
2525
],
26-
['windows-x86_64', selectArtifact(assets, /-setup\.exe$/i, 'windows-x86_64')],
26+
[
27+
'windows-x86_64',
28+
selectArtifact(assets, /-setup\.exe$/i, 'windows-x86_64', true),
29+
],
2730
['linux-x86_64', selectArtifact(assets, /\.AppImage$/i, 'linux-x86_64')],
2831
];
2932

3033
for (const [platform, artifact] of platformArtifacts) {
34+
if (!artifact) continue;
3135
const signatureFile = `${artifact}.sig`;
3236
if (!assets.includes(signatureFile)) {
3337
throw new Error(`Missing updater signature for ${artifact}`);
@@ -47,8 +51,9 @@ const manifest = {
4751
};
4852
fs.writeFileSync(options.output, `${JSON.stringify(manifest, null, 2)}\n`);
4953

50-
function selectArtifact(assets, pattern, platform) {
54+
function selectArtifact(assets, pattern, platform, optional = false) {
5155
const matches = assets.filter((asset) => pattern.test(asset));
56+
if (optional && matches.length === 0) return undefined;
5257
if (matches.length !== 1) {
5358
throw new Error(
5459
`Expected one updater artifact for ${platform}, found ${matches.length}: ${matches.join(', ')}`,

.github/workflows/desktop-build.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,10 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
include:
39-
- name: 'macOS Apple Silicon'
40-
os: 'macos-15'
41-
target: 'aarch64-apple-darwin'
42-
legacy_arch: 'arm64'
43-
- name: 'macOS Intel'
44-
os: 'macos-15-intel'
45-
target: 'x86_64-apple-darwin'
46-
legacy_arch: 'x64'
47-
- name: 'Windows x64'
48-
os: 'windows-2025'
49-
target: 'x86_64-pc-windows-msvc'
50-
- name: 'Linux x64'
51-
os: 'ubuntu-22.04'
52-
target: 'x86_64-unknown-linux-gnu'
38+
include: >-
39+
${{ fromJSON(inputs.publish &&
40+
'[{"name":"macOS Apple Silicon","os":"macos-15","target":"aarch64-apple-darwin","legacy_arch":"arm64"},{"name":"macOS Intel","os":"macos-15-intel","target":"x86_64-apple-darwin","legacy_arch":"x64"},{"name":"Linux x64","os":"ubuntu-22.04","target":"x86_64-unknown-linux-gnu"}]' ||
41+
'[{"name":"macOS Apple Silicon","os":"macos-15","target":"aarch64-apple-darwin","legacy_arch":"arm64"},{"name":"macOS Intel","os":"macos-15-intel","target":"x86_64-apple-darwin","legacy_arch":"x64"},{"name":"Windows x64","os":"windows-2025","target":"x86_64-pc-windows-msvc"},{"name":"Linux x64","os":"ubuntu-22.04","target":"x86_64-unknown-linux-gnu"}]') }}
5342
steps:
5443
- name: 'Check out source'
5544
uses: 'actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10' # v6.0.3
@@ -352,6 +341,9 @@ jobs:
352341
for manifest in macos:latest-mac.yml windows:latest.yml linux:latest-linux.yml; do
353342
platform="${manifest%%:*}"
354343
output="${manifest#*:}"
344+
if [[ "$platform" == 'windows' ]] && ! compgen -G 'release-assets/*-setup.exe' >/dev/null; then
345+
continue
346+
fi
355347
node .github/scripts/create-electron-bridge-manifest.mjs --assets release-assets --platform "$platform" --version "$RELEASE_VERSION" --output "release-assets/$output"
356348
done
357349
fi

packages/desktop-shell/scripts/test-release.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const electronBridgeScript = path.join(
2222
'scripts',
2323
'create-electron-bridge-manifest.mjs',
2424
);
25+
const desktopUpdateScript = path.join(
26+
packageDir,
27+
'..',
28+
'..',
29+
'.github',
30+
'scripts',
31+
'create-desktop-update-manifest.mjs',
32+
);
2533
const root = fs.mkdtempSync(
2634
path.join(os.tmpdir(), 'openwork-desktop-release-test-'),
2735
);
@@ -32,6 +40,7 @@ try {
3240
testMacosPermissions();
3341
testReleaseWorkflow();
3442
testRuntimePreparationContract();
43+
testDesktopUpdateManifest(path.join(root, 'desktop-update'));
3544
testElectronBridgeManifest(path.join(root, 'electron-bridge'));
3645
testChecksumRefresh(path.join(root, 'checksums'));
3746
testVersionSynchronization(path.join(root, 'version'));
@@ -258,10 +267,54 @@ function testReleaseWorkflow() {
258267
/if: '?inputs\.dry_run == false'?[\s\S]*contents: '?write'?/,
259268
);
260269
assert.match(publishJob, /secrets: '?inherit'?/);
270+
const matrices = buildWorkflow.match(
271+
/fromJSON\(inputs\.publish &&\s*'([^']+)' \|\|\s*'([^']+)'\)/,
272+
);
273+
assert.ok(matrices);
274+
assert.equal(
275+
JSON.parse(matrices[1]).some(({ os }) => os.startsWith('windows-')),
276+
false,
277+
);
278+
assert.equal(
279+
JSON.parse(matrices[2]).some(({ os }) => os.startsWith('windows-')),
280+
true,
281+
);
261282
assert.doesNotMatch(workflow, /uses: [^\n]+@(v\d|stable)\b/);
262283
assert.doesNotMatch(workflow, /push --force|force-with-lease/);
263284
}
264285

286+
function testDesktopUpdateManifest(directory) {
287+
const assets = path.join(directory, 'assets');
288+
const output = path.join(directory, 'latest.json');
289+
fs.mkdirSync(assets, { recursive: true });
290+
for (const artifact of [
291+
'OpenWork-aarch64-apple-darwin.app.tar.gz',
292+
'OpenWork-x86_64-apple-darwin.app.tar.gz',
293+
'OpenWork_0.2.1_amd64.AppImage',
294+
]) {
295+
fs.writeFileSync(path.join(assets, artifact), artifact);
296+
fs.writeFileSync(path.join(assets, `${artifact}.sig`), `signature:${artifact}`);
297+
}
298+
execFileSync(process.execPath, [
299+
desktopUpdateScript,
300+
'--assets',
301+
assets,
302+
'--repository',
303+
'modelstudioai/openwork',
304+
'--tag',
305+
'openwork-v0.2.1',
306+
'--version',
307+
'0.2.1',
308+
'--output',
309+
output,
310+
]);
311+
assert.deepEqual(Object.keys(JSON.parse(fs.readFileSync(output)).platforms), [
312+
'darwin-aarch64',
313+
'darwin-x86_64',
314+
'linux-x86_64',
315+
]);
316+
}
317+
265318
function testElectronBridgeManifest(directory) {
266319
const assets = path.join(directory, 'assets');
267320
fs.mkdirSync(assets, { recursive: true });

0 commit comments

Comments
 (0)