Tauri 示例工作流程

2023-10-19 17:15 更新

以下是一個已設(shè)置的示例工作流程,每當(dāng)在 git 上創(chuàng)建新版本時都會運行。

此工作流在 Windows、Ubuntu 和 macOS 最新版本上設(shè)置環(huán)境。請注意,在 jobs.release.strategy.matrix 下的 platform 數(shù)組包含 macos-latest、ubuntu-20.04 和 windows-latest。

此工作流程的步驟如下:

  1. 使用 actions/checkout@v3 檢出存儲庫。
  2. 使用 actions/setup-node@v3 設(shè)置 Node LTS 和全局 npm/yarn/pnpm 包數(shù)據(jù)的緩存。
  3. 使用 dtolnay/rust-toolchain@stable 和 swatinem/rust-cache@v2 設(shè)置 Rust 和 target/ 文件夾的緩存。
  4. 安裝所有依賴項并運行構(gòu)建腳本(用于 Web 應(yīng)用程序)。
  5. 最后,使用 tauri-apps/tauri-action@v0 運行 tauri build,生成構(gòu)建文件,并創(chuàng)建 GitHub 發(fā)布。
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
release:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
# You can remove libayatana-appindicator3-dev if you don't use the system tray feature.
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev

- name: Rust setup
uses: dtolnay/rust-toolchain@stable

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

- name: Sync node version and setup cache
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn' # Set this to npm, yarn or pnpm.

- name: Install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: yarn install # Change this to npm, yarn or pnpm.

- name: Build the app
uses: tauri-apps/tauri-action@v0

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ github.ref_name }} # This only works if your workflow triggers on new tags.
releaseName: 'App Name v__VERSION__' # tauri-action replaces \_\_VERSION\_\_ with the app version.
releaseBody: 'See the assets to download and install this version.'
releaseDraft: true
prerelease: false


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號