Skip to content

Commit 9042784

Browse files
committed
feat: add linux-arm64 support for codemachine
- Add linux-arm64 package to optionalDependencies - Update platformMap in codemachine.js and build.ts to include linux-arm64 - Modify build-binaries.yml workflow to build and verify linux-arm64 binary
1 parent 8154226 commit 9042784

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.github/workflows/build-binaries.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
include:
1717
- os: ubuntu-latest
1818
slug: codemachine-linux-x64
19+
- os: ubuntu-latest
20+
slug: codemachine-linux-arm64
21+
target: linux-arm64
1922
- os: macos-14
2023
slug: codemachine-darwin-arm64
2124
- os: macos-13
@@ -40,7 +43,13 @@ jobs:
4043
run: bun install --frozen-lockfile
4144

4245
- name: Build platform binary
43-
run: bun run build
46+
shell: bash
47+
run: |
48+
if [ -n "${{ matrix.target }}" ]; then
49+
bun run build --target ${{ matrix.target }}
50+
else
51+
bun run build
52+
fi
4453
4554
- name: Verify cm alias in package.json
4655
shell: bash
@@ -52,7 +61,7 @@ jobs:
5261
echo "✅ cm alias verified in package.json"
5362
5463
- name: Test binary execution (Unix)
55-
if: runner.os != 'Windows'
64+
if: runner.os != 'Windows' && matrix.target == ''
5665
continue-on-error: true
5766
run: |
5867
chmod +x binaries/${{ matrix.slug }}/codemachine
@@ -72,7 +81,20 @@ jobs:
7281
path: binaries/${{ matrix.slug }}
7382

7483
- name: Smoke test platform binary
84+
if: matrix.target == ''
7585
shell: bash
7686
run: |
7787
chmod +x binaries/${{ matrix.slug }}/codemachine* || true
7888
binaries/${{ matrix.slug }}/codemachine --version
89+
90+
- name: Verify cross-compiled binary exists
91+
if: matrix.target != ''
92+
shell: bash
93+
run: |
94+
if [ -f "binaries/${{ matrix.slug }}/codemachine" ]; then
95+
echo "✅ Cross-compiled binary exists: binaries/${{ matrix.slug }}/codemachine"
96+
file binaries/${{ matrix.slug }}/codemachine
97+
else
98+
echo "❌ Binary not found"
99+
exit 1
100+
fi

bin/codemachine.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function runBinary(binaryPath, packageRoot) {
7777
// Map Node.js platform/arch to our package names
7878
const platformMap = {
7979
'linux-x64': { pkg: 'codemachine-linux-x64', bin: 'codemachine' },
80+
'linux-arm64': { pkg: 'codemachine-linux-arm64', bin: 'codemachine' },
8081
'darwin-arm64': { pkg: 'codemachine-darwin-arm64', bin: 'codemachine' },
8182
'darwin-x64': { pkg: 'codemachine-darwin-x64', bin: 'codemachine' },
8283
'win32-x64': { pkg: 'codemachine-windows-x64', bin: 'codemachine.exe' },

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"optionalDependencies": {
4444
"codemachine-linux-x64": "0.8.0",
45+
"codemachine-linux-arm64": "0.8.0",
4546
"codemachine-darwin-arm64": "0.8.0",
4647
"codemachine-darwin-x64": "0.8.0",
4748
"codemachine-windows-x64": "0.8.0"

scripts/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ if (watcherVersion) {
135135
// Map platform/arch to target names
136136
const platformMap = {
137137
'linux-x64': { target: 'bun-linux-x64', pkgOs: 'linux', npmOs: 'linux', arch: 'x64', ext: '' },
138+
'linux-arm64': { target: 'bun-linux-arm64', pkgOs: 'linux', npmOs: 'linux', arch: 'arm64', ext: '' },
138139
'darwin-arm64': { target: 'bun-darwin-arm64', pkgOs: 'darwin', npmOs: 'darwin', arch: 'arm64', ext: '' },
139140
'darwin-x64': { target: 'bun-darwin-x64', pkgOs: 'darwin', npmOs: 'darwin', arch: 'x64', ext: '' },
140141
// NOTE: npm expects `win32` in the package.json `os` field; using `windows` causes the
@@ -212,7 +213,7 @@ try {
212213
asset: '[dir]/[name].[ext]', // Preserve original filenames (no hashing)
213214
},
214215
compile: {
215-
target: target as 'bun-linux-x64' | 'bun-darwin-arm64' | 'bun-darwin-x64' | 'bun-windows-x64',
216+
target: target as 'bun-linux-x64' | 'bun-linux-arm64' | 'bun-darwin-arm64' | 'bun-darwin-x64' | 'bun-windows-x64',
216217
outfile: binaryPath,
217218
},
218219
entrypoints: ['./src/runtime/index.ts', manifestPath],

0 commit comments

Comments
 (0)