Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to config electron-updater for a private GitHub Repo #14

Closed
mbtakanov opened this issue Apr 13, 2017 · 24 comments
Closed

How to config electron-updater for a private GitHub Repo #14

mbtakanov opened this issue Apr 13, 2017 · 24 comments
Labels

Comments

@mbtakanov
Copy link

Hello, I can't understand from the given examples how to configure the updater. I have private company git repo on a company website and the example is all about GitHub. Where do I have to add the url to the repo? Do I have to add a credentials? If yes - where? What is the thing with the access token? I can't understand anything. Can you explain points 4, 5(what do you mean by "Publish with the publish.sh script"?) and 6 without involving GitHub?

@iffy iffy added the question label Apr 13, 2017
@iffy
Copy link
Owner

iffy commented Apr 13, 2017

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.

@iffy iffy closed this as completed Apr 13, 2017
@mbtakanov
Copy link
Author

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.

@iffy
Copy link
Owner

iffy commented Apr 19, 2017

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

@iffy iffy reopened this Apr 19, 2017
@develar
Copy link
Contributor

develar commented Apr 19, 2017

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.

@iffy
Copy link
Owner

iffy commented Apr 19, 2017

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 ?

@iffy iffy closed this as completed Apr 19, 2017
@mbtakanov
Copy link
Author

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?

@iffy
Copy link
Owner

iffy commented Apr 20, 2017

@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?

@iffy
Copy link
Owner

iffy commented Apr 20, 2017

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

It worked for my updating my macOS app.

@mbtakanov
Copy link
Author

mbtakanov commented Apr 21, 2017

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?

@iffy
Copy link
Owner

iffy commented Apr 21, 2017

@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.

@iffy iffy reopened this Apr 21, 2017
@develar
Copy link
Contributor

develar commented Apr 22, 2017

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

@mbtakanov
Copy link
Author

mbtakanov commented Apr 24, 2017

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?

@iffy
Copy link
Owner

iffy commented Apr 24, 2017

@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

@develar
Copy link
Contributor

develar commented Apr 25, 2017

@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).

@mbtakanov
Copy link
Author

mbtakanov commented Apr 25, 2017

@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?

@develar
Copy link
Contributor

develar commented Apr 25, 2017

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.

@iffy
Copy link
Owner

iffy commented May 4, 2017

@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.

@iffy iffy closed this as completed May 4, 2017
@iffy iffy changed the title How to config electron-updater How to config electron-updater for a private GitHub Repo May 5, 2017
@ghost
Copy link

ghost commented May 5, 2017

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"

@iffy
Copy link
Owner

iffy commented May 5, 2017

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

@ghost
Copy link

ghost commented May 5, 2017

will do

@marc-parillo
Copy link

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.

@develar
Copy link
Contributor

develar commented May 8, 2017

@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)

@MutableLoss
Copy link

MutableLoss commented Oct 7, 2018

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".

@marc-parillo
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants