Ibra
Ibra

Reputation: 1072

Electron autoUpdate app using electron-updater with github private repo

What I have Done: I packaged my electron app using electron-builder. I used electron forge typescript & webpack template to create my electron app.

The Error: Cannot find asset "app-setup-21.6.9.exe" in: https://api.github.com/repos/OWNER/REPO/releases/assets/48643890"

I think the problem could be about the location of the build files on when i publish on github ?

MAIN.JS

import { app, BrowserWindow, ipcMain } from 'electron';
import { autoUpdater } from "electron-updater";
const log = require('electron-log');


declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;



const createWindow = (): void => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    height: 650,
    width: 1200,
    webPreferences: {
      preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
    },
  });

  // and load the index.html of the app.
  mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);



  autoUpdater.logger = log;
  log.info('App starting...');
  

  mainWindow.once('ready-to-show', () => {
    autoUpdater.checkForUpdatesAndNotify();

  });

  autoUpdater.on('update-available', () => {
    log.info("update-available");
    mainWindow.webContents.send('update_available');
  });

  autoUpdater.on('error', (ev, err) => {
    mainWindow.webContents.send('error', err);
    log.info(err);
});

autoUpdater.on('download-progress', (ev, progressObj) => {
  mainWindow.webContents.send('download-progress', progressObj);
})

  autoUpdater.on('update-downloaded', () => {
    log.info("update_downloaded");
    mainWindow.webContents.send('update_downloaded');
    autoUpdater.quitAndInstall();
  });


  // returns repos current Version 
  ipcMain.on('app_version', (event) => {

    log.info(app.getVersion());

    mainWindow.webContents.send('app_version', { version: 
    app.getVersion() });
  });


};

Main.js Logs

[info]  App starting...
[info]  Checking for update
[info]  Found version 21.6.9 (url: @cloudreign/app-setup-21.6.9.exe)
[info]  update-available
[info]  Downloading update from @cloudapp/app-setup-21.6.9.exe
[error] Error: Error: Cannot find asset "app-setup-21.6.9.exe" in: https://api.github.com/repos/<OWNER>/<REPO>/releases/assets/48643890"

Upvotes: 1

Views: 2042

Answers (3)

Fenil Jariwala
Fenil Jariwala

Reputation: 79

Have you provided GH_TOKEN in publish config in package.json?

Upvotes: 0

Ibra
Ibra

Reputation: 1072

In my case I had a productName key in my package.json file that had a different name than the github repo. When I changed it to the same name as the GitHub repo it worked.

Upvotes: 1

Abhinay
Abhinay

Reputation: 474

autoUpdater.on('update-available', () => {
  log.info("update-available");
  autoUpdater.downloadUpdate() ;
});

You need to add autoUpdater.downloadUpdate() ; to donwload the update.

Upvotes: 0

Related Questions