StealthReader/.github/workflows/release.yml

78 lines
2.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: "Publish Release"
on:
push:
tags:
- "v*" # 推送 v1.0.0 之类的 tag 时触发
workflow_dispatch: # 也支持手动触发
permissions:
contents: write # 需要写入权限来创建 Release
jobs:
publish-tauri:
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon (M1/M2/M3)
- platform: "macos-latest"
args: "--target aarch64-apple-darwin --bundles app,dmg"
# Windows x64
- platform: "windows-latest"
args: "--bundles nsis"
runs-on: ${{ matrix.platform }}
steps:
# 1. 检出代码
- name: Checkout
uses: actions/checkout@v5
# 2. 安装 pnpm必须先于 setup-node 的 pnpm 缓存)
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11
# 3. 安装 Node.js
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: lts/*
cache: "pnpm"
# 4. 安装 Rust
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Add macOS Apple Silicon target
if: matrix.platform == 'macos-latest'
run: rustup target add aarch64-apple-darwin
# 5. Rust 缓存(大幅加速后续构建)
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
# 6. 安装前端依赖
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
# 7. 构建并发布(核心步骤)
- name: Build app & publish release
uses: tauri-apps/tauri-action@v0
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: v__VERSION__ # 自动替换为 tauri.conf.json 里的版本号
releaseName: "StealthReader v__VERSION__"
releaseBody: "See the assets to download and install."
releaseDraft: true # 先创建草稿,手动确认后再发布
prerelease: false
args: ${{ matrix.args }}