Skip to content

Lightweight update server for Tauri apps

License

Notifications You must be signed in to change notification settings

HuakunShen/tauri-update-server

 
 

Repository files navigation

Hazel for Tauri

This is a fork from lemarier/tauri-update-server and vercel/hazel.

CircleCI XO code style

This project lets you deploy an update server for Electron apps with ease: You only need to click a button.

The result will be faster and more lightweight than any other solution out there! 🚀

  • Recommended by Electron here
  • 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 infinitely on Vercel Serverless Functions

Usage

Open this link in a new tab to deploy Hazel on Vercel:

Deploy with Vercel

Once deployed, Tauri app will automatically work given that the configuration file is set properly. See Updater Docs.

"updater": {
    "active": true,
    "endpoints": [
        "https://releases.myapp.com/update{{target}}/{{current_version}}"
    ],
    "dialog": true,
    "pubkey": "YOUR_UPDATER_SIGNATURE_PUBKEY_HERE"
}

That's it! ✅

Options

The following environment variables can be used optionally:

  • INTERVAL: Refreshes the cache every x minutes (restrictions) (defaults to 15 minutes)
  • PRE: When defined with a value of 1, only pre-releases will be cached
  • TOKEN: Your GitHub token (for private repos)
  • URL: The server's URL (for private repos - when running on Vercel, this field is filled with the URL of the deployment automatically)

Statistics

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

Routes

/

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.

/download

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.

/download/: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 /.

/update/:platform/:version

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.

/update/win32/:version/RELEASES

This endpoint was specifically crafted for the Windows platform (called "win32" in Node.js).

Since the Windows version of Squirrel (the software that powers auto updates inside Electron) requires access to a file named "RELEASES" when checking for updates, this endpoint will respond with a cached version of the file that contains a download link to a .nupkg file (the application update).

Credits

Huge thanks to my (@leo's) friend Andy, who suggested the name "Hazel" (since the auto updater software inside Electron is called "Squirrel") and Matheus for collecting ideas with me.

Author

Leo Lamprecht (@notquiteleo) - Vercel

About

Lightweight update server for Tauri apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 85.2%
  • Handlebars 14.8%