Files
Jidekin 08f42cf1ce feat(platform): 三端支持 —— Windows / Linux 已出包,macOS 走 Actions
老板要求:开发 macOS 和 Linux 版。

一、代码跨平台化(原来只能编 Windows)
  · Cargo.toml:clipboard-win / windows-sys 挪到 [target.'cfg(windows)'.dependencies];
    非 Windows 加 arboard(macOS 走 NSPasteboard,Linux 走 X11/Wayland)
  · main.rs:
      - windows_subsystem 属性加目标平台判断(mac/Linux 没这个概念)
      - 剪贴板三个命令按平台分文件级实现
      - 「复制文件本身」在 mac/Linux 退化为复制路径文本(这两个平台剪贴板没有
        通用的文件格式,要写 NSPasteboard / GTK 私有 target,代价不值)
      - reveal_in_explorer:explorer / open -R / xdg-open
      - open_external:explorer / open / xdg-open
  · 修了重构时误删的 message_box 命令(构建时才暴露,已核对 19 个命令齐全)

二、打包配置
  · tauri icon 生成三端图标集(.ico / .icns / 多尺寸 png)
  · bundle.targets = "all":win→nsis,mac→app+dmg,linux→deb+rpm+appimage
  · macOS minimumSystemVersion 10.15;linux.deb 依赖声明

三、发布链路升级成多平台
  · publish.py 重写:自动扫描 target 下**存在的**产物,按平台归位,
    清单**合并**写入(在 Windows 发版不会冲掉 mac 的条目)
  · 官网页新增 macOS / Linux 下载卡,按 latest.json 里有没有该平台决定显隐,
    避免指向不存在的文件

四、实测(Linux 版)
  · 本机装 webkit2gtk-4.1 等依赖后原生构建成功
  · deb 2.79MB、AppImage 103.62MB(AppImage 自带 webkit 运行时所以大)
  · 已发布:latest.json 现在有 windows-x86_64 + linux-x86_64 两个平台
  · 官网 Linux 卡已显示,macOS 卡等有产物再自动出现

五、macOS
  · .github/workflows/build.yml:macos-latest(arm64 + intel)/ ubuntu / windows 矩阵出包
  · 需要仓库 Secrets 配升级签名私钥(和可选的苹果开发者证书)
2026-11-20 11:28:32 +08:00

96 lines
3.3 KiB
YAML
Raw Permalink 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: build
# 三端出包:
# Windows → .exe(NSIS 安装包)
# macOS → .dmg(Intel + Apple Silicon 各一份)
# Linux → .deb / .AppImage
#
# Linux 版和 Windows 版本机就能交叉/原生编译,macOS 必须有苹果的编译链,
# 所以这里统一交给 GitHub Actions(macos-latest 就是真机 macOS)。
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
label: macOS (Apple Silicon)
- platform: macos-latest
target: x86_64-apple-darwin
label: macOS (Intel)
- platform: ubuntu-22.04
target: ''
label: Linux
- platform: windows-latest
target: ''
label: Windows
name: ${{ matrix.label }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: 安装 Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: 缓存 cargo
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: 安装 Linux 系统依赖
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \
librsvg2-dev libxdo-dev patchelf
- name: 安装前端依赖
run: npm install
- name: 构建并上传产物
uses: tauri-apps/tauri-action@v0
env:
# 升级签名:把私钥内容存到仓库 Secret(TAURI_SIGNING_PRIVATE_KEY)
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
# macOS 代码签名(没有苹果开发者证书时留空,产物未签名,用户需右键「打开」)
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
with:
args: ${{ matrix.target != '' && format('--target {0}', matrix.target) || '' }}
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: xiaoyin-markdown-${{ matrix.platform }}${{ matrix.target != '' && format('-{0}', matrix.target) || '' }}
path: |
src-tauri/target/**/release/bundle/**/*.exe
src-tauri/target/**/release/bundle/**/*.msi
src-tauri/target/**/release/bundle/**/*.dmg
src-tauri/target/**/release/bundle/**/*.deb
src-tauri/target/**/release/bundle/**/*.AppImage
src-tauri/target/**/release/bundle/**/*.tar.gz
src-tauri/target/**/release/bundle/**/*.sig
if-no-files-found: warn