Skip to content

Tauri v2

This workflow is specifically tailored to Tauri v2 applications. It can be easily adapted to work with any Tauri app and only requires the your project’s slug within your CrabNebula organization as an input. Instead of just uploading assets (like in the previous workflow), the build job builds the Tauri app automatically for Linux, MacOS, and Windows. and uploads the assets directly afterwards.

Versionining

The release version number is automatically extracted from Tauri configuration files (tauri.conf.json). The version entries in Cargo.toml and package.json will be ignored for your project release in CrabNebula and thus can be removed/ommitted.

Code Signing

For security reasons, it’s recommended to sign your code by generating a private key and a private key password for your app. Passing those keys via the environment variables (TAURI_SIGNING_PRIVATE_KEY and TAURI_SIGNING_PRIVATE_KEY_PASSWORD) to your tauri build command will be enough. See the Tauri Docs for more details.

Workflow Triggers

For testing and developing purposes it may be useful to set a workflow_dispatch trigger, so the workflow can be initiated from the GitHub UI.

run-name: triggered by ${{ github.actor }}.
on: workflow_dispatch

Once testing is done, it’s recommended to use Continuous Deployment.

on:
push:
branches:
- main

Deploy Platforms

When deploying to multiple platforms, it’s useful to make builds concurrent. Also, cancelling ongoing processes when a new workflow starts.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

Jobs

The following section snippets must be added in the jobs map.

jobs:
<job-name>: <job-snippet>

Note that the indentation is important.

Draft Release

The release draft command will create a new entry in your CrabNebula project, but it won’t upload any assets just yet. It uses the crabnebula-dev/cloud-release action, which requires CN_API_KEY to be defined within your GitHub Action scope.

Because we’ll refer to this later on as well, we’ll store our application name in env first.

env:
# ...
CN_APPLICATION: "YOUR_ORG_NAME/YOUR_APP_NAME"

And then call the release draft command.

draft:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: create draft release
uses: crabnebula-dev/cloud-release@v0
with:
command: release draft ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}

Build Your App

The build step is for setting up the container image in which our task will run for each platform, and finally run your app’s build to create the Tauri binaries.

Establish the dependencies and the matrix of platforms we want to run concurrently. Add the common dependencies (Rust, and Node.js), create a cache for Rust.

build:
needs: draft
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true

Linux and Windows

Linux distros require additional system dependencies. For Tauri v2 we need webkit2gtk-4.1, that’s the WebView our frontend will be running in.

- name: install Linux dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.1

With dependencies setup for Linux, it’s time to build the Tauri app for Windows and Linux.

- name: build Tauri app for Windows, Linux
if: matrix.os != 'macos-latest'
run: |
npm ci
npm run tauri build
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}

MacOS

GitHub Actions run on Mac Sillicon by default, so we must add Mac Intel support to our platform and establish the appropriate target to our Tauri CLI.

- name: Install x86_64-apple-darwin for mac and build Tauri binaries
if: matrix.os == 'macos-latest'
run: |
rustup target add x86_64-apple-darwin
npm ci
npm run tauri build -- --target x86_64-apple-darwin
npm run tauri build -- --target aarch64-apple-darwin
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}

Upload Assets to Cloud

At the last step of our build, we push all assets to the Cloud project. At this point, you will be able to see the binaries showing up in your dashboard. But the release is not published yet!

- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
path: ./src-tauri

Publishing

At this point, the heavy lifting has been done and it’s time ot publish the release. If you don’t want to autopublish, you can do it manually from the Cloud dashboard.

publish:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: publish release
uses: crabnebula-dev/cloud-release@v0
with:
command: release publish ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}

Full Workflow

name: Tauri v2 Release Process
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CN_APPLICATION: "YOUR_ORG_NAME/YOUR_APP_NAME"
jobs:
draft:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: create draft release
uses: crabnebula-dev/cloud-release@v0
with:
command: release draft ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
build:
needs: draft
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: install Linux dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.1
- name: build Tauri app for Windows, Linux
if: matrix.os != 'macos-latest'
run: |
npm ci
npm run tauri build
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
- name: Install x86_64-apple-darwin for mac and build Tauri binaries
if: matrix.os == 'macos-latest'
run: |
rustup target add x86_64-apple-darwin
npm ci
npm run tauri build -- --target x86_64-apple-darwin
npm run tauri build -- --target aarch64-apple-darwin
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
path: ./src-tauri
publish:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: publish release
uses: crabnebula-dev/cloud-release@v0
with:
command: release publish ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}