Skip to content

Commit 9947f36

Browse files
committed
Add auto-updater, fix build signing, v2.5.1
1 parent a838b92 commit 9947f36

3 files changed

Lines changed: 74 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,8 @@ jobs:
2727
- name: Compile JSX
2828
run: npx babel app.jsx --out-file app.js --presets=@babel/preset-react
2929

30-
- name: Build installer
30+
- name: Build and publish
3131
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3233
CSC_IDENTITY_AUTO_DISCOVERY: false
33-
run: npx electron-builder --win --publish never
34-
35-
- name: Create Release
36-
uses: softprops/action-gh-release@v2
37-
with:
38-
files: |
39-
dist/*.exe
40-
draft: false
41-
generate_release_notes: true
34+
run: npx electron-builder --win --publish always

main.js

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { app, BrowserWindow, Menu, shell, dialog, ipcMain, session } = require("e
22
const path = require("path");
33
const fs = require("fs");
44
const crypto = require("crypto");
5+
const { autoUpdater } = require("electron-updater");
56

67
let mainWindow;
78
const userDataPath = app.getPath("userData");
@@ -570,7 +571,7 @@ function createWindow() {
570571
]},
571572
{ label: "Help", submenu: [
572573
{ label: "About NoteForge", click: () => dialog.showMessageBox(mainWindow, {
573-
type: "info", title: "About NoteForge", message: "NoteForge v2.5.0",
574+
type: "info", title: "About NoteForge", message: "NoteForge v2.5.1",
574575
detail: "Encrypted offline note-taking.\nAES-256-GCM · scrypt (N=65536)\nDerived key session · Auto-lock\n\nData: " + userDataPath,
575576
})},
576577
]},
@@ -579,6 +580,65 @@ function createWindow() {
579580
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate));
580581
}
581582

582-
app.whenReady().then(createWindow);
583+
app.whenReady().then(() => {
584+
createWindow();
585+
setupAutoUpdater();
586+
});
583587
app.on("window-all-closed", () => { if (process.platform !== "darwin") app.quit(); });
584588
app.on("activate", () => { if (!mainWindow) createWindow(); });
589+
590+
/* ═══════════════════════════════════════════════════════════════
591+
AUTO-UPDATER — checks GitHub Releases on startup
592+
Only network activity the app makes. Everything else stays offline.
593+
═══════════════════════════════════════════════════════════════ */
594+
autoUpdater.autoDownload = false;
595+
autoUpdater.autoInstallOnAppQuit = true;
596+
597+
function setupAutoUpdater() {
598+
if (IS_DEV) return; // don't check for updates in dev mode
599+
600+
// Check for updates 5 seconds after launch (non-blocking)
601+
setTimeout(() => {
602+
autoUpdater.checkForUpdates().catch(() => {}); // silently fail if offline
603+
}, 5000);
604+
605+
autoUpdater.on("update-available", (info) => {
606+
if (!mainWindow) return;
607+
dialog.showMessageBox(mainWindow, {
608+
type: "info",
609+
title: "Update Available",
610+
message: `NoteForge ${info.version} is available.`,
611+
detail: "Would you like to download it? The update will be installed when you close the app.",
612+
buttons: ["Download", "Later"],
613+
defaultId: 0,
614+
}).then(result => {
615+
if (result.response === 0) {
616+
autoUpdater.downloadUpdate();
617+
mainWindow?.webContents.send("menu-action", "update-downloading");
618+
}
619+
});
620+
});
621+
622+
autoUpdater.on("update-downloaded", () => {
623+
if (!mainWindow) return;
624+
dialog.showMessageBox(mainWindow, {
625+
type: "info",
626+
title: "Update Ready",
627+
message: "Update downloaded. It will be installed when you quit NoteForge.",
628+
buttons: ["Restart Now", "Later"],
629+
defaultId: 0,
630+
}).then(result => {
631+
if (result.response === 0) autoUpdater.quitAndInstall();
632+
});
633+
});
634+
635+
autoUpdater.on("error", () => {}); // silently ignore update errors (offline, etc.)
636+
}
637+
638+
ipcMain.handle("check-for-updates", async () => {
639+
if (IS_DEV) return { update: false };
640+
try {
641+
const result = await autoUpdater.checkForUpdates();
642+
return { update: !!result?.updateInfo, version: result?.updateInfo?.version };
643+
} catch { return { update: false }; }
644+
});

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "noteforge",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "Encrypted offline note-taking — a OneNote alternative that keeps your data local and protected.",
55
"main": "main.js",
66
"author": {
@@ -63,8 +63,16 @@
6363
},
6464
"portable": {
6565
"artifactName": "NoteForge-${version}-portable.exe"
66+
},
67+
"publish": {
68+
"provider": "github",
69+
"owner": "jamesccupps",
70+
"repo": "NoteForge"
6671
}
6772
},
73+
"dependencies": {
74+
"electron-updater": "^6.3.0"
75+
},
6876
"devDependencies": {
6977
"@babel/cli": "^7.28.0",
7078
"@babel/preset-react": "^7.28.0",

0 commit comments

Comments
 (0)