Skip to content

Tauri Skill

🤖 AI Integration Guide: Send this page link to AI for automatic integration guidance

Quick Information

  • Application Type: Tauri
  • Skill Version: 2.0.0
  • Integration Difficulty: ⭐⭐ (Easy)
  • Estimated Time: 10-30 minutes

📖 Integration Scenarios

Choose the appropriate integration method based on your project type:

ScenarioSuitable ForFeaturesEstimated Time
Scenario 1Non-open source, Private projectsManual build & upload, Data reporting10 minutes
Scenario 2Open source projectsGitHub Actions automated build & release30 minutes

Scenario 1: Non-Open Source Project Integration

Suitable for private projects or projects that don't require GitHub Actions automated deployment.

1. Install Plugin

Use the official Tauri recommended command to install the updater plugin:

bash
npm run tauri add updater

This command automatically:

  • Installs @tauri-apps/plugin-updater dependency
  • Installs @tauri-apps/plugin-process dependency (for app restart)
  • Configures necessary permissions

For manual installation, execute separately:

bash
npm install @tauri-apps/plugin-updater
npm install @tauri-apps/plugin-process

2. Generate Signing Keys

Tauri updates require signing keys to verify the integrity of update packages. You need to generate a key pair (public key and private key).

Generate Keys

Run the following command in your project root directory:

bash
npm run tauri signer generate -- -w ./.tauri/tauri.key

You will be prompted to enter a password (to protect the private key), and two files will be generated:

  • .tauri/tauri.key - Private key (used to sign update packages, keep it safe and do not commit to the repository)
  • .tauri/tauri.key.pub - Public key (used to verify update packages in the application)

View Public Key Content

bash
cat .tauri/tauri.key.pub

Output example:

dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDY4QjBGNEM4NjUyMUNGRjAKUldUd3p5Rmx5UFN3YUN1UkFMK05DdWR4VjA1eDRybkxJNzMreURNbHZ4VFhtSk54UTVMWVg4NnAK

Configure Environment Variables

When building update packages, you need to set the following environment variables:

bash
# Mac/Linux
export TAURI_SIGNING_PRIVATE_KEY=$(cat .tauri/tauri.key)
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD=your_password

# Windows (PowerShell)
$env:TAURI_SIGNING_PRIVATE_KEY = Get-Content .tauri/tauri.key -Raw
$env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD = "your_password"

⚠️ Security Tips:

  • Add the private key file .tauri/tauri.key to .gitignore, do not commit to the repository
  • Use environment variables or secret management services in CI/CD to store the private key
  • The public key can be made public and used to configure the application

3. Configure tauri.conf.json

Configure the update plugin in src-tauri/tauri.conf.json:

json
{
  "bundle": {
    "createUpdaterArtifacts": true
  },
  "plugins": {
    "updater": {
      "pubkey": "your_generated_public_key_content",
      "endpoints": [
        "https://api.upgrade.toolsetlink.com/v1/tauri/upgrade?tauriKey=YOUR_TAURI_KEY&versionName={{current_version}}&appointVersionName=&devModelKey=&devKey=&target={{target}}&arch={{arch}}"
      ],
      "windows": {
        "installMode": "passive"
      }
    }
  }
}

Configuration Description:

FieldDescription
createUpdaterArtifactsSet to true to tell Tauri to create update packages
pubkeyPublic key content generated in Step 2 (not a file path)
endpointsUpgradeLink upgrade detection API address
windows.installModeWindows installation mode: passive (recommended), basicUi, quiet

endpoints Parameters:

ParameterDescriptionSource
tauriKeyUpgradeLink application identifierGet from UpgradeLink dashboard
versionNameCurrent application versionAuto-filled with
targetOperating systemAuto-filled with
archSystem architectureAuto-filled with

⚠️ Note:

  1. Replace your_generated_public_key_content with the public key generated in Step 2
  2. Replace YOUR_TAURI_KEY with your actual Tauri Key

4. Add Update Check Code

Add the following code to your Tauri application:

typescript
import { check } from '@tauri-apps/plugin-updater';
import { relaunch } from '@tauri-apps/plugin-process';

async function checkForUpdates() {
  try {
    const update = await check({
      timeout: 5000,
      headers: {
        'X-AccessKey': 'YOUR_ACCESS_KEY',
      },
    });
    
    if (update) {
      console.log(`New version ${update.version} available, released on ${update.date}`);
      console.log(`Release notes: ${update.body}`);
      
      let downloaded = 0;
      let contentLength = 0;
      
      await update.downloadAndInstall((event) => {
        switch (event.event) {
          case 'Started':
            contentLength = event.data.contentLength;
            console.log(`Download started, total size: ${contentLength} bytes`);
            break;
          case 'Progress':
            downloaded += event.data.chunkLength;
            console.log(`Download progress: ${downloaded} / ${contentLength}`);
            break;
          case 'Finished':
            console.log('Download complete');
            break;
        }
      });
      
      console.log('Installation complete, restarting application');
      await relaunch();
    } else {
      console.log('Already on the latest version');
    }
  } catch (error) {
    console.error('Update check failed:', error);
  }
}

