Monday, 28 October 2019

Electron auto updater setup with own server

I have my own server where I uploaded app installer via FTP. Its name is quickmargo Setup 1.0.0.exe and it's available at

https://quickmargo.pl/dist/download/quickmargo Setup 1.0.0.exe

Also via FTP I uploaded latest.yml to same directory and it is available at

https://quickmargo.pl/dist/download/latest.yml

In my project in index.js I have

import { autoUpdater } from 'electron-updater'

autoUpdater.setFeedURL('https://quickmargo.pl/dist/download');

autoUpdater.on('update-downloaded', () => {
    autoUpdater.quitAndInstall()
});

autoUpdater.on('update-available', (ev, info) => {
    alert('Update required!');
});

app.on('ready', async () => {
    if (process.env.NODE_ENV === 'production') {
        await autoUpdater.checkForUpdates()
    }
});

In package.json I have "version": "1.0.0", and inside build:{} I have:

"win": {
  "icon": "build/icons/icon.ico",
  "publish": [{
    "provider": "generic",
    "url": "https://quickmargo.pl/dist/download"
  }]
},

( I don't care about other platforms )

Now let's say I've made some changes in my app and I want to upload version 1.0.1 and I want my app to auto update if someone already downloaded installer and installed my app on his machine.

Tell me please if everything what I made so far is fine and what is next step. I consider following:

  • change version to 1.0.1 in package.json
  • run build command in terminal again
  • upload manually new installer to same place at my server

Edit

I did above three steps plus I also uploaded new latest.yml ( with version 1.0.1 ) and result is that when I now run previously installed (before uploading new version to server) version 1.0.0 on other PC then it doesn't detect that I added 1.0.1 to server and it doesn't update or show some popup or anything. What I'm doing wrong?

Edit 2

I'm trying to solve it on my own and now I uploaded 1.0.2 so now link to download app is:

https://quickmargo.pl/dist/download/quickmargo Setup 1.0.2.exe

Edit 3

I was trying to solve it on my own I edited code in index.js. I edited also above. alert('Update required!'); on update-available event never occure. It should show me error message window that alert is undefined. But apparently update-available event is never emitted.


Additional info:

  • My app was generated with vue-electron v1.0.6 boilerplate.
  • My electron-updater version is 4.1.2
  • npm run build actually invoke some code from boilerplate which is in .electron-vue/build.js you can see this file in above link (for example it set NODE_ENV to production. Script in package.json is: "build": "node .electron-vue/build.js && electron-builder",.
  • I don't want to host releases at github because my repository is private and I saw some information in electron.build docs that I shoudn't do that.
  • I also saw info in some issue that I could create new repo only for releases but I consider hosting everything at my own server as more clean approach.


from Electron auto updater setup with own server

No comments:

Post a Comment