Files

127 lines
4.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 macOS
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
build-mac:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- os: macos-14 # Apple Silicon (arm64) — 免费
arch: arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Sync version from tag
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION=${GITHUB_REF#refs/tags/v}
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json','utf8'));
pkg.version = '$VERSION';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
echo "✓ package.json version → $VERSION"
- name: Generate icon.icns
run: |
mkdir -p icon.iconset
sips -z 16 16 resources/icon.png --out icon.iconset/icon_16x16.png
sips -z 32 32 resources/icon.png --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 resources/icon.png --out icon.iconset/icon_32x32.png
sips -z 64 64 resources/icon.png --out icon.iconset/icon_32x32@2x.png
sips -z 128 128 resources/icon.png --out icon.iconset/icon_128x128.png
sips -z 256 256 resources/icon.png --out icon.iconset/icon_128x128@2x.png
sips -z 256 256 resources/icon.png --out icon.iconset/icon_256x256.png
sips -z 512 512 resources/icon.png --out icon.iconset/icon_256x256@2x.png
sips -z 512 512 resources/icon.png --out icon.iconset/icon_512x512.png
sips -z 1024 1024 resources/icon.png --out icon.iconset/icon_512x512@2x.png
iconutil -c icns icon.iconset -o resources/icon.icns
rm -rf icon.iconset
- name: Bundle macOS Node.js
run: |
NODE_VER=22.12.0
curl -fsSL "https://nodejs.org/dist/v${NODE_VER}/node-v${NODE_VER}-darwin-${{ matrix.arch }}.tar.gz" \
| tar -xz
SRC="node-v${NODE_VER}-darwin-${{ matrix.arch }}"
mkdir -p resources/node/lib/node_modules
# node 可执行文件
cp "$SRC/bin/node" resources/node/node
chmod +x resources/node/node
# npm(lib/node_modules/npm/bin/npm-cli.js,由 update.ts 直接调用)
cp -r "$SRC/lib/node_modules/npm" resources/node/lib/node_modules/npm
rm -rf "$SRC"
- name: Bundle OpenClaw
run: node scripts/bundle-openclaw.mjs
env:
npm_config_registry: https://registry.npmjs.org
- name: Build (electron-vite)
run: pnpm run build
- name: Package DMG
run: pnpm exec electron-builder --mac --${{ matrix.arch }} --publish never
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: EasiestClaw-mac-${{ matrix.arch }}
path: dist/*.dmg
if-no-files-found: error
- name: Extract release notes & detect pre-release
if: startsWith(github.ref, 'refs/tags/')
id: release_meta
run: |
VERSION=${GITHUB_REF#refs/tags/v}
node scripts/extract-release-notes.mjs $VERSION > "$RUNNER_TEMP/release-notes.md"
cat "$RUNNER_TEMP/release-notes.md"
# 主版本号为 0 或包含 - 的版本视为测试版
if [[ "$VERSION" =~ ^0\. ]] || [[ "$VERSION" =~ - ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Upload to Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.dmg
dist/latest-mac.yml
body_path: ${{ runner.temp }}/release-notes.md
draft: false
prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}