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 GitHub Action runner 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 the binaries and upload the artifacts.

build_desktop:
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 exec 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 Apple Silicon 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 exec tauri build -- --target x86_64-apple-darwin
npm exec 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 }}

Mobile

If your application targets Android and iOS, we recommend defining separate jobs per platform so your workflow is easier to read.

Android
  1. Create the job and install Rust and Node.js

    build_android:
    needs: draft
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    with:
    node-version: "lts/*"
    - name: Install stable toolchain
    uses: actions-rust-lang/setup-rust-toolchain@v1
    with:
    toolchain: stable
    cache: true
  2. Install Android dependencies

    - name: setup JDK 17
    uses: actions/setup-java@v4
    with:
    java-version: "17"
    distribution: "temurin"
    - name: setup Android SDK
    uses: android-actions/setup-android@v3
    - name: setup Android NDK
    uses: nttld/setup-ndk@v1
    id: setup-ndk
    with:
    ndk-version: r26d
    link-to-sdk: true
    - name: install Android targets
    run: rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
  3. Setup Android signing

    See the official documentation for more information.

    - name: setup Android signing
    working-directory: src-tauri/gen/android
    run: |
    echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
    echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
    base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
    echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
  4. Build the Android application

    - name: build Tauri app for Android
    env:
    NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
    run: |
    npm ci
    npm run tauri android build
  5. Upload to CrabNebula Cloud

    - name: upload assets
    uses: crabnebula-dev/cloud-release@v0
    with:
    command: release upload ${{ env.CN_APPLICATION }} --framework tauri
    api-key: ${{ secrets.CN_API_KEY }}
iOS
  1. Create the job and install Rust and Node.js

    build_ios:
    needs: draft
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    with:
    node-version: "lts/*"
    - name: Install stable toolchain
    uses: actions-rust-lang/setup-rust-toolchain@v1
    with:
    toolchain: stable
    cache: true
    - name: install iOS target
    run: rustup target add aarch64-apple-ios
  2. Install iOS dependencies

    - name: setup xcode
    uses: maxim-lobanov/setup-xcode@v1
    with:
    xcode-version: latest-stable
  3. Setup iOS signing

    See the official documentation for more information.

    - name: setup Apple API key
    run: |
    APPLE_API_KEY_PATH="$RUNNER_TEMP/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8"
    echo "${{ secrets.APPLE_API_KEY }}" > $APPLE_API_KEY_PATH
    echo "APPLE_API_KEY_PATH=$APPLE_API_KEY_PATH" >> $GITHUB_ENV
    echo "API_PRIVATE_KEYS_DIR=$RUNNER_TEMP" >> $GITHUB_ENV
  4. Build the iOS application

    - name: build Tauri app for iOS
    env:
    APPLE_API_KEY: ${{ secrets.APPLE_API_KEY_ID }}
    APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
    APPLE_DEVELOPMENT_TEAM: <ENTER TEAM HERE>
    run: |
    npm ci
    npm run tauri ios build --export-method app-store-connect
  5. Upload to CrabNebula Cloud

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

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_desktop, build_android, build_ios]
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_desktop:
needs: draft
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: macos-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- 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 exec 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 target for mac and build Tauri binaries
if: matrix.os == 'macos-latest'
run: |
rustup target add x86_64-apple-darwin
npm ci
npm exec tauri build -- --target x86_64-apple-darwin
npm exec 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 }}
build_android:
needs: draft
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: setup JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
- name: setup Android SDK
uses: android-actions/setup-android@v3
- name: setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26d
link-to-sdk: true
- name: install Android targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: setup Android signing
working-directory: src-tauri/gen/android
run: |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
- name: build Tauri app for Android
env:
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
npm ci
npm run tauri android build
- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
build_ios:
needs: draft
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: install iOS target
run: rustup target add aarch64-apple-ios
- name: setup xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: setup Apple API key
run: |
APPLE_API_KEY_PATH="$RUNNER_TEMP/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8"
echo "${{ secrets.APPLE_API_KEY }}" > $APPLE_API_KEY_PATH
echo "APPLE_API_KEY_PATH=$APPLE_API_KEY_PATH" >> $GITHUB_ENV
echo "API_PRIVATE_KEYS_DIR=$RUNNER_TEMP" >> $GITHUB_ENV
- name: build Tauri app for iOS
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_DEVELOPMENT_TEAM: <ENTER TEAM HERE>
run: |
npm ci
npm run tauri ios build --export-method app-store-connect
- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
publish:
needs: [build_desktop, build_android, build_ios]
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 }}