Skip to content

fix(binding): 修复 darwin-x64 构建配置并添加验证脚本#18787

Merged
Single-Dancer merged 1 commit intomainfrom
fix/build-binding
Jan 23, 2026
Merged

fix(binding): 修复 darwin-x64 构建配置并添加验证脚本#18787
Single-Dancer merged 1 commit intomainfrom
fix/build-binding

Conversation

@Single-Dancer
Copy link
Copy Markdown
Collaborator

@Single-Dancer Single-Dancer commented Jan 23, 2026

这个 PR 做了什么? (简要描述所做更改)

  • 为 x86_64-apple-darwin 构建添加 --target 参数,修复文件名错误问题
  • 为所有构建目标显式指定 --target 参数,确保构建一致性
  • 添加 scripts/verify-bindings.js 验证脚本
  • 在发布流程中添加 binding 包完整性验证步骤

问题原因:

  • GitHub Actions 的 macos-latest 现在默认是 ARM64
  • 不指定 --target 会导致 NAPI-RS 检测到 ARM64,生成错误的文件名
  • x86_64-apple-darwin 构建生成了 taro.darwin-arm64.node 而不是 taro.darwin-x64.node
  • 导致发布到 npm 的 @tarojs/binding-darwin-x64 包缺少 .node 文件

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

发布说明

  • Chores
    • 优化多平台原生构建流程,显式指定目标平台以改进跨平台构建和发布的一致性(涵盖 macOS、Windows 与 Linux musl)。
  • New Features
    • 在发布流程中新增预构建原生绑定的校验步骤和验证脚本,自动检测绑定完整性并在校验失败时阻止发布,提供失败指引与本地化提示。

✏️ Tip: You can customize this high-level summary in your review settings.

@Single-Dancer Single-Dancer requested a review from tutuxxx January 23, 2026 04:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 23, 2026

Walkthrough

为多个平台的 Rust 本机绑定构建命令添加显式 --target 参数,并在发布工作流中新增运行 scripts/verify-bindings.js 的验证步骤;同时新增用于校验预构建绑定的 Node.js 脚本(中文输出)。

Changes

Cohort / File(s) 变更摘要
构建工作流目标指定
.github/workflows/build-rust-binding.yml
在各平台的 pnpm build:binding:release 步骤中显式添加 --target <triple>(如 x86_64-apple-darwinx86_64-pc-windows-msvcx86_64-unknown-linux-musl),确保跨目标构建命令带上目标三元组。
发布工作流验证步骤
.github/workflows/publish.yml
在 "List Packages" 之后新增 "Verify Bindings" 步骤,执行 node scripts/verify-bindings.js,在发布前校验预构建绑定。
绑定验证脚本
scripts/verify-bindings.js
新增脚本:定义多平台绑定条目,校验绑定目录、package.json、绑定二进制文件存在且满足最小文件大小,比较 package.jsonmain 与预期 nodeFile,失败时以非零码退出;消息为中文。

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor "GitHub Actions Runner" as Runner
    participant "publish.yml workflow" as Workflow
    participant "scripts/verify-bindings.js" as Verifier
    participant "Repo File System" as FS
    Runner->>Workflow: 触发发布流程
    Workflow->>Verifier: 运行 `node scripts/verify-bindings.js`
    Verifier->>FS: 读取各 target 目录、package.json 与二进制文件
    FS-->>Verifier: 返回存在/大小/内容信息
    Verifier-->>Workflow: 返回成功或错误(exit 0/1)
    Workflow-->>Runner: 根据返回继续或中止发布
Loading
sequenceDiagram
    autonumber
    actor "GitHub Actions Runner" as Runner
    participant "build-rust-binding.yml" as BuildWF
    participant "pnpm / docker" as Builder
    participant "Rust Cross-Compiler" as RustBuild
    Runner->>BuildWF: 启动构建工作流
    BuildWF->>Builder: 调用 `pnpm build:binding:release --target <triple>`
    Builder->>RustBuild: 触发对应目标的构建(本机或容器)
    RustBuild-->>Builder: 生成绑定产物
    Builder-->>BuildWF: 返回构建结果
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 分钟

Possibly related PRs

Suggested reviewers

  • luckyadam
  • yechunxi
  • tutuxxx

Poem

🐰✨ 我是小兔巡视仓,目标三元归一行,
检查绑定逐条看,二进制稳又香,
发布前夜心更安,跨平台路闯荡 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 该标题清晰地总结了主要改动:修复 darwin-x64 构建配置问题并添加验证脚本,与 PR 的核心内容完全相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/build-binding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Single-Dancer Single-Dancer added this to the 4.1.11 milestone Jan 23, 2026
@coderabbitai coderabbitai Bot requested review from luckyadam and yechunxi January 23, 2026 04:41
@Single-Dancer Single-Dancer linked an issue Jan 23, 2026 that may be closed by this pull request
21 tasks
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.31%. Comparing base (3a162d7) to head (9887704).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #18787   +/-   ##
=======================================
  Coverage   56.31%   56.31%           
=======================================
  Files         447      447           
  Lines       23352    23352           
  Branches     5794     5770   -24     
=======================================
  Hits        13150    13150           
- Misses       8367     8377   +10     
+ Partials     1835     1825   -10     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 60.27% <ø> (ø)
taro-web 53.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot requested a review from tutuxxx January 23, 2026 05:46
@Single-Dancer Single-Dancer merged commit df16089 into main Jan 23, 2026
41 checks passed
@Single-Dancer Single-Dancer deleted the fix/build-binding branch January 23, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4.1.10版本初始化项目报错

2 participants