Skip to content

Commit 2759f1e

Browse files
committed
.github/workflows/main.yml
1 parent 273d766 commit 2759f1e

File tree

5 files changed

+104
-174
lines changed

5 files changed

+104
-174
lines changed

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Build and publish
25+
run: npm run electron-builder -- -p always
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitlab-ci.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

main.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import { getAllCoverImageUrls, getGameMetaData } from './src/js/backends.js';
99

1010
import { PLATFORMS, getPlatformInfo } from './src/js/platforms.js';
1111

12-
import axios from 'axios';
13-
import os from 'os';
14-
1512
// Auto-updater
1613
import pkg from 'electron-updater';
1714
const { autoUpdater } = pkg;
1815

16+
import axios from 'axios';
17+
import os from 'os';
18+
19+
20+
1921

2022

2123
let childProcesses = new Map();
@@ -903,7 +905,6 @@ ipcMain.handle('get-versions', async () => {
903905
return {current: pjson.version, latest: latestVersion};
904906
});
905907

906-
// Manual update handlers
907908
ipcMain.handle('check-for-updates', async () => {
908909
try {
909910
await autoUpdater.checkForUpdates();
@@ -1129,8 +1130,8 @@ ipcMain.handle('get-flatpak-download-size', async (event, appId) => {
11291130
});
11301131
});
11311132

1132-
// Manual update system - no auto-check on startup
11331133
app.whenReady().then(() => {
1134+
// Auto-updater events
11341135
autoUpdater.on('checking-for-update', () => {
11351136
mainWindow.webContents.send('update-status', { status: 'checking' });
11361137
});
@@ -1142,8 +1143,8 @@ app.whenReady().then(() => {
11421143
}).show();
11431144
mainWindow.webContents.send('update-status', {
11441145
status: 'available',
1145-
info: info,
1146-
version: info.version
1146+
version: info.version,
1147+
info
11471148
});
11481149
});
11491150

@@ -1183,7 +1184,7 @@ app.whenReady().then(() => {
11831184
title: 'Update Downloaded',
11841185
body: 'Restart Emulsion to apply the update'
11851186
}).show();
1186-
mainWindow.webContents.send('update-status', { status: 'downloaded', info: info });
1187+
mainWindow.webContents.send('update-status', { status: 'downloaded' });
11871188
});
11881189

11891190
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "emulsion",
3-
"version": "0.9.65",
3+
"version": "0.9.66",
44
"summary": "Better gaming throught chemistry",
55
"description": "Display your games collection into responsive galleries, manage game metadata, cover art and emulator configuration. Launch your games in style.",
66
"homepage": "https://yphil.gitlab.io/emulsion",

