Code Monkey home page Code Monkey logo

update.electronjs.org's Introduction

๐Ÿ“ก update.electronjs.org

A free service that makes it easy for open-source Electron apps to update themselves.

CircleCI build status

Requirements

Before using this service, make sure your Electron app meets these criteria:

  • Your app runs on macOS or Windows
  • Your app has a public GitHub repository
  • Your builds are published to GitHub Releases
  • Your builds are code signed (macOS only)

Quick Setup

Install update-electron-app as a runtime dependency (not a devDependency):

npm install update-electron-app --save

Call it from in your main process file:

require('update-electron-app')()

And that's all it takes! To customize, see the update-electron-app API.

Once your application is packaged, it will update itself for each new GitHub Release that you publish.

Manual Setup

Use something like the following setup to add automatic updates to your application:

Important: Please ensure that the code below will only be executed in your packaged app, and not in development. You can use electron-is-dev to check for the environment.

const { app, autoUpdater } = require('electron')

Next, construct the URL of the update server and tell autoUpdater about it:

const server = 'https://update.electronjs.org'
const feed = `${server}/OWNER/REPO/${process.platform}-${process.arch}/${app.getVersion()}`

autoUpdater.setFeedURL(feed)

As the final step, check for updates. The example below will check every 10 minutes:

setInterval(() => {
  autoUpdater.checkForUpdates()
}, 10 * 60 * 1000)

Once your application is packaged, it will update itself for each new GitHub Release that you publish.

Routes

/:owner/:repo/:platform/:version

/:owner/:repo/win32/:version/RELEASES

Development

You'll first need to have a running Redis server. There are two options:

  1. Locally: Install Redis locally and run it directly with redis-server. Guides can be found here.
  2. Docker: Install and run Redis with docker run -p 6379:6379 -it redis/redis-stack-server:latest.
$ yarn
$ GH_TOKEN=TOKEN npm start

To try with an actual electron app, run:

$ yarn start &
$ cd example
$ yarn

On Darwin:

$ npm run build
$ ./out/test-darwin-x64/test.app/Contents/MacOS/test

On Windows:

$ npm run build
$ "example\out\make\squirrel.windows\x64\test-0.0.0 Setup.exe"

update.electronjs.org's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

update.electronjs.org's Issues

Race condition for cache invalidation

Refs: https://github.com/electron/update-server/blob/master/index.js#L81

Imagine this scenario. R{X} = Request number {X} so R1 is the first request, R2 is the second request and so on.

  • R1: Cache miss, start github API request
  • R2: Cache miss, start github API request
  • R1: Github API responds
  • R3: Cache hit
  • R2: Github API responds
  • R4: Cache hit

Notice that because a request was made between the github API call returning another github API call was made. We probably need to use locks in redis to make it so this sequence works like:

  • R1: Cache miss, start github API request
  • R2: Cache miss, request locked, waiting
  • R1: Github API responds
  • R2: request unlocked, Cache hit
  • R3: Cache hit
  • R4: Cache hit

For popular apps this race condition will quite easily be hit, E.g. GPMDP update server processes approximately 5 requests a second 24/7.

add ?filter parameter

Atom has this use case where if you're on the beta channel, you only want to upgrade to releases that have beta in their name. An extra query parameter, like ?filter=beta would allow to do this.

@zeke any thoughts?

Improve logging for monitoring purposes

I have set up a few Papertrail alerts so we'll get notified of 404 or 500 HTTP statuses:

image

The 404 and 500 Papertrail searches are currently using a prepended space 404 to find those errors, but it would be nice to have something more explicit to search for in the logs, like status=404

app/web.1:  cache hit ummoji/ummoji-desktop 
app/web.1:  up to date 
app/web.1:  GET /ummoji/ummoji-desktop/darwin/1.2.12 204 
app/web.1:  GET /ummoji/ummoji-desktop/darwin/1.2.12 ... 
app/web.1:  cache hit ummoji/ummoji-desktop 
app/web.1:  up to date 
app/web.1:  GET /ummoji/ummoji-desktop/darwin/1.2.12 204

invalid version: latest

If someone doesn't pass a valid semver, we currently 500:

