chore(devex): CI 加 mac 矩阵 + version-triplet 校验 + bump-version.sh
审查反馈:
1. CI 缺质量门禁 — 仅 windows-latest 1 job,mac 端 cargo check 路径
无 PR-time 验证,每次 release-tauri.yml 才暴露平台问题
2. .gitignore 不全 — promo-openless-v2/ 反复出现在 git status;
node_modules / dist / target 没全局兜底
3. 版本号同步风险 — package.json + tauri.conf.json + Cargo.toml 三处
人工改,每次发版都担心漏一处
改动:
A. .github/workflows/ci.yml
- 单一 windows-tauri job → matrix(macos-latest + windows-latest)
- mac job:cargo check + npm run build 验证跨平台编译
- Windows job:保留原 preflight + ps1 tokenize
- 新加 step:Verify version triplet stays in sync(两端都跑)—
一旦 package.json / tauri.conf.json / Cargo.toml 三处 drift 立刻
fail,给发版工程加 long-running guard
B. .gitignore
- 加 promo-openless-v2/(已实测出现在 untracked)
- 加 node_modules/ + dist/ + target/ 全局兜底(避免某子目录漏配
时 build artifact 进 PR)
- 加 .cargo/registry / .cargo/git 兜底
C. scripts/bump-version.sh(新文件)
- 1 个参数(X.Y.Z),sed 同步改 3 个文件 + cargo update -p openless
同步 Cargo.lock
- 验证三处一致后输出后续 git 操作建议
- 跨 macOS sed / GNU sed 兼容(-i.bak 后 rm)
下次发版:./scripts/bump-version.sh 1.2.21 一行搞定。
未来 PR 漏改版本号 CI 立刻 fail,不需要靠人记忆。
This commit is contained in:
1 parent
095e3127bb
commit
b997f5fca2
3 files changed
+147
-5
No files matched your search
@@ -1,5 +1,11 @@
|
||||
name: CI
|
||||
|
||||
# 多平台跨语言质量门禁。release-tauri.yml 是发版流水线(仅打包构建),这里负责
|
||||
# 在合并前快速验证两件事:
|
||||
# 1. 前端 typecheck + vite bundle 通过(tsc + vite build,捕获跨 locale 类型 drift)
|
||||
# 2. Rust 后端在 macOS / Windows 都能 cargo check 过(捕获 cfg 漏分支 / 平台 API 误用)
|
||||
# 跑 build-mac.sh / windows-package-msvc.ps1 太重;只跑轻量 cargo check + vite build。
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, dev]
|
||||
@@ -7,9 +13,20 @@ on:
|
||||
branches: [main, dev]
|
||||
|
||||
jobs:
|
||||
windows-tauri:
|
||||
name: Windows Tauri checks
|
||||
runs-on: windows-latest
|
||||
cross-platform:
|
||||
name: ${{ matrix.label }} checks
|
||||
strategy:
|
||||
# 一个平台挂掉不阻塞其他平台拿到验证结果。
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-latest
|
||||
label: macOS
|
||||
preflight: false
|
||||
- os: windows-latest
|
||||
label: Windows
|
||||
preflight: true
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: openless-all/app
|
||||
@@ -32,10 +49,12 @@ jobs:
|
||||
run: npm ci
|
||||
|
||||
- name: Check Windows prerequisites
|
||||
if: matrix.preflight
|
||||
shell: pwsh
|
||||
run: ./scripts/windows-preflight.ps1 -Toolchain msvc
|
||||
|
||||
- name: Check PowerShell scripts
|
||||
if: matrix.preflight
|
||||
shell: pwsh
|
||||
run: |
|
||||
foreach ($script in @("./scripts/windows-preflight.ps1", "./scripts/windows-build-gnu.ps1", "./scripts/windows-runtime-smoke.ps1")) {
|
||||
@@ -47,8 +66,25 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
- name: Build frontend
|
||||
- name: Build frontend (tsc + vite)
|
||||
run: npm run build
|
||||
|
||||
- name: Check Tauri backend
|
||||
- name: Check Tauri backend (cargo check)
|
||||
run: cargo check --manifest-path src-tauri/Cargo.toml
|
||||
|
||||
- name: Verify version triplet stays in sync
|
||||
# 两个平台都跑这个校验:Windows runner 自带 git-bash,跨 shell 表现一致。
|
||||
# 一旦三处版本号 drift 立刻 fail,避免发版时再发现漏改。
|
||||
shell: bash
|
||||
run: |
|
||||
PKG=$(node -p "require('./package.json').version")
|
||||
TAU=$(node -p "require('./src-tauri/tauri.conf.json').version")
|
||||
CRG=$(grep -E '^version = ' src-tauri/Cargo.toml | head -1 | sed -E 's/^version = "(.+)"$/\1/')
|
||||
echo "package.json = $PKG"
|
||||
echo "tauri.conf.json = $TAU"
|
||||
echo "Cargo.toml = $CRG"
|
||||
if [ "$PKG" != "$TAU" ] || [ "$PKG" != "$CRG" ]; then
|
||||
echo "::error::version triplet 不一致 — 请用 scripts/bump-version.sh 同步更新"
|
||||
exit 1
|
||||
fi
|
||||
echo "[ok] 三处版本号一致:$PKG"
|
||||
@@ -22,9 +22,18 @@ SC/
|
||||
apps/
|
||||
promo/
|
||||
promo-openless/
|
||||
promo-openless-v2/
|
||||
docs/old-promo/
|
||||
.worktrees/
|
||||
|
||||
# 派生产物(兜底):项目曾出现 promo-openless-v2/node_modules 等遗漏,
|
||||
# 这里全局通配,避免某子目录漏配 .gitignore 时把 build artifact 推进 PR。
|
||||
node_modules/
|
||||
dist/
|
||||
target/
|
||||
.cargo/registry/
|
||||
.cargo/git/
|
||||
|
||||
# Windows TSF IME local build outputs
|
||||
openless-all/app/windows-ime/OpenLessIme/
|
||||
openless-all/app/windows-ime/x64/
|
||||
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
# 同步更新 OpenLess 三处版本号 + Cargo.lock。
|
||||
# 用法:
|
||||
# ./scripts/bump-version.sh 1.2.21
|
||||
#
|
||||
# 改的位置(CLAUDE.md 强调必须三处一起改):
|
||||
# - openless-all/app/package.json "version": "X.Y.Z"
|
||||
# - openless-all/app/src-tauri/tauri.conf.json "version": "X.Y.Z"
|
||||
# - openless-all/app/src-tauri/Cargo.toml version = "X.Y.Z"
|
||||
# - openless-all/app/src-tauri/Cargo.lock 通过 cargo update -p openless 同步
|
||||
#
|
||||
# CI 的 cross-platform 任务最后一步会校验三个文件版本号一致;漏改一处直接 fail。
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${1:-}" = "" ]; then
|
||||
echo "用法: $0 <new-version>" >&2
|
||||
echo "例: $0 1.2.21" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW="$1"
|
||||
|
||||
if ! [[ "$NEW" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "错误:版本号必须是 X.Y.Z 数字格式 (拿到 '$NEW')" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
APP="$REPO_ROOT/openless-all/app"
|
||||
|
||||
PKG_JSON="$APP/package.json"
|
||||
TAURI_CONF="$APP/src-tauri/tauri.conf.json"
|
||||
CARGO_TOML="$APP/src-tauri/Cargo.toml"
|
||||
|
||||
for f in "$PKG_JSON" "$TAURI_CONF" "$CARGO_TOML"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
echo "错误:找不到 $f" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# macOS sed 跟 GNU sed 行为不同(-i 后缀必填空字符串)。统一用 -i.bak 然后 rm。
|
||||
update_json_version() {
|
||||
local file="$1"
|
||||
sed -E -i.bak \
|
||||
"s/\"version\":[[:space:]]*\"[0-9]+\.[0-9]+\.[0-9]+\"/\"version\": \"$NEW\"/" \
|
||||
"$file"
|
||||
rm "$file.bak"
|
||||
}
|
||||
|
||||
update_cargo_toml_version() {
|
||||
local file="$1"
|
||||
# 仅匹配文件顶层 [package] 段下的 version = "X.Y.Z",避免误改 dependencies 里的版本。
|
||||
# OpenLess 项目 Cargo.toml 第一个出现的 version = 一定是 [package] 自己的。
|
||||
sed -E -i.bak \
|
||||
"0,/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"$/s//version = \"$NEW\"/" \
|
||||
"$file"
|
||||
rm "$file.bak"
|
||||
}
|
||||
|
||||
echo "▶ 升 package.json → $NEW"
|
||||
update_json_version "$PKG_JSON"
|
||||
|
||||
echo "▶ 升 tauri.conf.json → $NEW"
|
||||
update_json_version "$TAURI_CONF"
|
||||
|
||||
echo "▶ 升 Cargo.toml → $NEW"
|
||||
update_cargo_toml_version "$CARGO_TOML"
|
||||
|
||||
echo "▶ 同步 Cargo.lock"
|
||||
( cd "$APP/src-tauri" && cargo update -p openless 2>&1 | grep -E 'Updating|Locking|^error' || true )
|
||||
|
||||
echo
|
||||
echo "===== 验证三处版本一致 ====="
|
||||
PKG=$(node -p "require('$PKG_JSON').version")
|
||||
TAU=$(node -p "require('$TAURI_CONF').version")
|
||||
CRG=$(grep -E '^version = ' "$CARGO_TOML" | head -1 | sed -E 's/^version = "(.+)"$/\1/')
|
||||
|
||||
printf '%-20s %s\n' 'package.json:' "$PKG"
|
||||
printf '%-20s %s\n' 'tauri.conf.json:' "$TAU"
|
||||
printf '%-20s %s\n' 'Cargo.toml:' "$CRG"
|
||||
|
||||
if [ "$PKG" != "$NEW" ] || [ "$TAU" != "$NEW" ] || [ "$CRG" != "$NEW" ]; then
|
||||
echo "::error::三处版本号未对齐 — 请检查 sed 是否成功" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "✓ 三处版本号一致:$NEW"
|
||||
echo
|
||||
echo "下一步建议:"
|
||||
echo " git diff --stat $PKG_JSON $TAURI_CONF $CARGO_TOML \"$APP/src-tauri/Cargo.lock\""
|
||||
echo " git add $PKG_JSON $TAURI_CONF $CARGO_TOML \"$APP/src-tauri/Cargo.lock\""
|
||||
echo " git commit -m 'chore(release): $NEW'"
|
||||
echo " git push"
|
||||
echo " git tag v$NEW-tauri && git push origin v$NEW-tauri"
|
||||
Reference in new issue
Block a user