⚠️ Note: Replace YOUR_ACCESS_KEY with your actual Access Key

5. Set Permissions

Add permissions in src-tauri/capabilities/default.json:

json
{
  "permissions": [
    "updater:default",
    "process:default"
  ]
}

Permission Description:

PermissionDescription
updater:defaultAllow checking, downloading, and installing updates
process:defaultAllow restarting the application

6. Data Reporting Integration

During the upgrade process, call the data reporting API to record upgrade status for data statistics and analysis.

Reporting Utility Functions

typescript
import crypto from 'crypto';

function generateSignature(timestamp: string, nonce: string, body: string, accessSecret: string): string {
  const signStr = `timestamp=${timestamp}&nonce=${nonce}&body=${body}&accessSecret=${accessSecret}`;
  return crypto.createHash('md5').update(signStr).digest('hex');
}

function generateNonce(length: number = 16): string {
  return crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
}

async function reportEvent(
  eventType: string,
  appKey: string,
  eventData: Record<string, any>,
  accessKey: string,
  accessSecret: string
): Promise<void> {
  const timestamp = new Date().toISOString();
  const nonce = generateNonce();
  const body = JSON.stringify({
    eventType,
    timestamp,
    appKey,
    eventData,
  });
  
  const signature = generateSignature(timestamp, nonce, body, accessSecret);
  
  try {
    const response = await fetch('https://api.upgrade.toolsetlink.com/v1/app/report', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-Timestamp': timestamp,
        'X-Nonce': nonce,
        'X-AccessKey': accessKey,
        'X-Signature': signature,
      },
      body,
    });
    
    const result = await response.json();
    console.log('Report result:', result);
  } catch (error) {
    console.error('Report failed:', error);
  }
}

Complete Upgrade Flow Example (with Data Reporting)

typescript
import { check } from '@tauri-apps/plugin-updater';
import { relaunch } from '@tauri-apps/plugin-process';
import { getVersion } from '@tauri-apps/api/app';
import { platform, arch } from '@tauri-apps/plugin-os';

let upgradeVersionCode = 0;

async function checkAndInstallUpdate() {
  try {
    const update = await check({
      timeout: 5000,
      headers: {
        'X-AccessKey': 'YOUR_ACCESS_KEY',
      },
    });
    
    if (update) {
      console.log('New version available:', update.version);
      upgradeVersionCode = parseInt(update.version.split('.').join(''));
      
      let downloaded = 0;
      let contentLength = 0;
      
      await update.downloadAndInstall((event) => {
        switch (event.event) {
          case 'Started':
            contentLength = event.data.contentLength || 0;
            console.log(`Download started, total size: ${contentLength} bytes`);
            break;
          case 'Progress':
            downloaded += event.data.chunkLength;
            const percent = contentLength > 0 ? (downloaded / contentLength * 100).toFixed(1) : 'unknown';
            console.log(`Download progress: ${percent}%`);
            break;
          case 'Finished':
            console.log('Download complete');
            reportDownload(upgradeVersionCode, 0);
            break;
        }
      });
      
      console.log('Installation complete, restarting application');
      await reportUpgrade(upgradeVersionCode, 0);
      await relaunch();
    }
  } catch (error) {
    console.error('Update failed:', error);
    
    if (upgradeVersionCode > 0) {
      await reportDownload(upgradeVersionCode, 1);
      await reportUpgrade(upgradeVersionCode, 1);
    }
  }
}

async function reportDownload(downloadVersionCode: number, code: number) {
  const currentVersion = await getVersion();
  const currentPlatform = await platform();
  const currentArch = await arch();
  
  await reportEvent(
    'app_upgrade_download',
    'YOUR_TAURI_KEY',
    {
      versionCode: parseInt(currentVersion.split('.').join('')),
      downloadVersionCode,
      code,
      target: currentPlatform,
      arch: currentArch,
    },
    'YOUR_ACCESS_KEY',
    'YOUR_ACCESS_SECRET'
  );
}

async function reportUpgrade(upgradeVersionCode: number, code: number) {
  const currentVersion = await getVersion();
  const currentPlatform = await platform();
  const currentArch = await arch();
  
  await reportEvent(
    'app_upgrade_upgrade',
    'YOUR_TAURI_KEY',
    {
      versionCode: parseInt(currentVersion.split('.').join('')),
      upgradeVersionCode,
      code,
      target: currentPlatform,
      arch: currentArch,
    },
    'YOUR_ACCESS_KEY',
    'YOUR_ACCESS_SECRET'
  );
}

