110 lines
3.9 KiB
YAML
110 lines
3.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
inputs:
|
|
skip_npm:
|
|
description: 'Skip npm publish'
|
|
type: boolean
|
|
default: false
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
- name: Cache bun dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: bun-${{ runner.os }}-${{ hashFiles('**/bun.lockb') }}
|
|
- name: Install system deps
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev fd-find ripgrep imagemagick
|
|
sudo ln -s $(which fdfind) /usr/local/bin/fd
|
|
sudo ln -sf /usr/bin/convert /usr/local/bin/magick
|
|
- run: bun install --frozen-lockfile
|
|
- run: bun run check
|
|
- run: bun test --only-failures
|
|
- name: CLI smoke test
|
|
run: |
|
|
bun packages/coding-agent/src/cli.ts --version
|
|
bun packages/coding-agent/src/cli.ts --help
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
- name: Cache bun dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: bun-${{ runner.os }}-${{ hashFiles('**/bun.lockb') }}
|
|
- run: bun install --frozen-lockfile
|
|
- name: Install cross-platform native bindings
|
|
run: |
|
|
# bun install only fetches optional deps for current platform (linux-x64)
|
|
# Explicitly install all platform binaries for bun cross-compilation
|
|
bun add --no-save \
|
|
@img/sharp-darwin-arm64@0.34.5 \
|
|
@img/sharp-darwin-x64@0.34.5 \
|
|
@img/sharp-linux-x64@0.34.5 \
|
|
@img/sharp-linux-arm64@0.34.5 \
|
|
@img/sharp-win32-x64@0.34.5 \
|
|
@img/sharp-libvips-darwin-arm64@1.2.4 \
|
|
@img/sharp-libvips-darwin-x64@1.2.4 \
|
|
@img/sharp-libvips-linux-x64@1.2.4 \
|
|
@img/sharp-libvips-linux-arm64@1.2.4
|
|
- name: Build binaries
|
|
run: |
|
|
cd packages/coding-agent
|
|
mkdir -p binaries
|
|
bun build --compile --target=bun-darwin-arm64 ./src/cli.ts --outfile binaries/omp-darwin-arm64
|
|
bun build --compile --target=bun-darwin-x64 ./src/cli.ts --outfile binaries/omp-darwin-x64
|
|
bun build --compile --target=bun-linux-x64 ./src/cli.ts --outfile binaries/omp-linux-x64
|
|
bun build --compile --target=bun-linux-arm64 ./src/cli.ts --outfile binaries/omp-linux-arm64
|
|
bun build --compile --target=bun-windows-x64 ./src/cli.ts --outfile binaries/omp-windows-x64.exe
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: packages/coding-agent/binaries/*
|
|
generate_release_notes: true
|
|
- name: Publish to npm
|
|
if: ${{ !inputs.skip_npm }}
|
|
env:
|
|
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
for pkg in packages/*/; do
|
|
pkg_name=$(basename "$pkg")
|
|
echo "Publishing $pkg_name..."
|
|
output=$(cd "$pkg" && bun publish --access public 2>&1) && echo "$output" && continue
|
|
echo "$output"
|
|
if echo "$output" | grep -q "previously published\|cannot publish over\|You cannot publish over"; then
|
|
echo "Already published, skipping"
|
|
else
|
|
echo "Failed to publish $pkg_name"
|
|
exit 1
|
|
fi
|
|
done
|