Over-the-air updates
A Tauri plugin that provides over-the-air (OTA) updates for the Web assets of a Tauri app.
It leverages CrabNebula Cloud to ship the assets.
Overview
Over the air updates are a way to update your Tauri application frontend assets without shipping a complete new application bundle.
This is helpful when you just need to update the frontend quickly, without going through the whole update process such as going through App Store reviews or desktop application reinstallation.
It is still possible to ship a complete new application bundle - and that is the required approach to distribute updates to your Rust code. When a complete application bundle is distributed, its embedded frontend assets are automatically applied and used over any previous over the air updates.
Install
This plugin requires a Rust version of at least 1.75
Install the Core plugin by adding the following to your Cargo.toml
file:
src-tauri/Cargo.toml
[dependencies]tauri-plugin-ota-updater = "2"
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
npm add @crabnebula/plugin-ota-updater
yarn add @crabnebula/plugin-ota-updater
pnpm add @crabnebula/plugin-ota-updater
Configuration
You need a signing key to sign the update bundle. This ensures the integrity of your code can be checked at runtime.
To generate a new signing key run the generate-keypair
command:
npx @crabnebula/ota-updater generate-keypair
Safely store the private key and DO NOT share it with anyone. It will be required to distribute updates later.
The plugin must be configured with the signing public key and CrabNebula Cloud org/app slug pair:
{ "plugins": { "ota-updater": { "orgSlug": "my-org", "appSlug": "my-app", "pubkey": "<insert-public-key-here>" } }}
To be able to use the updater from the frontend of your application you need to enable the default permission of the plugin in your capability ( e.g. capabilities/default.json
):
{ "permissions": [ "ota-updater:default" ]}
Distributing Updates
To distribute updates, build your frontend assets and then run the upload
command
providing the private key and a CrabNebula Cloud API key as environment variables:
export PRIVATE_KEY=<insert-private-key-here>export PRIVATE_KEY_PASSWORD=<insert-private-key-password-here>export CN_API_KEY=<insert api-key-here>npx @crabnebula/ota-updater upload
GitHub Actions Workflow
The following workflow demonstrates how to distribute updates using GitHub Actions:
name: Distribute OTA Update
on: workflow_dispatch:
concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true
jobs: build: runs-on: ubuntu-latest
steps: - uses: actions/checkout@v4
- name: Install Node.js uses: actions/setup-node@v4 with: node-version: "lts/*"
- name: Install pnpm and frontend dependencies uses: pnpm/action-setup@v4 with: version: 10
- name: build frontend run: pnpm build
- name: distribute OTA update run: pnpm dlx @crabnebula/ota-updater upload env: PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} CN_API_KEY: ${{ secrets.CN_API_KEY }}
Usage
First you need to register the core plugin with Tauri:
src-tauri/src/main.rs
fn main() { let context = tauri::generate_context!();
let (ota_plugin, context) = tauri_plugin_ota_updater::init(context);
tauri::Builder::default() .plugin(ota_plugin) .run(context) .expect("error while running tauri application");}
Afterwards all the plugin’s APIs are available through the JavaScript guest bindings:
import { check } from "@crabnebula/plugin-ota-updater";const update = await check()if (update) { await update.apply() location.reload()}