async function reportAppStart() {
  const currentVersion = await getVersion();
  const currentPlatform = await platform();
  const currentArch = await arch();
  
  await reportEvent(
    'app_start',
    'YOUR_TAURI_KEY',
    {
      versionCode: parseInt(currentVersion.split('.').join('')),
      launchTime: new Date().toISOString(),
      target: currentPlatform,
      arch: currentArch,
    },
    'YOUR_ACCESS_KEY',
    'YOUR_ACCESS_SECRET'
  );
}

Status Code Reference

Download event code:

Status CodeDescription
0Download successful
1Download failed (general)
1001HTTP error
1002Insufficient space
1003File operation error
1004MD5 verification failed

Upgrade event code:

Status CodeDescription
0Upgrade successful
1Upgrade failed

📖 Detailed API Documentation: Event Reporting API

7. Manual Build and Upload

Build Update Packages

After setting environment variables, execute the build command:

bash
npm run tauri build

Generated Files

After the build completes, update packages will be generated in the following directories:

PlatformDirectoryFiles
Linuxtarget/release/bundle/appimage/myapp.AppImage, myapp.AppImage.sig
macOStarget/release/bundle/macos/myapp.app.tar.gz, myapp.app.tar.gz.sig
Windowstarget/release/bundle/msi/myapp.msi, myapp.msi.sig
Windowstarget/release/bundle/nsis/myapp-setup.exe, myapp-setup.exe.sig
  1. Log in to UpgradeLink dashboard
  2. Go to Application Management page
  3. Create a new version, upload the corresponding installation package and signature file
  4. Configure upgrade strategy

Scenario 2: Open Source Project Integration

Suitable for open source projects that require GitHub Actions automated build, release, and update.

1. Complete Basic Integration

First complete all steps (1-6) in Scenario 1.

2. Configure GitHub Secrets

Add the following encrypted environment variables in your GitHub repository's Settings > Security > Secrets and variables > Actions:

Secret NameDescriptionHow to Get
UPGRADE_LINK_ACCESS_KEYUpgradeLink access keyUpgradeLink dashboard > Key Management
UPGRADE_LINK_ACCESS_SECRETUpgradeLink access secretUpgradeLink dashboard > Key Management
UPGRADE_LINK_TAURI_KEYTauri application unique identifierUpgradeLink dashboard > Application Info
TAURI_SIGNING_PRIVATE_KEYTauri signing private keyPrivate key content generated in Step 2
TAURI_SIGNING_PRIVATE_KEY_PASSWORDSigning private key passwordPassword set in Step 2

3. Configure GitHub Actions Workflow

Create .github/workflows/publish.yml in your project root:

yaml
name: 'publish'

on:
  push:
    branches:
      - main

