Skip to content

Commit 2234f22

Browse files
committed
ci: add build workflow
1 parent b6a3bc4 commit 2234f22

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/build.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build Platform Binaries
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
build-platform:
11+
name: Build ${{ matrix.slug }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
slug: codemachine-linux-x64
19+
- os: ubuntu-latest
20+
slug: codemachine-linux-arm64
21+
target: linux-arm64
22+
- os: macos-14
23+
slug: codemachine-darwin-arm64
24+
- os: macos-14
25+
slug: codemachine-darwin-x64
26+
target: darwin-x64
27+
- os: windows-latest
28+
slug: codemachine-windows-x64
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Read Bun version from package.json
34+
id: bun-version
35+
shell: bash
36+
run: echo "version=$(jq -r '.engines.bun' package.json)" >> $GITHUB_OUTPUT
37+
38+
- name: Setup Bun
39+
uses: oven-sh/setup-bun@v1
40+
with:
41+
bun-version: ${{ steps.bun-version.outputs.version }}
42+
43+
- name: Install dependencies
44+
run: bun install --frozen-lockfile
45+
46+
- name: Build platform binary
47+
shell: bash
48+
run: |
49+
if [ -n "${{ matrix.target }}" ]; then
50+
bun run build --target ${{ matrix.target }}
51+
else
52+
bun run build
53+
fi
54+
55+
- name: Verify cm alias in package.json
56+
shell: bash
57+
run: |
58+
if ! grep -q '"cm"' binaries/${{ matrix.slug }}/package.json; then
59+
echo "❌ ERROR: 'cm' alias missing from binaries/${{ matrix.slug }}/package.json"
60+
exit 1
61+
fi
62+
echo "✅ cm alias verified in package.json"
63+
64+
- name: Test binary execution (Unix)
65+
if: runner.os != 'Windows' && matrix.target == ''
66+
continue-on-error: true
67+
run: |
68+
chmod +x binaries/${{ matrix.slug }}/codemachine
69+
binaries/${{ matrix.slug }}/codemachine --version || echo "⚠️ Binary execution test skipped (may require dependencies)"
70+
71+
- name: Test binary execution (Windows)
72+
if: runner.os == 'Windows'
73+
continue-on-error: true
74+
run: |
75+
binaries/${{ matrix.slug }}/codemachine.exe --version
76+
if ($LASTEXITCODE -ne 0) { Write-Host "⚠️ Binary execution test skipped (may require dependencies)" }
77+
78+
- name: Upload binary package
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: ${{ matrix.slug }}
82+
path: binaries/${{ matrix.slug }}
83+
84+
- name: Smoke test platform binary
85+
if: matrix.target == ''
86+
shell: bash
87+
run: |
88+
chmod +x binaries/${{ matrix.slug }}/codemachine* || true
89+
binaries/${{ matrix.slug }}/codemachine --version
90+
91+
- name: Verify cross-compiled binary exists
92+
if: matrix.target != ''
93+
shell: bash
94+
run: |
95+
if [ -f "binaries/${{ matrix.slug }}/codemachine" ]; then
96+
echo "✅ Cross-compiled binary exists: binaries/${{ matrix.slug }}/codemachine"
97+
file binaries/${{ matrix.slug }}/codemachine
98+
else
99+
echo "❌ Binary not found"
100+
exit 1
101+
fi

0 commit comments

Comments
 (0)