Skip to content

Commit 4ee587f

Browse files
committed
add auto-update for .deb .rpm + update artifact name
1 parent 770629b commit 4ee587f

7 files changed

Lines changed: 69 additions & 17 deletions

File tree

.github/workflows/build-desktop.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ jobs:
116116
release/*.zip
117117
release/*.dmg
118118
release/*.AppImage
119-
release/@liascript/*.deb
120-
release/@liascript/*.rpm
121-
release/@liascript/*.tar.gz
119+
release/*.deb
120+
release/*.rpm
121+
release/*.tar.gz
122122
release/*.yml
123123
retention-days: 30
124124

@@ -131,9 +131,9 @@ jobs:
131131
release/*.zip
132132
release/*.dmg
133133
release/*.AppImage
134-
release/@liascript/*.deb
135-
release/@liascript/*.rpm
136-
release/@liascript/*.tar.gz
134+
release/*.deb
135+
release/*.rpm
136+
release/*.tar.gz
137137
release/*.yml
138138
draft: false
139139
prerelease: false

dist/server/public/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ async function checkForUpdates() {
122122
btn.onclick = () => window.electronAPI.installUpdate()
123123
})
124124

125-
window.electronAPI.onUpdateError?.(() => {
125+
window.electronAPI.onUpdateError?.((data) => {
126126
btn.textContent = window.i18n?.t('update.button') ?? 'Download update'
127127
btn.disabled = false
128+
const label = banner.querySelector('span')
129+
if (label && data?.message) label.textContent = `Update failed: ${data.message}`
128130
})
129131

130132
btn.onclick = async () => {

electron-builder.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
}
114114
],
115115
"executableName": "liascript-exporter",
116-
"artifactName": "${name}-${version}.${ext}",
116+
"artifactName": "${productName}-${version}.${ext}",
117117
"desktop": {
118118
"Name": "LiaScript Exporter",
119119
"Comment": "Export LiaScript courses to various formats",

electron/main.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,25 @@ app.whenReady().then(() => {
5555
await shell.openExternal(url);
5656
});
5757

58-
// Auto-updater setup (AppImage, NSIS, DMG only — others fall back to releases page)
58+
// Auto-updater setup. Self-updatable formats download + install in-app; anything
59+
// else falls back to opening the GitHub releases page for a manual download.
5960
autoUpdater.autoDownload = false;
6061
autoUpdater.autoInstallOnAppQuit = false;
6162
autoUpdater.channel = 'latest';
6263
autoUpdater.allowPrerelease = false;
6364

64-
const updatableFormats = ['appimage', 'nsis', 'dmg'];
65+
// deb/rpm/pacman self-update via the system package manager (prompts for sudo at install time).
66+
const updatableFormats = ['appimage', 'nsis', 'dmg', 'deb', 'rpm', 'pacman'];
6567

6668
function getInstallerType() {
67-
if (process.platform === 'linux') return process.env.APPIMAGE ? 'appimage' : 'other';
69+
if (process.platform === 'linux') {
70+
if (process.env.APPIMAGE) return 'appimage';
71+
try {
72+
return fs.readFileSync(path.join(process.resourcesPath, 'package-type'), 'utf8').trim() || 'other';
73+
} catch {
74+
return 'other';
75+
}
76+
}
6877
if (process.platform === 'win32') return fs.existsSync(path.join(process.resourcesPath, '..', 'Uninstall LiaScript-Exporter.exe')) ? 'nsis' : 'other';
6978
if (process.platform === 'darwin') return 'dmg';
7079
return 'other';
@@ -82,8 +91,8 @@ app.whenReady().then(() => {
8291
if (mainWindow) mainWindow.webContents.send('update:downloaded');
8392
});
8493

85-
autoUpdater.on('error', () => {
86-
if (mainWindow) mainWindow.webContents.send('update:error');
94+
autoUpdater.on('error', (err) => {
95+
if (mainWindow) mainWindow.webContents.send('update:error', { message: err && (err.message || String(err)) });
8796
});
8897

8998
ipcMain.handle('app:checkForUpdates', async () => {

electron/preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
3131
onUpdateAvailable: (cb) => ipcRenderer.on('update:available', (_e, data) => cb(data)),
3232
onUpdateProgress: (cb) => ipcRenderer.on('update:progress', (_e, data) => cb(data)),
3333
onUpdateDownloaded: (cb) => ipcRenderer.on('update:downloaded', () => cb()),
34-
onUpdateError: (cb) => ipcRenderer.on('update:error', () => cb()),
34+
onUpdateError: (cb) => ipcRenderer.on('update:error', (_e, data) => cb(data)),
3535
});
3636

3737
// Log that the preload script has loaded

package-lock.json

Lines changed: 41 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/public/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ async function checkForUpdates() {
122122
btn.onclick = () => window.electronAPI.installUpdate()
123123
})
124124

125-
window.electronAPI.onUpdateError?.(() => {
125+
window.electronAPI.onUpdateError?.((data) => {
126126
btn.textContent = window.i18n?.t('update.button') ?? 'Download update'
127127
btn.disabled = false
128+
const label = banner.querySelector('span')
129+
if (label && data?.message) label.textContent = `Update failed: ${data.message}`
128130
})
129131

130132
btn.onclick = async () => {

0 commit comments

Comments
 (0)