Electron Autoupdater with Private GitHub Repository?

10,010

Solution 1

Are you using electron auto-updater module? from the API documentation, I can see that they don't support.

On the other hand, if you are using electron-updater module, make sure that you are following the recommended release workflow, and you should not use setFeedURL check the note here

Updated:

If you are using electron-updater and you are publishing to a private repository, you will need to make sure that your token will be available within the app-update.yml file, that's why many say it's not recommended, if the token is not set in your app-update.yml file you will get 404.

For electron-updater to auto add your token to the app-update.yml file the token should be set within the publish section like the following:

  "publish": [
    {
      "provider": "github",
      "private": true,
      "owner": "<github_owner>",
      "repo": "<repo_name>",
      "token": "<your github token>"
    }
  ],

This will produce a app-update.yml file like the following:

owner: <github_owner>
repo: <repo_name>
provider: github
private: true
token: <your github token>
updaterCacheDirName: electron-updater-private-updater

Check this small video

Here is my code https://github.com/linuxjuggler/electron-auto-update-example check the electron-builder.json file.

Update 2

Based on the note mentioned in the Quick Setup Guide section, you should never call setFeedURL.

Solution 2

Auto-Update - you can see that private github repos works only for very special cases, and they are recommending to have a separate release-only repository to distribute releases so source is locked down, and you can distribute to controlled machines. It is a useful feature since no server is required, but special use case. Also, you can make this work with s3 bucket or some other upgrade servers.

Share:
10,010
CoronaVirus
Author by

CoronaVirus

Updated on June 15, 2022

Comments

  • CoronaVirus
    CoronaVirus almost 2 years

    I have implemented Electron AutoUpdater with PRIVATE GitHub Repository as provider to publish electron application. Now, i can publish it using GitHub repository but Whenever AutoUpdater tries to download the updates from GitHub repository, Everytime it prompts with response code 404 Not found.. I have tried passing token in setFeedURL method and also set it in GH_TOKEN but seems like that does not work either.

    autoUpdater.setFeedURL({ provider: 'github'
    , owner: 'owner'
    , repo: 'repo-name'
    , token: 'token'
    , private: true });
    

    So, Is there any way to get it working with PRIVATE GitHub Repository ?

  • CoronaVirus
    CoronaVirus almost 5 years
    Yes i am using electron-updater. referring the workflow mentioned setting GH_TOKEN and private option.but seems it is not available for all the users.
  • CoronaVirus
    CoronaVirus almost 5 years
    yeah, Thanks for putting it on front.
  • Zaher
    Zaher almost 5 years
    is it hard for you to share the code snippet for the whole update process, not just the setFeedURL one, cause I remember it worked with me when I test it? but to be honest I advise against using it for releasing your code as the final app-update.yml file will contain your GH_TOKEN in plain text, and since this the same key you are using for pushing the release anyone can then use it to release a new version. at least this is what I was thinking about. unless you are releasing it for a private group of users.
  • Zaher
    Zaher almost 5 years
    Also when you release your code, what is the tag format you use? as github rely on the fact that your tag should prefixed with v (electron.build/configuration/publish#githuboptions) which is true by default.
  • CoronaVirus
    CoronaVirus almost 5 years
    Yes, tag format are prefixed with v. just checked and confirmed. This is how i am checking for updates autoUpdater.checkForUpdates(); autoUpdater.on('checking-for-update', () => { console.log("CHECKING FOR UPDATES !!"); }); and at start of script i am setting that setFeedURL
  • CoronaVirus
    CoronaVirus almost 5 years
    i read it works only for release-only github account. i set repository to release-only mode too. that did not work out either.
  • Zaher
    Zaher almost 5 years
    I'll create a test project today to remember what I did, and get back to you.
  • CoronaVirus
    CoronaVirus almost 5 years
    Yeah it worked for me. somehow release-only repository worked. rest of the configuration was correct as yours. btw .. Great thanks.
  • CoronaVirus
    CoronaVirus almost 5 years
    Can we manage somehow target branch name on github to publish ? and targeting any specific branch name to download update from. i want to publish separate release for each environment Dev, QA and PROD based upon some branch strategy. Or any suggestion for this ?
  • Zaher
    Zaher almost 5 years
    Am not sure there is a way to do that, as I know the build will be based on the currently active branch, but you might need to read about channels electron.build/tutorials/release-using-channels.html this way each environment will get its own, but again am not sure if this is a perfect solution.
  • CoronaVirus
    CoronaVirus almost 5 years
    Oh Man !! is this github private repo is unstable ? I literally changed nothing but this github auto update is again stopped working. 404 NOT FOUND Error: Cannot download "https://api.github.com/repos/owner/repo-name/releases/asset‌​s/assets-number" status 404: Not Found
  • Zaher
    Zaher almost 5 years
    You may have hit the limit, electron.build/auto-update#private-github-update-repo , that's why github private is not recommended using S3 or something similar might be a better option that you should check.
  • Chris Hayes
    Chris Hayes almost 3 years
    Just to add to this, a public S3 bucket or a release-only repo are the most sane options. The answer marked as correct suggests putting the GitHub token in the repo, which I wouldn't recommend considering anyone with that token can read/write any GitHub repo on that account (that token is shipping with the client!). Nuts used to be a popular proxy server, but it hasn't been maintained, and I haven't found a fork that functions anymore.
  • Admin
    Admin over 2 years
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.