Skip to content

Commit 417f0bc

Browse files
Bulat Yapparovclaude
andcommitted
fix: refresh platform binary optionalDependencies on every release
The committed @aictrl/cli optionalDependencies hard-pinned @aictrl/cli-linux-x64 to 0.2.0, so 0.3.0 and 0.3.1 both shipped pointing at the old native binary — upgrades silently kept running the 0.2.0 build. Only @aictrl/cli-linux-x64 was even listed; other platforms (linux-arm64, darwin, windows, musl/baseline variants) were built but neither published nor referenced. The publish workflow now (1) loops over every platform binary the build produced under packages/cli/dist/@aictrl/ and publishes each, and (2) regenerates @aictrl/cli's optionalDependencies from those manifests at publish time, preserving genuine runtime optionals (@parcel/watcher, bun-pty) that the compiled binary still resolves at install time. Removed the stale @aictrl/cli-linux-x64 entry from the committed package.json so source-of-truth no longer lies about what ships. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent ed9e952 commit 417f0bc

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,31 @@ jobs:
4646
working-directory: packages/sdk
4747
run: bun pm pack && npm publish *.tgz --access public --provenance || true
4848

49-
- name: Publish @aictrl/cli-linux-x64
50-
working-directory: packages/cli/dist/@aictrl/cli-linux-x64
51-
run: npm publish --access public --provenance || true
49+
- name: Publish platform binary packages
50+
working-directory: packages/cli/dist/@aictrl
51+
run: |
52+
# Publish every @aictrl/cli-<platform>-<arch>[-variant] package that the
53+
# build step produced. Each directory contains a generated package.json
54+
# stamped with the release version. Individual failures (e.g. version
55+
# already published on a rerun) are tolerated to match the convention
56+
# used by the other publish steps in this workflow.
57+
for dir in */; do
58+
echo "Publishing ${dir%/}"
59+
(cd "$dir" && npm publish --access public --provenance) || true
60+
done
5261
53-
- name: Strip bundled deps from CLI package.json
62+
- name: Strip bundled deps and refresh platform binary optionalDependencies
5463
working-directory: packages/cli
5564
run: |
56-
# All dependencies are bundled into the compiled binary.
57-
# Only optionalDependencies (platform binaries) are needed at install time.
65+
# All bundleable dependencies are compiled into the native binary, so
66+
# the published package only needs:
67+
# - platform binary packages (regenerated below from dist/ to match
68+
# the release version — otherwise stale pins ship the wrong binary)
69+
# - genuine runtime optionals like @parcel/watcher and bun-pty that
70+
# must be resolved at install time against the host platform
5871
node -e "
72+
const fs = require('fs');
73+
const path = require('path');
5974
const pkg = require('./package.json');
6075
delete pkg.dependencies;
6176
delete pkg.devDependencies;
@@ -64,7 +79,29 @@ jobs:
6479
delete pkg.overrides;
6580
delete pkg.exports;
6681
delete pkg.type;
67-
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
82+
83+
// Preserve non-platform-binary optionals (real runtime deps);
84+
// drop any @aictrl/cli-* entries so we can repopulate from dist/.
85+
const preserved = {};
86+
for (const [name, version] of Object.entries(pkg.optionalDependencies || {})) {
87+
if (!name.startsWith('@aictrl/cli-')) preserved[name] = version;
88+
}
89+
90+
const distDir = path.join('dist', '@aictrl');
91+
const platformDeps = {};
92+
for (const entry of fs.readdirSync(distDir)) {
93+
const manifest = JSON.parse(
94+
fs.readFileSync(path.join(distDir, entry, 'package.json'), 'utf8')
95+
);
96+
platformDeps[manifest.name] = manifest.version;
97+
}
98+
if (Object.keys(platformDeps).length === 0) {
99+
throw new Error('No platform binary packages found in ' + distDir);
100+
}
101+
102+
pkg.optionalDependencies = { ...preserved, ...platformDeps };
103+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
104+
console.log('optionalDependencies:', pkg.optionalDependencies);
68105
"
69106
70107
- name: Publish @aictrl/cli

‎packages/cli/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
"zod-to-json-schema": "3.24.5"
129129
},
130130
"optionalDependencies": {
131-
"@aictrl/cli-linux-x64": "0.2.0",
132131
"@parcel/watcher": "2.5.1",
133132
"bun-pty": "0.4.8"
134133
},

0 commit comments

Comments
 (0)