Files
u-claw/.github/workflows/release.yml
hfshfg c99b52e8e2 fix(ci): normalize CRLF for .bat/.cmd/.ps1 in portable zip
Real bug found in v2.1.0: ubuntu-runner zip preserved LF line endings, which
breaks Windows batch parsing. cmd.exe mis-tokenized 'setlocal' as 'local',
trashed env vars, and produced 'URL: //node--win-x64.zip' on Node download.

Symptom: Windows users who unzip and double-click setup.bat see a flood of
'XXX is not recognized as a command' errors followed by curl 'No host part'.

Fix: convert .bat/.cmd/.ps1 to CRLF, ensure .sh/.command/.mjs stay LF, before
zipping in the portable-skeleton job.
2026-05-02 18:44:40 +08:00

175 lines
5.7 KiB
YAML
Raw 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: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g. v2.1.0). Leave empty to use the most recent tag.'
required: false
default: ''
permissions:
contents: write
jobs:
portable-skeleton:
name: Portable skeleton zip (cross-platform)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Stage portable skeleton (no node_modules, no Node.js runtime)
run: |
mkdir -p dist
tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}"
stage_dir="dist/u-claw-portable-${tag_name}"
mkdir -p "$stage_dir"
# Copy source skeleton only — first launch will download Node.js + OpenClaw
# via portable/setup.sh / setup.bat (China mirror, ~1 minute).
cp -R portable/. "$stage_dir/"
rm -rf "$stage_dir/app" "$stage_dir/data/logs" 2>/dev/null || true
- name: Normalize line endings (CRLF for Windows scripts, LF for shell)
run: |
tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}"
stage_dir="dist/u-claw-portable-${tag_name}"
# Windows batch files MUST be CRLF — cmd.exe mis-parses LF-only files
find "$stage_dir" -type f \( -name '*.bat' -o -name '*.cmd' -o -name '*.ps1' \) -print0 \
| xargs -0 -I {} sh -c 'sed -i "s/\r$//; s/$/\r/" "{}"'
# Ensure shell scripts stay LF (mac/linux double-click won't run otherwise)
find "$stage_dir" -type f \( -name '*.sh' -o -name '*.command' -o -name '*.mjs' -o -name '*.js' \) -print0 \
| xargs -0 -I {} sh -c 'sed -i "s/\r$//" "{}"'
# Restore +x on shell entry points
chmod +x "$stage_dir"/*.sh "$stage_dir"/*.command 2>/dev/null || true
- name: Zip skeleton
run: |
tag_name="${GITHUB_REF_NAME:-${{ github.event.inputs.tag }}}"
cd dist
zip -qry "u-claw-portable-${tag_name}.zip" "u-claw-portable-${tag_name}"
ls -lh "u-claw-portable-${tag_name}.zip"
- uses: actions/upload-artifact@v4
with:
name: portable-skeleton
path: dist/u-claw-portable-*.zip
desktop-windows:
name: Electron Windows installer
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
shell: cmd
run: |
cd u-claw-app
npm install --registry=https://registry.npmmirror.com
- name: Build Windows installer
shell: cmd
run: |
cd u-claw-app
npm run build:win
env:
# Skip code signing — we ship unsigned. README documents the SmartScreen workaround.
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- uses: actions/upload-artifact@v4
with:
name: desktop-windows
path: |
u-claw-app/release/*.exe
u-claw-app/release/*.exe.blockmap
desktop-mac:
name: Electron macOS DMG
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: |
cd u-claw-app
npm install --registry=https://registry.npmmirror.com
- name: Build macOS DMG
run: |
cd u-claw-app
npm run build:mac-arm64
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- uses: actions/upload-artifact@v4
with:
name: desktop-mac
path: |
u-claw-app/release/*.dmg
u-claw-app/release/*.dmg.blockmap
publish:
name: Publish GitHub Release
needs: [portable-skeleton, desktop-windows, desktop-mac]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Resolve tag
id: tag
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
tag="${{ github.event.inputs.tag }}"
else
tag="${GITHUB_REF_NAME}"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Read OpenClaw version
id: openclaw_version
run: |
version=$(tr -d '[:space:]' < OPENCLAW_VERSION)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: U-Claw ${{ steps.tag.outputs.tag }}
body: |
## U-Claw ${{ steps.tag.outputs.tag }}
- 内置虾盘云:首次启动自动绑定本机/U盘指纹生成 `sk-uc-...` apiKey
- OpenClaw runtime: `${{ steps.openclaw_version.outputs.version }}`
- 充值入口https://u-claw.org/cloud.html
### 下载
- **Windows 桌面版**`U-Claw.Setup.*.exe`(安装到电脑)或 `U-Claw.*.exe`(免安装绿色版)
- **macOS 桌面版**`U-Claw-*-arm64.dmg`Apple Silicon或 `U-Claw-*.dmg`Intel
- **便携骨架U 盘版)**`u-claw-portable-*.zip`(约 1 MB首次启动自动下载 Node.js + OpenClaw国内镜像约 1 分钟)
> Windows 安装包未做代码签名,首次运行 SmartScreen 选择「仍要运行」。
> macOS DMG 未做公证,首次启动 `xattr -rd com.apple.quarantine /Applications/U-Claw.app` 或右键打开。
files: |
artifacts/portable-skeleton/*
artifacts/desktop-windows/*
artifacts/desktop-mac/*
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}