Giter Club home page Giter Club logo

Comments (24)

marc-parillo avatar marc-parillo commented on July 22, 2024 16

Actually, no need to change the docs. I looked at the source code and Auto Updater does support private github accounts. The only way I could get it to work is by calling the
autoUpdater.setFeedURL({ provider: 'github', owner: '[repo owner]', repo: '[repo name]', token: '[gh_token]' }) method before calling checkForUpdates() in main.js.

Of course, doing that is a serious security issue because your private repo token will need to be stored in the source code. Too bad GitHub doesn't offer read-only repo tokens.

from electron-updater-example.

MutableLoss avatar MutableLoss commented on July 22, 2024 14

I know this is old, but @marc-parillo thanks for this.

This was the only way I could get electron-updater working in a build with a regular private GH setup, and an org would just add unneeded overhead. Of course hard-coded tokens were far from ideal, so I ended up accessing each value via an environment variable set by dotenv on startup from an ignored .env file.

autoUpdater.setFeedURL({ provider: 'github', owner: process.env.OWNER, repo: process.env.REPO, token: process.env.GH_TOKEN })

Yes, the variables are still in the built source itself, but I'm obfuscating this after webpack, so finding these are not that feasible.

Its great to see it working now. 👍

By the way, what are the future plans of this feature now? I still see the docs state support for "Private GH Repos".

from electron-updater-example.

 avatar commented on July 22, 2024 7

If @develar is correct -- then the documentation is misleading with regards to the Auto Update feature.

Please change the docs to indicate that private github repos are not supported for Auto Updating. The docs at https://github.com/electron-userland/electron-builder/wiki/Auto-Update#private-github-update-repo say... "You can use a private repository for updates with electron-updater"

from electron-updater-example.

mbtakanov avatar mbtakanov commented on July 22, 2024 1

Thank you for the answer, it really helped. Two more things though.

  1. How should the repo look like? I mean what it should contain? Only an .exe (installer) file and latest.yml? Or the source files (before compiling)? Or the files in win-unpacked folder (the compiled files)?
  2. Is it possible to make a video in youtube how this work? With all the configs and ect. It would be very helpful.

from electron-updater-example.

mbtakanov avatar mbtakanov commented on July 22, 2024 1

Ok, I did what you said. I uploaded the .exe and latest.yml in a foo folder in the repo. Then I navigated to the folder and copy the URL. Then I set the URL at the package.json in the publish option like this:

"publish": [
      {
        "provider": "generic",
        "url": "https://git.companyname.com/repo_name/src/master/foo/"
      }
]

Unfortunately, when I start the app, an error pops up:

Error: Error: Cannot find channel "latest.yml" update info: HttpError: 404 Not Found
"method: undefined url: https://git.companyname.com/repo_name/src/master/foo/latest.yml\n\n    Please double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n   "

Could you tell me what's wrong? There is nothing in google when I search the error.

And just out of curiosity, in latest.yml there is sha2: foobarfoobarfoobar... row. Is there something I must do with it?

from electron-updater-example.

marc-parillo avatar marc-parillo commented on July 22, 2024 1

@MutableLoss I'm glad you found it helpful. Fortunately, I was eventually able to host everything in an S3 bucket so I was able to bypass GH altogether.

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

I've only ever published on GitHub, but I'm pretty sure you can do it on other providers (including your own). I'm guessing you want to configure publish as generic according to these docs: https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#PublishConfiguration

