Merge pull request #17 from leeguooooo/feat/macos-release

ci: 发布流程增加 macOS Universal dmg
This commit is contained in:
WEP
2026-11-09 08:58:55 +08:00
committed by GitHub
2 changed files with 65 additions and 1 deletions
+56 -1
View File
@@ -170,10 +170,65 @@ jobs:
path: artifacts/*
if-no-files-found: error
# ================= macOS:Universal(Apple Silicon + Intel)dmg =================
macos:
name: macOS (universal dmg)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: 版本号对齐 tag
id: ver
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
V="${GITHUB_REF_NAME#v}"
else
V="$(node -p "require('./src-tauri/tauri.conf.json').version")"
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
node -e "const fs=require('fs');for(const p of ['src-tauri/tauri.conf.json','package.json']){const j=JSON.parse(fs.readFileSync(p));j.version=process.argv[1];fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n')}" "$V"
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
key: macos
- run: pnpm install --frozen-lockfile
# 打包目标(app + dmg)取自 src-tauri/tauri.macos.conf.json;未配置开发者证书,产物为 ad-hoc 签名
- name: 构建(Universal dmg)
run: pnpm tauri build --target universal-apple-darwin
- name: 收集产物
shell: bash
run: |
set -euo pipefail
mkdir -p artifacts
cp src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg \
"artifacts/HGhub_${{ steps.ver.outputs.version }}_universal.dmg"
ls -lh artifacts
- uses: actions/upload-artifact@v4
with:
name: macos
path: artifacts/*
if-no-files-found: error
# ================= 发布 =================
release:
name: Publish GitHub Release
needs: [windows, android]
needs: [windows, android, macos]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
+9
View File
@@ -147,5 +147,14 @@ cd src-tauri/gen/android
需要设置 `ANDROID_HOME`(Android SDK 根目录)、`NDK_HOME`(`$ANDROID_HOME/ndk/<版本>`)与 `JAVA_HOME`(JDK 17)。
**4. macOS 打开时提示「已损坏」或「无法验证开发者」**
Release 里的 dmg 没有用 Apple 开发者证书签名和公证,从网上下载后会被 Gatekeeper 拦下。
把 HGhub 拖进「应用程序」后,在终端执行一次:
```bash
xattr -cr /Applications/HGhub.app
```
## LinuxDO
https://linux.do/