使用 Github Workflow 进行发布 tauri

name: 构建应用

description: 构建应用并发布

on:
  workflow_dispatch:
  push:
    branches:
      - release/**
    tags:
      - v*

jobs:
  publish-tauri:
      permissions:
        contents: write
      strategy:
        fail-fast: false
        matrix:
          include:
            # - platform: 'macos-latest' # for Arm based macs (M1 and above).
            #   args: '--target aarch64-apple-darwin'
            # - platform: 'macos-latest' # for Intel based macs.
            #   args: '--target x86_64-apple-darwin'
            # - platform: 'ubuntu-22.04'
            #   args: ''
            - platform: 'windows-latest'
              args: ''
      runs-on: ${{ matrix.platform }}

      steps:
        - name: 签出代码
          uses: actions/checkout@v4

        - name: 安装依赖(仅 ubuntu)
          if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
          run: |
            sudo apt-get update
            sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf

        - name: 安装 node
          uses: actions/setup-node@v4
          with:
            node-version: lts/*
            # cache: 'pnpm'

        - name: 安装 pnpm
          uses: pnpm/action-setup@v3
          with:
            version: 10
            run_install: false

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

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

        - name: 安装前端依赖
          run: npm install

        - name: "构建应用"
          uses: tauri-apps/tauri-action@v0
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          with:
            tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
            releaseName: 'App v__VERSION__'
            releaseBody: 'See the assets to download this version and install.'
            releaseDraft: true
            prerelease: false
            args: ${{ matrix.args }}

需要注意, __VERSION__ 是一个占位符,会被 tauri.conf.jsonversion 字段替换。


使用 Github Workflow 进行发布 tauri
http://www.inksha.com/archives/shi-yong-github-workflow-jin-xing-fa-bu
作者
inksha
发布于
2025年04月22日
许可协议