Tauri v2 with Auto-Updater
Let’s setup auto-updates with Tauri v2. For this guide, you will need a working Tauri project (v2), in a GitHub repository and integrated with CrabNebula Cloud. If you haven’t done that yet, the Publish Tauri with GitHub Actions guide will help you.
Required Dependencies
crate name | description | version |
---|---|---|
tauri-plugin-updater | Tauri plugin for auto-updates | ^2.0.0 |
tauri-plugin-dialog | Tauri plugin for dialogs | ^2.0.0 |
tauri-plugin-process | Tauri plugin for handling processes like app relaunch | ^2.0.0 |
To add them with cargo
you can run:
Tauri Capabilities
Before starting to implement auto-updates, some capabilities must be enabled in your app. Usually capabilities are under /src-tauri/capabilities/main.json
, adjust accordingly if your setup diverged from the defaults. Finally, add the necessary permissions so they match the JSON below:
Secret and Public Keys
To secure auto-updates, you need to generate a secret and public key pair. You can use the tauri-plugin-updater
CLI to generate them:
The above commands will generate a prompt to add a password to your key, make note of that for a while.
The stdout will yield back:
In your CI integration, you must add 2 environment variable secrets:
TAURI_SIGNING_PRIVATE_KEY
with the content ofmyapp.key
.TAURI_SIGNING_PRIVATE_KEY_PASSWORD
with the password you set.
And the contents of myapp.key.pub
must be added to your tauri.conf.json
:
Get Updater Endpoint from CrabNebula Cloud
Navigate to CrabNebula Cloud and login. At the Get started section you will find the Configure Tauri Updates card. Clicking on “Configure” will offer you a snippet with the endpoint.
The endpoint URL follows this template:
Do not replace the curly brackets, those are variables that will be used by Tauri itself when defining the right endpoint to hit. CrabNebula will take care of the rest.
Add the Plugins to Your App
Now it’s time to wire things up and use it within your app. The infrastructure is in place, we need to connect to it and to provide a decent user experience. First, we will add the plugins to our Tauri app.
And now it’s time to make use of that from the front-end side. We will create a method that will ping the endpoint for updates. If a new version is available it will download it and gracefully restart the app.
Lastly, we let this run early and non-blocking.
Final Thoughts
With this setup, you now have auto-updates and CI/CD in your app through CrabNebula Cloud. This is recommended to make sure your users always have the best and most secure experience. If you have any issues, feel free to reach out at the CrabNebula Discord or the Tauri Discord.