May 15 03:07:31 electron-update-server app/web.1:  {"level":50,"time":1526378850822,"msg":"Invalid Version: latest","pid":4,"hostname":"c853bc29-6768-4c53-a420-b78389ba2d65","type":"Error","stack":"TypeError: Invalid Version: latest\n    at new SemVer (/app/node_modules/semver/semver.js:305:11)\n    at compare (/app/node_modules/semver/semver.js:578:39)\n    at Function.eq (/app/node_modules/semver/semver.js:617:10)\n    at Updates.handleUpdate (/app/index.js:76:23)\n    at <anonymous>","v":1} 
May 15 03:07:31 electron-update-server app/web.1:  {"level":30,"time":1526378850823,"msg":"request","pid":4,"hostname":"c853bc29-6768-4c53-a420-b78389ba2d65","method":"GET","url":"/forCandies/GooglePhotosDesktop/darwin/latest","status":500,"ipHash":"ff84d3a0139a554efdc1f6f963aa18aefc053b2db7a54e75d368036466137cc2","duration":95,"v":1} 

Windows: Support 64 and 32 bit

I'm wondering if this service supports producing both x64 and ia32 versions of apps. I don't want to exclude users on weaker Windows machines, but I also don't want to punish those with beefy machines.

We could teach the service to detect ia32 and x64 identifiers - and update-electron-app to pass on what architecture they're running on right now.

Enable auto updates to pre-release versions

Is there a way to enable auto updates to pre-release versions and a way to only update to stable versions? I would like my users to be able to opt into a beta program that still auto updates without having to publish it as a completely separate application.

set up dns

update.electronjs.org ๐Ÿ‘‰ electron-update-server.herokuapp.com

Release Notes?

Just wondering if showing the release notes when prompting the user to restart is on the roadmap? Release notes would be taken from the github release.

Something like this:

38202830-0a352da6-3695-11e8-9e71-0b24c152bf9e

deployment

@juliangruber I created a heroku app electron-update-server and have configured it to auto-deploy when the master branch is updated.

Working on getting you added as collaborator.

screen shot 2018-04-03 at 1 51 13 pm

caching strategy

@MarshallOfSound very well analyzed:

From the looks of it, the cache expires every 15 minutes, that means we have a maximum number of apps as 1250 (5000 rate limit / 4 requests per hour). According to apps-using-electron at the time of that packes generation (a while ago) there were 13455 repos on github that used Electron as a dependency. That number is probably way up now so we're probably gonna need a SUPER TOKEN from GH ๐Ÿ˜‰ @zeke

Adding more details about the steps in the readme for newcomers

In the readme, it is said:

Make sure that:

Your builds are published to GitHub Releases
Your builds are code-signed

It would be useful to give more details about these.
Speaking as a newcomer to this kind of release flow.

  • "Github releases": do we need to attach / add the binaries to each drafted release? Or is the code somehow pulled, built and magically hosted?

  • "code-signed": how can one do this properly? some link and/or details?
    For example, electron-builder has this doc

Feedback from @kilian

From @Kilian in Slack:


I've tried this, but I'm running into a problem (I think, the docs are not super clear here)

I'm pretending to get an update by running an earlier version on a mac, so locally I pretend to be 1.2.0 and calling this url: https://electron-update-server.herokuapp.com/kilian/fromscratch/darwin/1.2.0 gives me the current latest version with the correct download link, but I get no update-available or update-downloaded events. Could this be due to me using _v_1.3.0 as the version name?

Additionally, https://electron-update-server.herokuapp.com/kilian/fromscratch/win32/1.2.0 gives me a 'not found', same as https://electron-update-server.herokuapp.com/kilian/fromscratch/win32-x64/1.2.0 or https://electron-update-server.herokuapp.com/kilian/fromscratch/win32/1.2.0/RELEASES the latter per de update-server readme)

Beyond that, is it supposed to automatically extract the downloaded ZIP file and extract the contents in-place? How does that work?

create github issues from server errors

@zeke and me have manually been pinging repo maintainers when their apps were hitting the wrong URLs or their assets weren't set up correctly. While we do now show more useful error messages, there's still a substantial amount of >=400 http status codes.

Instead of doing manual work, we can automate this! ๐Ÿ’ป

Questions:

  • which user to send this from (could be bot user but link @zeke and @juliangruber in the comment)
  • should it be part of this service (+ realtime - coupling) or the monthly log aggregator?

Technical considerations:

  • needs to wait a few calls before acting
  • needs to keep track of which repo was already informed

measure active users

Thinking ahead, it would be nice to be able to differentiate (anonymous) individual users while sifting through the logs. In other words, we might have 100 requests for app /foo/bar in the logs, but maybe those were just repeated requests from a handful of running apps.

