Skip to content

Commit 94aae5e

Browse files
committed
fix(release): use native signing for Darwin binaries
1 parent fc08001 commit 94aae5e

2 files changed

Lines changed: 8 additions & 41 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
publish-stable:
3232
if: inputs.mode == 'stable' && inputs.package != 'bailian-kb-dsh'
3333
name: publish stable (${{ inputs.package }}) to npm + binary + tag
34-
runs-on: ubuntu-latest
34+
# Apple's codesign handles Bun's cross-compiled Intel Mach-O; rcodesign 0.29.0 panics here.
35+
runs-on: macos-15-intel
3536
environment: production # Required Reviewers gate
3637
permissions:
3738
contents: write # push tag + create GitHub Release with binary assets
@@ -52,28 +53,10 @@ jobs:
5253
set -euo pipefail
5354
GITLEAKS_VERSION=8.21.2
5455
curl -sSfL \
55-
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
56+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_darwin_x64.tar.gz" \
5657
| sudo tar -xz -C /usr/local/bin gitleaks
5758
gitleaks version
5859
59-
- name: Ensure zip and tar (per-platform binary archives)
60-
run: sudo apt-get update && sudo apt-get install -y zip
61-
62-
# bun build --compile leaves an invalid darwin linker signature. rcodesign
63-
# re-signs those Mach-O files on the Linux runner (binary-codesign.mjs).
64-
- name: Install rcodesign (ad-hoc sign darwin binaries)
65-
run: |
66-
set -euo pipefail
67-
RCODESIGN_VERSION=0.29.0
68-
asset="apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl.tar.gz"
69-
curl -fsSL -o "/tmp/${asset}" \
70-
"https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign/${RCODESIGN_VERSION}/${asset}"
71-
tar -xzf "/tmp/${asset}" -C /tmp
72-
sudo install -m 755 \
73-
"/tmp/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl/rcodesign" \
74-
/usr/local/bin/rcodesign
75-
rcodesign --version
76-
7760
- run: pnpm install --frozen-lockfile
7861

7962
# Binary compile uses `bun build --compile` CLI (not Bun.build API).
@@ -101,7 +84,8 @@ jobs:
10184
publish-channel:
10285
if: inputs.mode == 'channel' && inputs.package != 'bailian-kb-dsh'
10386
name: publish channel (${{ inputs.package }}) to npm + binary
104-
runs-on: ubuntu-latest
87+
# Keep binary publishing on Apple codesign; Linux rcodesign 0.29.0 panics on Intel Mach-O.
88+
runs-on: macos-15-intel
10589
permissions:
10690
contents: write # create prerelease GitHub Release with binary assets
10791
id-token: write # OIDC for npm Trusted Publishing + provenance
@@ -127,28 +111,10 @@ jobs:
127111
set -euo pipefail
128112
GITLEAKS_VERSION=8.21.2
129113
curl -sSfL \
130-
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
114+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_darwin_x64.tar.gz" \
131115
| sudo tar -xz -C /usr/local/bin gitleaks
132116
gitleaks version
133117
134-
- name: Ensure zip and tar (per-platform binary archives)
135-
run: sudo apt-get update && sudo apt-get install -y zip
136-
137-
# bun build --compile leaves an invalid darwin linker signature. rcodesign
138-
# re-signs those Mach-O files on the Linux runner (binary-codesign.mjs).
139-
- name: Install rcodesign (ad-hoc sign darwin binaries)
140-
run: |
141-
set -euo pipefail
142-
RCODESIGN_VERSION=0.29.0
143-
asset="apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl.tar.gz"
144-
curl -fsSL -o "/tmp/${asset}" \
145-
"https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign/${RCODESIGN_VERSION}/${asset}"
146-
tar -xzf "/tmp/${asset}" -C /tmp
147-
sudo install -m 755 \
148-
"/tmp/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl/rcodesign" \
149-
/usr/local/bin/rcodesign
150-
rcodesign --version
151-
152118
- run: pnpm install --frozen-lockfile
153119

154120
# Binary compile uses `bun build --compile` CLI (not Bun.build API).

‎docs/agents/publish.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ node tools/release/publish-channel.mjs --channel test --knowledge --dry-run
115115
- **GitHub Release**:`contents: write` + `GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}`(stable / channel 均需)
116116
- **Node 版本**:24(npm 11.5+ 才支持 OIDC token 交换)
117117
- **Bun**:`oven-sh/setup-bun`,版本钉死在 workflow 中
118-
- **darwin 签名**:编完后 `binary-codesign.mjs` 对 darwin Mach-O 做 ad-hoc 重签,并按 Apple 的方式重算每一页 SHA-256(末页不补零)。对不上就中止发布。macOS runner 额外跑 `codesign --verify --strict`。Linux runner 用 `rcodesign 0.29.0 sign`;不要用 `rcodesign verify`(会拒绝 Apple 已通过的 ad-hoc 签名)。漏签时 Apple Silicon 会在启动时 SIGKILL
118+
- **darwin 签名**:编完后 `binary-codesign.mjs` 对 darwin Mach-O 做 ad-hoc 重签,并按 Apple 的方式重算每一页 SHA-256(末页不补零)。对不上就中止发布。含二进制的 stable / channel job 使用 `macos-15-intel` 和 Apple `codesign`;`rcodesign 0.29.0` 在 Linux 上签 Bun 的 darwin-x64 二进制会 panic。漏签时 Apple Silicon 会在启动时 SIGKILL
119119
- **Actions 版本**:checkout/setup-node/pnpm-action 均为 v6(Node 24 兼容)
120120
- **npm 配置**:当前 release tooling 发布的包(`bailian-cli-core` / `bailian-cli-runtime` / `bailian-cli-commands` / `bailian-cli` / `knowledge-studio-cli`)的 Trusted Publisher 指向 `modelstudioai/cli` 的 `publish.yml`;新增发布包时同步 npm Trusted Publisher
121121

@@ -162,6 +162,7 @@ node tools/release/publish-channel.mjs --channel test --knowledge --dry-run
162162
| CI 用 Node 22(npm 10)跑 publish | npm 10 不支持 OIDC token 交换,publish 报 404 |
163163
| stable 发布前没有升级版本号 | 所选发布集合的版本已全部存在于 npm,CI 明确报错并要求先升级版本号 |
164164
| channel job 缺少 `contents: write` | `gh release create` 失败 |
165+
| 在 Linux runner 上用 `rcodesign 0.29.0` 签 Bun 的 darwin-x64 二进制 | `rcodesign` 因签名范围越界 panic;二进制发布在生成 Release / npm 前中止 |
165166
| darwin 二进制编完后没有 ad-hoc 重签 | Apple Silicon / macOS 27 对失效的 linker 签名直接 SIGKILL(`Killed: 9`) |
166167
| npm 先于二进制 / OSS 成功 | latest 已发出,CDN 上没有对应 zip/tar.gz;OSS 网络失败时无法回滚 npm |
167168
| stable 未先推 tag 就建 Release | `--verify-tag` 失败 |

0 commit comments

Comments
 (0)