Skip to content

Commit 9ac6a48

Browse files
committed
Embed @napi-rs/keyring native bindings for all CLI release targets
The CLI publish workflow cross-compiles all six bun targets on one Linux host after a single `bun install`. @napi-rs/keyring ships its native binding as os/cpu-gated platform packages, so that install only fetches the host's (@napi-rs/keyring-linux-x64-gnu). bun --compile embeds a binding only when its platform package is present on disk, so every non-linux-x64 binary shipped with no binding and silently fell back to plaintext credential storage at runtime (the keyring code itself landed earlier; this is the missing build half). Fetch each target's platform package (direct npm tarball, which bypasses the os/cpu install skip) before cross-compiling so every released binary embeds its native keyring binding.
1 parent 3ffded3 commit 9ac6a48

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

templates/cli/.github/workflows/publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ jobs:
4646
- name: Install dependencies and build for Linux and Windows
4747
run: |
4848
bun install --frozen-lockfile
49+
# @napi-rs/keyring ships its native binding as os/cpu-gated platform
50+
# packages, so `bun install` only fetches the host's. bun --compile
51+
# embeds a binding only when its platform package is present on disk, so
52+
# fetch the rest before cross-compiling; otherwise those binaries
53+
# silently fall back to plaintext credential storage.
54+
KEYRING_VERSION="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' node_modules/@napi-rs/keyring/package.json | head -1)"
55+
for triple in darwin-arm64 darwin-x64 linux-x64-gnu linux-arm64-gnu win32-x64-msvc win32-arm64-msvc; do
56+
dir="node_modules/@napi-rs/keyring-${triple}"
57+
ls "${dir}"/*.node >/dev/null 2>&1 && continue
58+
mkdir -p "${dir}"
59+
curl -fsSL "https://registry.npmjs.org/@napi-rs/keyring-${triple}/-/keyring-${triple}-${KEYRING_VERSION}.tgz" | tar -xz -C "${dir}" --strip-components=1
60+
done
4961
bun run linux-x64
5062
bun run linux-arm64
5163
bun run mac-x64

0 commit comments

Comments
 (0)