Files

123 lines
4.0 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
on:
workflow_dispatch:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-win:
runs-on: windows-latest
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/')
shell: bash
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: Bundle Windows Node.js
shell: powershell
run: |
$NODE_VER = "22.12.0"
$arch = "win-x64"
$url = "https://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER-$arch.zip"
Invoke-WebRequest -Uri $url -OutFile node-win.zip
Expand-Archive -Path node-win.zip -DestinationPath . -Force
$src = "node-v$NODE_VER-$arch"
New-Item -ItemType Directory -Force -Path resources/node | Out-Null
New-Item -ItemType Directory -Force -Path resources/node/node_modules | Out-Null
# node 可执行文件
Copy-Item "$src/node.exe" "resources/node/node.exe"
# npm(npm.cmd 依赖 node_modules/npm)
Copy-Item "$src/npm.cmd" "resources/node/npm.cmd"
Copy-Item -Recurse "$src/node_modules/npm" "resources/node/node_modules/npm"
Remove-Item -Recurse -Force $src, node-win.zip
- name: Bundle MinGit
shell: powershell
run: |
$GIT_VER = "2.47.0"
$url = "https://github.com/git-for-windows/git/releases/download/v$GIT_VER.windows.1/MinGit-$GIT_VER-64-bit.zip"
$dest = "resources/git/win"
$zip = "build/mingit.zip"
New-Item -ItemType Directory -Force -Path $dest | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path $zip) | Out-Null
Invoke-WebRequest -Uri $url -OutFile $zip
Expand-Archive -Path $zip -DestinationPath $dest -Force
Remove-Item $zip
Write-Host "MinGit $GIT_VER bundled OK"
- 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 NSIS installer
run: pnpm exec electron-builder --win --publish never
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: EasiestClaw-win-x64
path: dist/*.exe
if-no-files-found: error
- name: Extract release notes & detect pre-release
if: startsWith(github.ref, 'refs/tags/')
id: release_meta
shell: bash
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/*.exe
dist/latest.yml
body_path: ${{ runner.temp }}/release-notes.md
draft: false
prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}