jobs:
  publish-tauri:
    permissions:
      contents: write
    outputs:
      appVersion: ${{ steps.set-job-output.outputs.appVersion }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'macos-latest'
            args: '--target aarch64-apple-darwin'
          - platform: 'macos-latest'
            args: '--target x86_64-apple-darwin'
          - platform: 'ubuntu-22.04'
            args: ''
          - platform: 'ubuntu-22.04-arm'
            args: ''
          - platform: 'windows-latest'
            args: ''

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4

      - name: install dependencies (ubuntu only)
        if: startsWith(matrix.platform, 'ubuntu-')
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: 'yarn'

      - name: install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

      - name: Rust cache
        uses: swatinem/rust-cache@v2
        with:
          workspaces: './src-tauri -> target'

      - name: install frontend dependencies
        run: yarn install

      - uses: tauri-apps/tauri-action@v0
        id: tauri-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
          TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
        with:
          tagName: ${{ github.event.repository.name }}-v__VERSION__
          releaseName: '${{ github.event.repository.name }} v__VERSION__'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: false
          prerelease: false
          args: ${{ matrix.args }}

      - name: Set job output
        id: set-job-output
        if: matrix.platform == 'ubuntu-22.04'
        run: |
          echo "appVersion=${{ steps.tauri-action.outputs.appVersion }}" >> $GITHUB_OUTPUT

  upgradeLink-upload:
    needs: publish-tauri
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - name: Send a request to UpgradeLink
        uses: toolsetlink/upgradelink-action@3.0.2
        with:
          access_key: ${{ secrets.UPGRADE_LINK_ACCESS_KEY }}
          access_secret: ${{ secrets.UPGRADE_LINK_ACCESS_SECRET }}
          config: |
            {
              "app_type": "tauri",
              "request": {
                "app_key": "${{ secrets.UPGRADE_LINK_TAURI_KEY }}",
                "latest_json_url": "https://github.com/${{ github.repository }}/releases/download/${{ github.event.repository.name }}-v${{ needs.publish-tauri.outputs.appVersion }}/latest.json"
              }
            }

4. Workflow Details

publish-tauri Job

Function: Cross-platform build and publish to GitHub Releases

StepDescription
Checkout codeactions/checkout@v4
Install dependenciesLinux system dependencies, Node.js, Rust
Build cacheRust compilation cache to speed up builds
Frontend dependenciesInstall npm/yarn dependencies
Tauri buildBuild using tauri-apps/tauri-action@v0
Extract versionOutput appVersion for later use

Multi-platform Build Strategy:

PlatformRunnerTarget Architecture
macOS (M1+)macos-latestaarch64-apple-darwin
macOS (Intel)macos-latestx86_64-apple-darwin
Linux (x64)ubuntu-22.04-
Linux (ARM)ubuntu-22.04-arm-
Windowswindows-latest-

Function: Sync update information to UpgradeLink platform

StepDescription
Wait for buildDepends on publish-tauri completion
Get versionRetrieve from publish-tauri output
Upload infoSync using upgradelink-action

UpgradeLink Action Parameters:

ParameterDescription
access_keyUpgradeLink access key
access_secretUpgradeLink access secret
app_typeApplication type, fixed as tauri
app_keyTauri application unique identifier
latest_json_urllatest.json address in GitHub Releases

Configure the GitHub repository address in UpgradeLink dashboard:

  1. Log in to UpgradeLink dashboard
  2. Go to Application Management > Tauri Application Details
  3. Fill in the repository address in the "GitHub Repository Address" field, e.g.: https://github.com/username/repo-name
  4. Save configuration

After configuration, UpgradeLink will automatically read the latest.json file from GitHub Releases.

6. Automated Process Description

When code is pushed to the main branch, the automated process is as follows:

Code Push


┌─────────────────────────────────────────┐
│         publish-tauri Job                │
│  ┌─────────────────────────────────┐    │
│  │ Parallel build for 5 platforms   │    │
│  │ - macOS (M1)                    │    │
│  │ - macOS (Intel)                 │    │
│  │ - Linux (x64)                   │    │
│  │ - Linux (ARM)                   │    │
│  │ - Windows                       │    │
│  └─────────────────────────────────┘    │
│                 │                        │
│                 ▼                        │
│  ┌─────────────────────────────────┐    │
│  │ Create GitHub Release            │    │
│  │ Upload packages & latest.json    │    │
│  └─────────────────────────────────┘    │
└─────────────────────────────────────────┘


┌─────────────────────────────────────────┐
│       upgradeLink-upload Job             │
│  ┌─────────────────────────────────┐    │
│  │ Read latest.json URL             │    │
│  │ Call UpgradeLink API             │    │
│  │ Auto-create version & strategy   │    │
│  └─────────────────────────────────┘    │
└─────────────────────────────────────────┘


Users receive update notification

🤖 AI Integration

Send this page link to AI, for example:

Please help me integrate application upgrade, here's the Skill link:
https://www.toolsetlink.com/en/upgrade/skill/tauri

AI will automatically:

  1. Identify the application type as Tauri
  2. Determine project type (open source/non-open source)
  3. Retrieve configuration information and code examples
  4. Guide you to replace placeholders (YOUR_TAURI_KEY, etc.)
  5. Verify configuration correctness
  6. Complete integration testing

📋 Complete Example

View complete example project: tauri-demo


❓ FAQ

Q: How to get Tauri Key?

A: Log in to UpgradeLink dashboard, create a Tauri application to obtain it.

Q: How to get Access Key and Access Secret?

A: Log in to UpgradeLink dashboard, obtain them from the key management page.

Q: What if update fails?

A: Check network connection and configuration, or contact AI for help.

Q: Will data reporting failure affect the upgrade process?

A: No. Data reporting is an asynchronous operation, failure will not affect the normal upgrade process. It is recommended to retry during off-peak hours.

Q: What if GitHub Actions build fails?

A:

  1. Check GitHub Actions logs for specific error information
  2. Confirm all dependencies are correctly installed, especially Linux platform system dependencies
  3. Ensure Rust and Node.js versions are compatible
  4. Check if GitHub Secrets are configured correctly

Q: How to test the update process?

A:

  1. Build and upload a lower version
  2. Modify code version number, build and upload a higher version
  3. Run the lower version application and check if it can detect the update

Q: Can I rollback to an older version?

A: Yes. Modify the upgrade strategy in UpgradeLink dashboard and specify the target version.


📚 Reference Resources

toolsetlink@163.com