One idea: include an anonymized hash of the request IP address in the logs.

Add support for latest pre-release

As a maintainer of an application with a stable and beta channel, it would be great if I could somehow tell the API to return the latest prerelease with a parameter (maybe something like https://update.electronjs.org/{name}/{repo}/{platform}/{semver}/beta) and to otherwise return the latest stable release.

Would make for a very simple release cycle where releases can be marked as pre-releases, picked up and tested by those on the beta channel, and eventually bumped up to a full release on GitHub.

make cache TTL an environment variable

Let's be more explicit and have a CACHE_TTL env var, instead of a hardcoded value in the code. Values should be human-friendly strings that ms module can parse, like 15 minutes

Nupkg path in RELEASES file gets updated incorrectly

I noticed something weird when I started producing deltas for releases using the update service as the remoteReleases URI in electron-winstaller. It seems that the update service is returning this for the latest release's RELEASES file now:

9A410F776059D4CEA85D008B461D90C7B95033EB https://github.com/atom/atom-nightly-releases/releases/download/1.29.0-nightly6/https://github.com/atom/atom-nightly-releases/releases/download/1.29.0-nightly5/atom-1.29.0-nightly5-full.nupkg 149089622
B6E8F9C8D6BE42E7888EE35CF90C4C4C10C0DB28 atom-1.29.0-nightly6-delta.nupkg 48698787
B503279BD722E84E74F611AFBF4E3F2DE60F48CD atom-1.29.0-nightly6-full.nupkg 149087747

On the first line, the nupkg path is double-prefixed with a URL path. The original RELEASES file from my repo looks like this:

๏ปฟ9A410F776059D4CEA85D008B461D90C7B95033EB https://github.com/atom/atom-nightly-releases/releases/download/1.29.0-nightly5/atom-1.29.0-nightly5-full.nupkg 149089622
B6E8F9C8D6BE42E7888EE35CF90C4C4C10C0DB28 atom-1.29.0-nightly6-delta.nupkg 48698787
B503279BD722E84E74F611AFBF4E3F2DE60F48CD atom-1.29.0-nightly6-full.nupkg 149087747

This could be the consequence of using a different repository for delivering releases, perhaps Squirrel is doing something sneaky there?

add json logging

Ideally, we'd log request path, status code, anonymized hash of user IP, and anything else that might be useful.

[ERROR] function validateInput - no such file or directory, open 'dist\main\package.json'

Hello there,

First time using this plugin, I have an issue with it.

When I try to run yarn dev I have an exception telling that package.json does not exist in the root/dist/main folder (and thats normal because package.json is not copied in compilation).

The line from your update-electron-app\index.js (l. 110) is:
const pkgBuf = fs.readFileSync(path.join(electron.app.getAppPath(), 'package.json'))

โ” Electron -------------------

  Error: ENOENT: no such file or directory, open 'E:\Developpement\Web\Projects\Hajime\dist\main\package.json'
      at Object.openSync (fs.js:453:3)
      at Object.func [as openSync] (electron/js2c/asar.js:155:31)
      at Object.readFileSync (fs.js:353:35)
      at Object.fs.readFileSync (electron/js2c/asar.js:597:40)
      at validateInput (E:\Developpement\Web\Projects\Hajime\node_modules\update-electron-app\index.js:110:23)
      at updater (E:\Developpement\Web\Projects\Hajime\node_modules\update-electron-app\index.js:22:10)
      at Module.eval (webpack-internal:///./src/main/index.js:35:59)
      at eval (webpack-internal:///./src/main/index.js:122:30)
      at Module../src/main/index.js (E:\Developpement\Web\Projects\Hajime\dist\main\main.js:952:1)
      at __webpack_require__ (E:\Developpement\Web\Projects\Hajime\dist\main\main.js:704:30)

โ”— ----------------------------

I am using electron 5.0.6, I could'nt up higher beaucause I use SQLite and install-app-deps does not work with latest version for SQLite deps (if the bug comes from because im using a uncompatible version of Electron, I'll see how I can fix it in another way).

How I can do without setting manually feed url ?

Best regards

atom requirements

  • if the user is on a specific release channel, like beta, they want to stay there. This is in contrast to other use cases, where if you're on 1.0.0-beta you're expected to upgrade to 1.0.0 next
  • there's multiple zip files in a release, one for the app and one for symbols. We need to make it configurable which to use
  • turn on prereleases

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.