Skip to content

Commit 528250b

Browse files
committed
Add release action for electron platforms
Update release electron action Update release electron action -- add ubuntu and macos Update release electron action Update release electron action Update release electron action Update release electron action Update release electron action Update release electron action Ignore vscode extension during linting Ignore vscode extension in tsconfig.json Move electron-serve to electron dist as it is needed for hosting static pages as part of electron Update electron forge to copy electron serve after completion Update electron forge packager config Update electron forge after completion logic Update electron forge extract path for darwin Fix darwin electron release build path bug Fix darwin path typo
1 parent 83d535f commit 528250b

File tree

5 files changed

+4257
-4786
lines changed

5 files changed

+4257
-4786
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build Electron Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
os: [windows-latest, ubuntu-latest, macos-latest]
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 22.x
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Build Web App
28+
run: |
29+
npm run build
30+
31+
- name: Build Electron App
32+
run: |
33+
npm run desktop-build
34+
35+
- name: Zip the build (Linux)
36+
run: |
37+
ZIP_NAME="linux-x64.zip"
38+
cd out-desktop
39+
zip -r "../$ZIP_NAME" .
40+
shell: bash
41+
if: runner.os == 'Linux'
42+
43+
- name: Zip the build (Windows)
44+
run: |
45+
$ZipName = "windows-x64.zip"
46+
Set-Location out-desktop
47+
Compress-Archive -Path * -DestinationPath "../$ZipName" -Force
48+
shell: pwsh
49+
if: runner.os == 'Windows'
50+
51+
- name: Zip the build (macOS)
52+
run: |
53+
ZIP_NAME="macos-arm64.zip"
54+
cd out-desktop
55+
zip -r "../$ZIP_NAME" .
56+
shell: bash
57+
if: runner.os == 'macOS'
58+
59+
- name: Create Release Build (Linux)
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
files: linux-x64.zip
63+
if: runner.os == 'Linux'
64+
65+
- name: Create Release Build (Windows)
66+
uses: softprops/action-gh-release@v2
67+
with:
68+
files: windows-x64.zip
69+
if: runner.os == 'Windows'
70+
71+
- name: Create Release Build (macOS)
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
files: macos-arm64.zip
75+
if: runner.os == 'macOS'

desktop/main.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { app, BrowserWindow, dialog, ipcMain } from "electron";
22
import serve from "electron-serve";
33
import { join } from "path";
4-
54
import { fileURLToPath } from "url";
65
import path from "path";
76
import { nativeTheme } from "electron/main";

forge.config.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import type { ForgeConfig } from "@electron-forge/shared-types";
2+
import path from "path";
3+
import fs from "fs-extra";
4+
5+
function removeNextjsModules(exceptionList: string[], nodeModulesPath: string) {
6+
fs.readdirSync(nodeModulesPath).forEach((module) => {
7+
if (!exceptionList.includes(module)) {
8+
fs.removeSync(path.join(nodeModulesPath, module));
9+
}
10+
});
11+
}
212

313
const config: ForgeConfig = {
414
outDir: "out-desktop",
@@ -14,10 +24,40 @@ const config: ForgeConfig = {
1424
return false;
1525
} else if (path.match(/desktop/)) {
1626
return false;
27+
} else if (path.match(/node_modules/)) {
28+
return false;
1729
}
18-
1930
return true;
2031
},
32+
afterComplete: [
33+
(extractPath, electronVersion, platform, arch, done) => {
34+
// We need electron-serve to exist inside the electron build's node_modules.
35+
// All other modules from nextjs are not needed and can be removed.
36+
37+
const electronModules = ["electron-serve"];
38+
if (platform === "win32") {
39+
removeNextjsModules(
40+
electronModules,
41+
path.join(extractPath, "resources/app/node_modules"),
42+
);
43+
} else if (platform === "darwin") {
44+
removeNextjsModules(
45+
electronModules,
46+
path.join(
47+
extractPath,
48+
"chisel-editor.app/Contents/Resources/app/node_modules",
49+
),
50+
);
51+
} else if (platform === "linux") {
52+
removeNextjsModules(
53+
electronModules,
54+
path.join(extractPath, "resources/app/node_modules"),
55+
);
56+
}
57+
58+
done();
59+
},
60+
],
2161
},
2262
};
2363

0 commit comments

Comments
 (0)