diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ce0f54..5883b09 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: