This project lets you deploy an update server for Electron apps with ease: You only need to run a single command and fill out two text fields.
The result will be faster and more lightweight than any other solution out there! 🚀
- Built on top of micro, the tiniest HTTP framework for Node.js
- Pulls the latest release data from GitHub Releases and caches it in memory
- Refreshes the cache every 15 minutes (custom interval possible)
- When asked for an update, it returns the link to the GitHub asset directly (saves bandwidth)
- Supports macOS and Windows apps
- Scales very nicely across multiple Now instances
With Now CLI, you can easily deploy an update server. As the first step, clone the repository:
git clone https://github.com/zeit/hazel
Next, move into the directory:
cd hazel
Inside the directory, create a new deployment:
now -e ACCOUNT="<github-account>" -e REPOSITORY="<github-repository>"
On the command above, you can define the following environment variables:
ACCOUNT
: Your username or organisation name on GitHubREPOSITORY
: The name of the repository to pull releases fromPORT
: The port on which Hazel should run
Once it's deployed, paste the deployment address into your Tauri config (please keep in mind that updates should only occur in the production version of the app, not while developing).
That's it! ✅
The following environment variables can be used optionally:
INTERVAL
: Refreshes the cache every x minutes (restrictions)PRE
: When defined with a value of1
, only pre-releases will be cachedTOKEN
: Your GitHub token (for private repos)URL
: The server's URL (for private repos - when running on Now, this field is filled with the URL of the deployment automatically)
Since Hazel routes all the traffic for downloading the actual application files to GitHub Releases, you can use their API to determine the download count for a certain release.
As an example, check out the latest Now Desktop release and search for mac.zip
. You'll find a release containing a sub property named download_count
with the amount of downloads as its value.
Displays an overview page showing the cached repository with the different available platforms and file sizes. Links to the repo, releases, specific cached version and direct downloads for each platform are present.
Automatically detects the platform/OS of the visitor by parsing the user agent and then downloads the appropriate copy of your application.
If the latest version of the application wasn't yet pulled from GitHub Releases, it will return a message and the status code 404
. The same happens if the latest release doesn't contain a file for the detected platform.
Accepts a platform (like "darwin" or "win32") to download the appropriate copy your app for.
If the cache isn't filled yet or doesn't contain a download link for the specified platform, it will respond like /
.
Checks if there is an update available by reading from the cache.
If the latest version of the application wasn't yet pulled from GitHub Releases, it will return the 204
status code. The same happens if the latest release doesn't contain a file for the specified platform.
You can add Hazel to an existing HTTP server, if you want. For example, this will allow you to implement custom analytics on certain paths.
const tauri_updater = require('tauri-update-server')
http.createServer((req, res) => {
tauri_updater(req, res)
})
- Fork this repository to your own GitHub account and then clone it to your local device
- Move into the directory of your clone:
cd your-clone
- Run the development server:
yarn dev
Huge thanks to my (@leo's) friend Andy and Matheus for collecting ideas.
Leo Lamprecht (@notquiteleo) - ZEIT