src/js/dialog.js

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -266,103 +266,98 @@ export async function helpDialog(defaultTabId = null) {
266266

267267
const upgradeButton = dialog.querySelector('button.upgrade');
268268

269-
// Update status tracking
270-
let updateStatus = 'idle'; // idle, checking, available, downloading, downloaded, error
269+
// Create a new element for update status messages under the button
270+
const updateStatusElement = document.createElement('div');
271+
updateStatusElement.id = 'update-status-dialog';
272+
updateStatusElement.style.marginTop = '10px';
273+
updateStatusElement.style.fontSize = '0.9em';
274+
updateStatusElement.style.color = 'var(--accent, #3b82f6)';
275+
upgradeButton.insertAdjacentElement('afterend', updateStatusElement);
276+
277+
upgradeButton.textContent = 'Check for Updates';
278+
upgradeButton.addEventListener('click', async () => {
279+
try {
280+
const result = await ipcRenderer.invoke('check-for-updates');
281+
if (!result.success) {
282+
updateStatusElement.textContent = `Error: ${result.error}`;
283+
updateStatusElement.style.color = 'var(--error, #ef4444)';
284+
} else {
285+
updateStatusElement.textContent = 'Checking for updates...';
286+
updateStatusElement.style.color = 'var(--accent, #3b82f6)';
287+
}
288+
} catch (error) {
289+
updateStatusElement.textContent = `Error: ${error.message}`;
290+
updateStatusElement.style.color = 'var(--error, #ef4444)';
291+
}
292+
});
271293

272294
// Listen for update status changes from main process
273295
ipcRenderer.on('update-status', (event, status) => {
274-
updateStatus = status.status;
275-
const progressContainer = dialog.querySelector('.update-progress');
276-
const progressBar = dialog.querySelector('.update-progress-bar');
277-
const progressText = dialog.querySelector('.update-progress-text');
278-
279296
switch (status.status) {
280297
case 'checking':
281-
upgradeButton.textContent = 'Checking...';
298+
updateStatusElement.textContent = 'Checking for updates...';
299+
updateStatusElement.style.color = 'var(--accent, #3b82f6)';
282300
upgradeButton.disabled = true;
283-
if (progressContainer) progressContainer.style.display = 'none';
284301
break;
285302
case 'available':
286-
upgradeButton.textContent = `Download Update ${status.version}`;
303+
updateStatusElement.textContent = `Update ${status.version} available! Click to download.`;
304+
updateStatusElement.style.color = 'var(--success, #10b981)';
305+
upgradeButton.textContent = 'Download Update';
287306
upgradeButton.disabled = false;
288-
if (progressContainer) {
289-
progressContainer.className = 'update-progress available';
290-
progressContainer.style.display = 'block';
291-
progressBar.style.width = '0%';
292-
progressText.textContent = 'Update available for download';
293-
}
307+
upgradeButton.onclick = async () => {
308+
try {
309+
const downloadResult = await ipcRenderer.invoke('download-update');
310+
if (!downloadResult.success) {
311+
updateStatusElement.textContent = `Download failed: ${downloadResult.error}`;
312+
updateStatusElement.style.color = 'var(--error, #ef4444)';
313+
upgradeButton.disabled = false;
314+
} else {
315+
updateStatusElement.textContent = 'Starting download...';
316+
updateStatusElement.style.color = 'var(--accent, #3b82f6)';
317+
upgradeButton.disabled = true;
318+
}
319+
} catch (error) {
320+
updateStatusElement.textContent = `Download error: ${error.message}`;
321+
updateStatusElement.style.color = 'var(--error, #ef4444)';
322+
upgradeButton.disabled = false;
323+
}
324+
};
294325
break;
295326
case 'up-to-date':
296-
upgradeButton.textContent = 'Up to Date';
297-
upgradeButton.disabled = true;
298-
if (progressContainer) progressContainer.style.display = 'none';
327+
updateStatusElement.textContent = 'You are running the latest version.';
328+
updateStatusElement.style.color = 'var(--success, #10b981)';
329+
upgradeButton.disabled = false;
330+
upgradeButton.textContent = 'Check for Updates';
299331
break;
300332
case 'downloading':
301-
upgradeButton.textContent = `Downloading... ${status.progress}%`;
333+
updateStatusElement.textContent = `Downloading... ${status.progress}% (${status.downloaded}/${status.total} MB @ ${status.speed} MB/s)`;
334+
updateStatusElement.style.color = 'var(--accent, #3b82f6)';
302335
upgradeButton.disabled = true;
303-
if (progressContainer) {
304-
progressContainer.className = 'update-progress downloading';
305-
progressContainer.style.display = 'block';
306-
progressBar.style.width = `${status.progress}%`;
307-
progressText.textContent = `${status.progress}% (${status.downloaded}/${status.total} MB @ ${status.speed} MB/s)`;
308-
}
336+
upgradeButton.textContent = 'Downloading...';
309337
break;
310338
case 'downloaded':
339+
updateStatusElement.textContent = 'Download complete! Restart to install.';
340+
updateStatusElement.style.color = 'var(--success, #10b981)';
311341
upgradeButton.textContent = 'Install & Restart';
312342
upgradeButton.disabled = false;
313-
if (progressContainer) {
314-
progressContainer.style.display = 'none';
315-
}
343+
upgradeButton.onclick = async () => {
344+
try {
345+
await ipcRenderer.invoke('quit-and-install');
346+
} catch (error) {
347+
updateStatusElement.textContent = `Install error: ${error.message}`;
348+
updateStatusElement.style.color = 'var(--error, #ef4444)';
349+
}
350+
};
316351
break;
317352
case 'error':
318-
upgradeButton.textContent = 'Check for Updates';
353+
updateStatusElement.textContent = `Update error: ${status.error}`;
354+
updateStatusElement.style.color = 'var(--error, #ef4444)';
319355
upgradeButton.disabled = false;
320-
if (progressContainer) {
321-
progressContainer.className = 'update-progress error';
322-
progressContainer.style.display = 'block';
323-
progressBar.style.width = '0%';
324-
progressText.textContent = `Error: ${status.error}`;
325-
}
326-
console.error('Update error:', status.error);
356+
upgradeButton.textContent = 'Check for Updates';
327357
break;
328358
}
329359
});
330360

331-
upgradeButton.addEventListener('click', async () => {
332-
try {
333-
switch (updateStatus) {
334-
case 'idle':
335-
case 'up-to-date':
336-
case 'error':
337-
// Check for updates
338-
const result = await ipcRenderer.invoke('check-for-updates');
339-
if (!result.success) {
340-
console.error('Failed to check for updates:', result.error);
341-
upgradeButton.textContent = 'Check Failed - Try Again';
342-
upgradeButton.disabled = false;
343-
}
344-
break;
345-
case 'available':
346-
// Start download
347-
const downloadResult = await ipcRenderer.invoke('download-update');
348-
if (!downloadResult.success) {
349-
console.error('Failed to download update:', downloadResult.error);
350-
upgradeButton.textContent = 'Download Failed - Try Again';
351-
upgradeButton.disabled = false;
352-
}
353-
break;
354-
case 'downloaded':
355-
// Install and restart
356-
await ipcRenderer.invoke('quit-and-install');
357-
break;
358-
}
359-
} catch (error) {
360-
console.error('Update operation failed:', error);
361-
upgradeButton.textContent = 'Error - Try Again';
362-
upgradeButton.disabled = false;
363-
}
364-
});
365-
366361
dialog.querySelector('button.btn-liberapay').addEventListener('click', () => {
367362
ipcRenderer.invoke('go-to-url', 'https://liberapay.com/yPhil/');
368363
});

0 commit comments

Comments
 (0)