Files
oh-my-pi/.github/workflows/ci.yml
T
2026-01-12 11:11:59 +01:00

117 lines
4.2 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: Build darwin-arm64
run: |
cd packages/coding-agent
bun install --os darwin --cpu arm64
bun add --no-save @img/sharp-darwin-arm64@0.34.5 @img/sharp-libvips-darwin-arm64@1.2.4
bun build --compile --target=bun-darwin-arm64 ./src/cli.ts --outfile binaries/omp-darwin-arm64
- name: Build darwin-x64
run: |
cd packages/coding-agent
bun install --os darwin --cpu x64
bun add --no-save @img/sharp-darwin-x64@0.34.5 @img/sharp-libvips-darwin-x64@1.2.4
bun build --compile --target=bun-darwin-x64 ./src/cli.ts --outfile binaries/omp-darwin-x64
- name: Build linux-x64
run: |
cd packages/coding-agent
bun install --os linux --cpu x64
bun add --no-save @img/sharp-linux-x64@0.34.5 @img/sharp-libvips-linux-x64@1.2.4
bun build --compile --target=bun-linux-x64 ./src/cli.ts --outfile binaries/omp-linux-x64
- name: Build linux-arm64
run: |
cd packages/coding-agent
bun install --os linux --cpu arm64
bun add --no-save @img/sharp-linux-arm64@0.34.5 @img/sharp-libvips-linux-arm64@1.2.4
bun build --compile --target=bun-linux-arm64 ./src/cli.ts --outfile binaries/omp-linux-arm64
- name: Build win32-x64
run: |
cd packages/coding-agent
bun install --os win32 --cpu x64
bun add --no-save @img/sharp-win32-x64@0.34.5 @img/sharp-libvips-win32-x64@1.2.4
bun build --compile --target=bun-win32-x64 ./src/cli.ts --outfile binaries/omp-win32-x64
- 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