saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.69k stars 215 forks source link

Electron updater #457

Closed zvbt closed 1 month ago

zvbt commented 1 month ago

I recently switched to Nextron for one of my projects, but I'm having trouble getting the Electron updater to work. If anyone can help me, it would be appreciated.

This is the code im using in the background.ts file


autoUpdater.on("update-available", (info: UpdateInfo) => {
  const releaseNotes = Array.isArray(info.releaseNotes) ? info.releaseNotes.map(note => note.note).join('\n') : info.releaseNotes;
  const dialogOpts: Electron.MessageBoxOptions = {
    type: 'info',
    buttons: ['Ok'],
    title: 'Application Update',
    message: process.platform === 'win32' ? releaseNotes : info.releaseName,
    detail: 'A new version is being downloaded.'
  };
  dialog.showMessageBoxSync(dialogOpts);
});

autoUpdater.on("update-downloaded", (info: UpdateInfo) => {
  const releaseNotes = Array.isArray(info.releaseNotes) ? info.releaseNotes.map(note => note.note).join('\n') : info.releaseNotes;
  const dialogOpts: Electron.MessageBoxOptions = {
    type: 'info',
    buttons: ['Restart', 'Later'],
    title: 'Application Update',
    message: process.platform === 'win32' ? releaseNotes : info.releaseName,
    detail: 'A new version has been downloaded. Restart the application to apply the updates.'
  };
  dialog.showMessageBox(dialogOpts).then((returnValue) => {
    if (returnValue.response === 0) autoUpdater.quitAndInstall();
  });
});```
pixelass commented 1 month ago

Can you elaborate on the actual issue you are facing?

zvbt commented 1 month ago

Whenever I upload a new version to GitHub, it doesnt get that there is a new update.

pixelass commented 1 month ago

@zvbt did you add a latest.yml? please link to you repo if it's a public repo. It will be easier to help.

image

pixelass commented 1 month ago

Here's what we do: https://github.com/blib-la/captain/blob/alpha/src/electron/helpers/utils/update.ts

pixelass commented 1 month ago

https://github.com/saltyshiomix/nextron/assets/1148334/ebcc3c30-deed-43d2-a38e-95cd55bcc7b8

zvbt commented 1 month ago

For now, it's a private repo. I'll try your methods and let you know if everything is good.

pixelass commented 1 month ago

I'm not sure if it works for private repositories though. It is likely to resolve to a 404 because of missing authentication.

pixelass commented 1 month ago

Please see here: https://www.electron.build/auto-update.html#private-github-update-repo

zvbt commented 1 month ago

"I got it to work. I forgot to include autoUpdater.checkForUpdates(); within the if (isProd){} block."

thank you for your help