Files
u-claw/.github/workflows/track-upstream.yml
zheng 45026b9d35
Some checks failed
Tests / test (push) Has been cancelled
docs: 翻掉我上轮漏掉的三处,并修正发布说明里一条错误建议
上一轮我说"剩余中文都合理",说得太满。这三处不合理:

1. bootable/linux-setup/test-installation.sh —— 在用户的 Linux 机器上跑的
   自检脚本,输出中英混杂(check "安装目录存在" ... "Directory $INSTALL_DIR")

2. issue / PR 模板 —— 贡献者第一眼看到的东西,而 CONTRIBUTING.md 已经是
   英文了。顺带修掉模板里指向上游官网和上游微信的链接(那些我们控制不了),
   改为指向本仓库。PR 模板加了一条"说明你在哪个平台跑过" —— 只在 Mac 上
   验证过的 .bat 改动一直是本项目最主要的故障来源。

3. release.yml 的发布说明正文 —— 那是用户在 release 页面读到的文字,内容
   还停留在旧产品(DeepSeek/通义、预装微信 QQ 钉钉飞书企微)。

第 3 项里还有一条**和事实相反**的建议:它让用户把 U 盘格式化成 NTFS。
macOS 对 NTFS 只读,照做正好会让"配置跟着盘走"这个核心卖点在 Mac 上
彻底失效。改为 exFAT,并说明为什么慢、以及我们如何用本机缓存补偿。

track-upstream.yml 的输入描述和输出也翻了 —— 它们会显示给手动触发
workflow 的人。
2026-08-17 19:24:55 +08:00

156 lines
6.4 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: Track OpenClaw upstream
# 自动跟踪 OpenClaw 上游更新(借鉴 agentkernel/openclaw-desktop 的 pin 思路,
# 但补上了它没做的最后一步:定时检测 + 自动 bump + 自动打 tag → 自动发版)。
#
# 工作原理:
# 1. 每天 cron 跑 `npm view openclaw version` 拿上游 npm 最新版
# 2. 和仓库里的 OPENCLAW_VERSIONpin比对
# 3. 上游更新了 → 改 OPENCLAW_VERSION根 + portable/、bump 壳版本 patch、
# commit、push 新 tag v<壳版本>
# 4. push tag 触发 release.yml → 自动构建 Win/Mac 便携版+桌面版并发布 Release
#
# 设计原则:
# - 幂等:上游没新版就什么都不做,安静退出
# - 可手动workflow_dispatch 支持手动触发、强制指定上游版本、dry-run 只看不改
# - 单一可信源OPENCLAW_VERSION 是上游 pinu-claw-app/package.json 是壳版本
on:
schedule:
# 每天 UTC 01:00北京时间 09:00检查一次
- cron: '0 1 * * *'
workflow_dispatch:
inputs:
force_version:
description: 'Pin a specific upstream OpenClaw version (blank = whatever npm says is latest)'
required: false
default: ''
dry_run:
description: 'Check only, change nothing (true/false)'
required: false
default: 'false'
permissions:
contents: write
jobs:
track:
name: Check upstream & auto-bump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# 需要完整历史才能正确打 tag / 读已有 tag
fetch-depth: 0
# 半自动模式(默认):用 GITHUB_TOKEN push tag。GitHub 防递归机制下
# 自动推的 tag 不会触发 release.yml所以需到 Actions 手动点一次 Run release。
# 想升级成全自动:去仓库 Settings → Secrets 加一个 RELEASE_PAT个人访问令牌
# repo 权限),本行会自动优先用它 pushtag 即可自动触发发版。
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Resolve upstream OpenClaw version
id: upstream
run: |
force="${{ github.event.inputs.force_version }}"
if [ -n "$force" ]; then
latest="${force#v}"
echo "Forced upstream version: $latest"
else
latest="$(npm view openclaw version --registry=https://registry.npmjs.org 2>/dev/null | tr -d '[:space:]')"
echo "npm latest openclaw: $latest"
fi
if [ -z "$latest" ]; then
echo "::error::Could not read the upstream openclaw version — npm view failed"
exit 1
fi
echo "latest=$latest" >> "$GITHUB_OUTPUT"
- name: Read current pin
id: current
run: |
pinned="$(tr -d '[:space:]' < OPENCLAW_VERSION)"
shell_ver="$(node -p "require('./u-claw-app/package.json').version")"
echo "pinned=$pinned" >> "$GITHUB_OUTPUT"
echo "shell_ver=$shell_ver" >> "$GITHUB_OUTPUT"
echo "Currently pinned: $pinned | shell version: $shell_ver"
- name: Decide whether to bump
id: decide
run: |
latest="${{ steps.upstream.outputs.latest }}"
pinned="${{ steps.current.outputs.pinned }}"
if [ "$latest" = "$pinned" ]; then
echo "Already up to date (pinned=$pinned) — nothing to release."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# 只在 latest 严格 > pinned 时发版(避免上游撤版导致回退)
newer="$(printf '%s\n%s\n' "$pinned" "$latest" | sort -V | tail -1)"
if [ "$newer" != "$latest" ]; then
echo "npm latest ($latest) is not newer than the pin ($pinned) — skipping."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Upstream has moved: $pinned -> $latest"
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Compute next shell version (patch bump)
if: steps.decide.outputs.changed == 'true'
id: nextver
run: |
cur="${{ steps.current.outputs.shell_ver }}"
IFS='.' read -r MA MI PA <<< "$cur"
PA=$((PA + 1))
next="${MA}.${MI}.${PA}"
echo "Bumping shell version: $cur -> $next"
echo "next=$next" >> "$GITHUB_OUTPUT"
- name: Apply changes (pin + version files)
if: steps.decide.outputs.changed == 'true' && github.event.inputs.dry_run != 'true'
run: |
latest="${{ steps.upstream.outputs.latest }}"
next="${{ steps.nextver.outputs.next }}"
# 1) 更新上游 pin根 + portable/ 两份保持一致)
printf '%s\n' "$latest" > OPENCLAW_VERSION
printf '%s\n' "$latest" > portable/OPENCLAW_VERSION
# 2) bump 壳版本package.json。release.yml 仍会从 tag 同步,
# 这里写一份让 main 分支也保持一致。
node -e "const f='u-claw-app/package.json';const p=require('./'+f);p.version='$next';require('fs').writeFileSync(f, JSON.stringify(p,null,2)+'\n')"
echo "Wrote OPENCLAW_VERSION=$latest, shell version=$next"
- name: Commit, tag & push
if: steps.decide.outputs.changed == 'true' && github.event.inputs.dry_run != 'true'
run: |
latest="${{ steps.upstream.outputs.latest }}"
next="${{ steps.nextver.outputs.next }}"
git config user.name "u-claw-bot"
git config user.email "bot@u-claw.org"
git add OPENCLAW_VERSION portable/OPENCLAW_VERSION u-claw-app/package.json
git commit -m "chore(upstream): follow OpenClaw $latest, release v$next
Automated: upstream OpenClaw moved to $latest, so the shell version
is bumped to $next and tagged, which triggers a release."
git push origin HEAD:main
# 打 tag 触发 release.yml
git tag "v$next"
git push origin "v$next"
echo "Pushed v$next — release.yml will build and publish it."
- name: Dry-run summary
if: steps.decide.outputs.changed == 'true' && github.event.inputs.dry_run == 'true'
run: |
echo "DRY RUN — nothing changed."
echo "Would set OPENCLAW_VERSION ${{ steps.current.outputs.pinned }} -> ${{ steps.upstream.outputs.latest }} and release v${{ steps.nextver.outputs.next }}"