So (and I'm just guessing here) do this:

Step 3.5: Update package.json to have this in it (see https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#genericserveroptions--publishconfiguration):

{
  ...
  "build": {
    "publish": [{
      "provider": "generic",
      "url": "https://example.com"
    }],
  }
  ...
}

Step 4 is GitHub specific.

Step 5: Build the project: node_modules/.bin/build --win --mac with whatever flags you need (see the docs for this) then manually upload the generated files to the right places.

Step 6 is GitHub specific.

I'm not sure what the correct values for url are or where you need to place the uploaded files... I'm sorry. But maybe this is enough to get you close?

Please reopen if you have more questions.

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

I'm not sure. @develar, how should files be laid out on the fileserver for a generic provider?

from electron-updater-example.

develar avatar develar commented on July 22, 2024

Url — it is base URL for installer and channel update info files. I.e both exe and latest.yml must uploaded. Layout — nothing specific. E.g https://example.com/foo — dir foo must contains these files.

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

So:

"url": "https://www.example.com/foo"

with these files on the webserver:

https://www.example.com/foo/latest.yml
https://www.example.com/foo/myapp Setup.exe

Does that work, @mbtakanov ?

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@mbtakanov If you use your browser to go to the url mentioned in the error do you get a 404 or does it download the file?

@develar is the problem that method is undefined?

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@mbtakanov Does this work for you? https://gist.github.com/iffy/0ff845e8e3f59dbe7eaf2bf24443f104

It worked for my updating my macOS app.

from electron-updater-example.

mbtakanov avatar mbtakanov commented on July 22, 2024

Hi, thank you for going through this with me.

  1. If I navigate to https://git.companyname.com/repo_name/src/master/foo/latest.yml in my browser, it just shows the content of the file just like any other file opened in a repo (example - https://github.com/electron/electron/blob/master/script/bootstrap.py)

  2. The instructions in the link you provided - https://gist.github.com/iffy/0ff845e8e3f59dbe7eaf2bf24443f104 helped me to create a working update process (I had to npm install http-server -g and use it, no big deal). The question now is, how I can create the same thing, but with a URL of a repo (like the one above) and not with a htpp-server?

  3. Is it possible, the update process to be like any other normal app update and not uninstall and install?

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@mbtakanov

  1. The generic provider is for plain old HTTP servers that serve plain old files. For instance, instead of https://github.com/electron/electron/blob/master/script/bootstrap.py electron-updater is expecting the "Raw" version of that file (i.e. https://raw.githubusercontent.com/electron/electron/master/script/bootstrap.py -- notice that this is from raw.githubusercontent.com)

What software are you using to host your git repos on the web? GitHub? BitBucket? GitLab? Something else? I imagine most of them have a way to serve raw files. More information would help me help you.

  1. (You probably don't need the -g to install http-server)

  2. I'm not sure what you mean. When I update this app, it installs itself and restarts without me having to uninstall then install.

from electron-updater-example.

develar avatar develar commented on July 22, 2024

If you cannot use GitHub or Bintray to serve artifacts — just use Amazon S3. It is very cheap.

from electron-updater-example.

mbtakanov avatar mbtakanov commented on July 22, 2024

My company repo is based on GitHub, everything is the same as github.com, but it's on a private domain. Imagine I'm at the folder where are the .exe and latest.yml. So, how can I extract a link which will work in the generic provider? Is it even possible? I can get the link with the raw latest.yml file, but as we know, we need a link which contain both, the .exe and latest.yml files. My goal here is to make it work with a "github like" repository and if possible - avoid Amazon S3.
I have "oneClick": false, so on update, the app uninstall by itself, but I have to manage the installation. I guess your (@iffy) options is different, that's why you don't have to manage the installation process. Anyway, my question was about that is there a way/is it possible that the app doesn't uninstall and install (by itself or not, it doesn't matter), but instead, it just apply the patch" on the current installation?

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@mbtakanov Can you use the github provider and configure host (inside package.json) and token in setFeedURL as described here: https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#githuboptions--publishconfiguration

from electron-updater-example.

develar avatar develar commented on July 22, 2024

@mbtakanov if you want silent update for boring installer — file issue to electron-builder.

If you want to use private GitHub repo for update — no way (see docs for more details).

from electron-updater-example.

mbtakanov avatar mbtakanov commented on July 22, 2024

@iffy I have few questions:

  1. I created access token from my company private repo. Then I put it in token property. Now my package.json look like this:
...
"publish": [
      {
        "provider": "github",
        "repo": "repo_name",
        "host": "https://git.companyname.com/repo_name/src/master/foo",
        "protocol": "https",
        "token": "123foobar123foobar"
      }
    ],
...

Is this ok?
2) In https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#GithubOptions, the token description is somehow incomprehensible. What Never specify it in the configuration files. Only for setFeedURL. means? Which files are meant to be configuration-able?
3) In https://github.com/electron/electron/blob/master/docs/api/auto-updater.md -> autoUpdater.setFeedURL(url[, requestHeaders])

  1. When I run the app with the above config and
autoUpdater.setFeedURL('https://git.companyname.com/repo_name/src/master/foo', [{ }]);

in the electron file, I get the error which I posted earlier:

Error: Error: Cannot find channel "latest.yml" update info: HttpError: 404 Not Found
"method: undefined url: https://git.companyname.com/repo_name/src/master/foo/latest.yml\n\n    Please double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n   "

Is @develar right saying using private GitHub repo for update is impossible?

from electron-updater-example.

develar avatar develar commented on July 22, 2024

Docs is clear — https://github.com/electron-userland/electron-builder/wiki/Auto-Update#private-github-update-repo So, in short, do not use private GitHub repo for autoupdate.

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@mbtakanov I'm closing this (as it seems your use case isn't supported). But open a new issue or comment on this if you have more questions.

from electron-updater-example.

iffy avatar iffy commented on July 22, 2024

@nbcnc can you file an issue on that repo? Or better yet a PR. I don't control those docs :)

from electron-updater-example.

 avatar commented on July 22, 2024

will do

from electron-updater-example.

develar avatar develar commented on July 22, 2024

@marc-parillo Yes, as stated in the docs. https://github.com/electron-userland/electron-builder/wiki/Auto-Update#private-github-update-repo

Too bad GitHub doesn't offer read-only repo tokens.

Please read solution in the linked issue — electron-userland/electron-builder#1393 (comment)

from electron-updater-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.