Skip to content

Commit

Permalink
auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanff committed May 7, 2024
1 parent faf8c36 commit d8e73ef
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 42 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., alpha-v0.0.2)'
required: true
version-number:
description: 'Release version number (e.g., 1.0.0)'
description: 'Release version (e.g., 0.0.2)'
required: true

jobs:
Expand Down Expand Up @@ -36,5 +33,5 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
release: true
args: -c.extraMetadata.version=${{ github.event.inputs.version-number }} -c.publish.releaseType=prerelease
args: -c.extraMetadata.version=${{ github.event.inputs.version }} -c.publish.releaseType=prerelease

34 changes: 0 additions & 34 deletions .github/workflows/release.yml

This file was deleted.

29 changes: 26 additions & 3 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
import { CardData, PersonaFormData } from "@shared/types";
import { BrowserWindow, Menu, Tray, app, ipcMain, nativeImage, net, protocol, shell } from "electron";
import { BrowserWindow, Menu, Tray, app, dialog, ipcMain, nativeImage, net, protocol, shell } from "electron";
import { autoUpdater } from "electron-updater";
import path, { join } from "path";
import icon from "../../resources/icon.png?asset";
Expand Down Expand Up @@ -239,8 +239,31 @@ app.whenReady().then(async () => {
});

createWindow();
// Implement Electron auto-updater
// autoUpdater.on();

autoUpdater.checkForUpdates();

autoUpdater.on("update-downloaded", (e) => {
const { version } = e;
const dialogOpts: Electron.MessageBoxOptions = {
type: "info",
buttons: ["Restart", "Later"],
title: "Application Update",
message: `anime.gf version ${version} has been downloaded.`,
detail: "Restart the application to apply the update."
};

dialog.showMessageBox(dialogOpts).then((val) => {
if (val.response === 0) {
isQuiting = true;
autoUpdater.quitAndInstall();
}
});
});

autoUpdater.on("error", (error) => {
console.error("There was a problem updating the application");
console.error(error);
});
});

function createWindow(): void {
Expand Down

0 comments on commit d8e73ef

Please sign in to comment.