-
Notifications
You must be signed in to change notification settings - Fork 6
feat(desktop): add Windows support with an NSIS installer and release job #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9dd2abc
fix(desktop): correct Windows process teardown, artifact guard, and t…
elkaix 70a22fc
feat(desktop): ship a Windows NSIS installer and release job
elkaix 530dc19
fix(desktop): stage the runtime on Windows and skip empty signing cre…
elkaix 815b892
fix(desktop): give pnpm deploy a workspace-relative staging target
elkaix 7321b89
ci: gate the desktop suite and typecheck on pull requests
elkaix d94ba4b
fix(desktop): bound the Windows tree kill and correct the installer docs
elkaix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pymodel/pythinker-desktop': patch | ||
| --- | ||
|
|
||
| Bound the Windows process-tree kill so a stalled taskkill cannot freeze desktop shutdown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pymodel/pythinker-desktop': patch | ||
| --- | ||
|
|
||
| Fix Windows runtime staging and skip empty signing credentials in the desktop release workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pymodel/pythinker-desktop': patch | ||
| --- | ||
|
|
||
| Stage the desktop Host closure inside the workspace so pnpm deploy resolves the target on Windows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pymodel/pythinker-desktop': patch | ||
| --- | ||
|
|
||
| Add the Windows NSIS installer target, release script, and release workflow job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pymodel/pythinker-desktop': patch | ||
| --- | ||
|
|
||
| Fix Windows process-tree shutdown, packaged-runtime guards, and taskbar identity in the desktop app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** Build the Windows NSIS installer from a native Windows host. */ | ||
|
|
||
| import { spawnSync } from 'node:child_process' | ||
| import { dirname, resolve } from 'node:path' | ||
| import { fileURLToPath } from 'node:url' | ||
| import { verifyWindowsInstaller } from './verify-win-installer' | ||
|
|
||
| function run(command: string, args: readonly string[], cwd: string): void { | ||
| const result = spawnSync(command, args, { cwd, stdio: 'inherit', shell: process.platform === 'win32' }) | ||
| if (result.error !== undefined) throw result.error | ||
| if (result.status !== 0) throw new Error(`${command} ${args.join(' ')} exited with ${String(result.status)}`) | ||
| } | ||
|
|
||
| /** Build and verify the unsigned Windows installer. */ | ||
| export function releaseWin(): void { | ||
| if (process.platform !== 'win32') { | ||
| throw new Error('The Windows installer must be built on Windows: the staged Host closure contains platform-specific native packages') | ||
| } | ||
| if (process.arch !== 'x64') { | ||
| throw new Error(`The Windows installer targets x64; this host is ${process.arch}`) | ||
| } | ||
| const desktopRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..') | ||
| run('pnpm', ['--workspace-root', 'run', 'build'], desktopRoot) | ||
| run('node', ['--import', 'tsx', 'scripts/stage-runtime.ts'], desktopRoot) | ||
| run('pnpm', ['exec', 'electron-builder', '--win', 'nsis', '--x64', '--publish', 'never'], desktopRoot) | ||
| verifyWindowsInstaller(desktopRoot) | ||
| } | ||
|
|
||
| const invokedPath = process.argv[1] | ||
| if (invokedPath !== undefined && resolve(invokedPath) === fileURLToPath(import.meta.url)) { | ||
| try { | ||
| releaseWin() | ||
| } catch (error) { | ||
| console.error(error instanceof Error ? error.message : String(error)) | ||
| process.exitCode = 1 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** Reject a Windows release whose installer or unpacked shell is not a real PE binary. */ | ||
|
|
||
| import { openSync, readSync, closeSync, statSync, readFileSync } from 'node:fs' | ||
| import { join } from 'node:path' | ||
|
|
||
| const MINIMUM_PE_BYTES = 0x40 + 4 | ||
|
|
||
| function assertPortableExecutable(path: string): void { | ||
| const stats = statSync(path) | ||
| if (!stats.isFile()) throw new Error(`Windows release artifact is not a regular file: ${path}`) | ||
| if (stats.size < MINIMUM_PE_BYTES) throw new Error(`Windows release artifact is too small to be a PE image: ${path}`) | ||
| const handle = openSync(path, 'r') | ||
| try { | ||
| const header = Buffer.alloc(0x40) | ||
| readSync(handle, header, 0, header.length, 0) | ||
| if (header.toString('latin1', 0, 2) !== 'MZ') throw new Error(`Windows release artifact has no DOS header: ${path}`) | ||
| const peOffset = header.readUInt32LE(0x3c) | ||
| if (peOffset + 4 > stats.size) throw new Error(`Windows release artifact has an out-of-range PE offset: ${path}`) | ||
| const signature = Buffer.alloc(4) | ||
| readSync(handle, signature, 0, 4, peOffset) | ||
| if (signature.toString('latin1') !== 'PE\0\0') throw new Error(`Windows release artifact has no PE signature: ${path}`) | ||
| } finally { | ||
| closeSync(handle) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Verify the Windows artifacts electron-builder must have produced. | ||
| * @param desktopRoot - The apps/desktop directory containing dist/. | ||
| */ | ||
| export function verifyWindowsInstaller(desktopRoot: string): void { | ||
| const { version } = JSON.parse(readFileSync(join(desktopRoot, 'package.json'), 'utf8')) as { version: string } | ||
| assertPortableExecutable(join(desktopRoot, 'dist', `Pythinker-${version}-x64-Setup.exe`)) | ||
| assertPortableExecutable(join(desktopRoot, 'dist', 'win-unpacked', 'Pythinker.exe')) | ||
| console.log(`Windows release verified: Pythinker-${version}-x64-Setup.exe`) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.