把本地 html/ 文件夹(含 js/css/图片)打包成一个离线桌面 .app。
架构分两步,本机不需要 Rust / Docker:
- 云端编空壳(一次性,在 GitHub Actions 的 macOS runner 上跑)
- 本机日常打包(纯 shell,秒级,把你的 html 塞进空壳)
macOS 的
.app只能在 mac 上编译(依赖苹果私有框架),Docker 和交叉编译都做不到,所以编译放到 GitHub 的 mac 云端机器。你的业务 html 不上传,只留本机。
app-shell/
├── .github/workflows/build-shell.yml # 云端编译配置(手动触发)
├── src-tauri/ # Tauri 空壳(Rust),推到 GitHub 供云端编译
│ ├── Cargo.toml
│ ├── build.rs
│ ├── tauri.conf.json # productName/identifier/图标/resources
│ ├── src/main.rs # 读 app-config.json 取标题 + 起本地服务器 + 建窗口
│ ├── icons/ # 占位图标(日常 build.sh 会换成你的)
│ └── resources/
│ ├── html/index.html # 占位页(日常 build.sh 会整体替换)
│ └── app-config.json # {"title":"App"} 占位(日常 build.sh 会覆写)
├── frontend/index.html # Tauri frontendDist 占位,运行时不用
├── install-shell.sh # 把下载的 shell-app.zip 装成 shell-template/shell.app
└── build.sh # 日常打包:塞 html + 换图标标题 + 重签名(纯 shell)
cd app-shell
git init && git add . && git commit -m "chore: app-shell 空壳骨架"
git branch -M main
git remote add origin git@github.com:<你的用户名>/<仓库名>.git
git push -u origin main然后:仓库网页 → Actions → 选 build-macos-shell → Run workflow → 等几分钟绿勾
→ 进这次运行 → 底部 Artifacts 下载 shell-app.zip。
./install-shell.sh ~/Downloads/shell-app.zip
# → 生成 shell-template/shell.app./build.sh \
--name "我的应用" \
--icon /路径/icon-1024.png \
--html /路径/我的html目录 \
--identifier com.example.myapp
# → dist/我的应用.app换 html / 图标 / 标题都只需重跑 build.sh。
只有改了 src-tauri 里的 Rust 逻辑,才需要重新推代码 + 重新在 Actions 里 Run 一次拿新空壳。
- 重签名是必需的:
build.sh末尾的codesign --force --deep --sign -不能省,否则 macOS 拒绝运行。 - 未签名/ad-hoc 签名的 App 在别人机器首次打开会被 Gatekeeper 拦(右键→打开可绕过);正式分发建议 Apple 开发者证书签名 + 公证。
- 图标缓存:换图标后 Dock/访达可能仍显示旧图标,
killall Dock或重登录可刷新。
详见项目 docs/ 下的三份方案文档。