diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 811b6cb555..42a33fdee7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -207,6 +207,36 @@ jobs: # ABI3 wheels use cpXYZ-abi3 naming; just match any abi3 wheel path: dist/coglet-*-abi3-*.whl + build-coglet-binary: + name: Build coglet binaries + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + - uses: jdx/mise-action@v4 + with: + version: 2026.4.27 + cache_key_prefix: mise-ci-${{ github.job }} + - uses: Swatinem/rust-cache@v2 + with: + workspaces: crates -> target + save-if: ${{ github.ref == 'refs/heads/main' }} + - name: Ensure Rust musl targets + run: rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl + - name: Build coglet binaries + run: mise run build:coglet:binary + - name: Check coglet binary runs + run: | + file dist/coglet_Linux_x86_64 dist/coglet_Linux_arm64 + dist/coglet_Linux_x86_64 --version + - name: Upload coglet binaries + uses: actions/upload-artifact@v6 + with: + name: CogletBinaries + path: | + dist/coglet_Linux_x86_64 + dist/coglet_Linux_arm64 + build-cog: name: Build cog CLI runs-on: ubuntu-latest @@ -752,6 +782,7 @@ jobs: - build-cog - build-sdk - build-rust + - build-coglet-binary - fmt-go - fmt-rust - fmt-python @@ -782,6 +813,7 @@ jobs: echo " build-cog: ${{ needs.build-cog.result }}" echo " build-sdk: ${{ needs.build-sdk.result }}" echo " build-rust: ${{ needs.build-rust.result }}" + echo " build-coglet-binary: ${{ needs.build-coglet-binary.result }}" echo " fmt-go: ${{ needs.fmt-go.result }}" echo " fmt-rust: ${{ needs.fmt-rust.result }}" echo " fmt-python: ${{ needs.fmt-python.result }}" @@ -810,6 +842,7 @@ jobs: "${{ needs.build-cog.result }}" \ "${{ needs.build-sdk.result }}" \ "${{ needs.build-rust.result }}" \ + "${{ needs.build-coglet-binary.result }}" \ "${{ needs.fmt-go.result }}" \ "${{ needs.fmt-rust.result }}" \ "${{ needs.fmt-python.result }}" \ diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index b510ea18ef..a21835cf47 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -296,11 +296,46 @@ jobs: name: coglet-wheel-${{ matrix.artifact-suffix }} path: dist/*.whl + build-coglet-binaries: + name: Build coglet binaries + needs: verify-tag + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - uses: jdx/mise-action@v4 + with: + version: 2026.4.27 + cache_key_prefix: mise-rel-${{ github.job }} + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: crates -> target + key: release-coglet-binaries + + # mise-action does not cache ~/.rustup, so targets may be missing on a cache hit + - name: Ensure Rust musl targets + run: rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl + + - name: Build coglet binaries + run: mise run build:coglet:binary + + - name: Upload coglet binaries + uses: actions/upload-artifact@v6 + with: + name: coglet-binaries + path: | + dist/coglet_Linux_x86_64 + dist/coglet_Linux_arm64 + create-release: name: Create release permissions: contents: write - needs: [verify-tag, build-sdk, build-coglet-wheels] + needs: [verify-tag, build-sdk, build-coglet-wheels, build-coglet-binaries] # macOS arm64 runner: native clang for darwin targets, zig for linux targets. # CGo required for go-tree-sitter (static Python schema parser). runs-on: macos-14 @@ -341,13 +376,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Append Python wheels to the release + # Append Python wheels and coglet binaries to the release - name: Download all wheel artifacts uses: actions/download-artifact@v8 with: path: artifacts - - name: Upload wheels to release + - name: Upload wheels and coglet binaries to release run: | TAG="${{ github.ref_name }}" @@ -355,11 +390,13 @@ jobs: mkdir -p release-wheels cp artifacts/sdk-dist/* release-wheels/ cp artifacts/coglet-wheel-*/*.whl release-wheels/ + cp artifacts/coglet-binaries/coglet_Linux_x86_64 artifacts/coglet-binaries/coglet_Linux_arm64 release-wheels/ # Download goreleaser's checksums.txt and append wheel checksums gh release download "$TAG" -p checksums.txt -D release-wheels cd release-wheels shasum -a 256 *.whl *.tar.gz >> checksums.txt + shasum -a 256 coglet_Linux_x86_64 coglet_Linux_arm64 >> checksums.txt echo "Checksums:" cat checksums.txt cd .. diff --git a/AGENTS.md b/AGENTS.md index 79521f8881..eb9455f597 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -78,6 +78,7 @@ Tasks follow a consistent naming pattern: - `mise run build:coglet:wheel` - Build coglet wheel (native platform) - `mise run build:coglet:wheel:linux-x64` - Build for Linux x86_64 - `mise run build:coglet:wheel:linux-arm64` - Build for Linux ARM64 +- `mise run build:coglet:binary` - Build static coglet binaries for Linux x86_64 and ARM64 - `mise run build:sdk` - Build SDK wheel **Install:** diff --git a/crates/coglet/src/bin/coglet.rs b/crates/coglet/src/bin/coglet.rs new file mode 100644 index 0000000000..cd8a4b887a --- /dev/null +++ b/crates/coglet/src/bin/coglet.rs @@ -0,0 +1,15 @@ +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + match args.as_slice() { + [flag] if flag == "--version" || flag == "-V" => { + println!("coglet {}", coglet::COGLET_VERSION); + ExitCode::SUCCESS + } + _ => { + eprintln!("usage: coglet --version"); + ExitCode::from(2) + } + } +} diff --git a/mise.toml b/mise.toml index 2508819583..6d8a48d646 100644 --- a/mise.toml +++ b/mise.toml @@ -35,7 +35,7 @@ config_roots = ["."] go = "latest" uv = "0.9.26" "pipx:nox" = { version = "2025.11.12", uvx = true, uvx_args = "--python-preference=managed -p 3.13" } -"rust" = { version = "1.93.0", components = "rustfmt,clippy,rust-analyzer", targets = "x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,aarch64-apple-darwin" } +"rust" = { version = "1.93.0", components = "rustfmt,clippy,rust-analyzer", targets = "x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,aarch64-apple-darwin,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl" } cargo-binstall = "1.16.6" # Cargo tools - use aqua backend where available for faster binary downloads # and better security (cosign/SLSA verification). Remaining cargo: tools use binstall. @@ -291,6 +291,23 @@ run = [ { task = "build:coglet:wheel" }, ] +[tasks."build:coglet:binary"] +description = "Build static coglet binaries for Linux x86_64 and ARM64" +sources = ["crates/**/*.rs", "crates/**/Cargo.toml", "crates/Cargo.lock"] +outputs = ["dist/coglet_Linux_x86_64", "dist/coglet_Linux_arm64"] +run = [ + { task = "_setup_dist" }, + """ +#!/usr/bin/env bash +set -euo pipefail +for target in x86_64-unknown-linux-musl aarch64-unknown-linux-musl; do + cargo zigbuild --release --manifest-path crates/Cargo.toml -p coglet --bin coglet --target "$target" +done +cp crates/target/x86_64-unknown-linux-musl/release/coglet dist/coglet_Linux_x86_64 +cp crates/target/aarch64-unknown-linux-musl/release/coglet dist/coglet_Linux_arm64 +""", +] + [tasks."build:sdk"] description = "Build cog SDK wheel" sources = ["python/**/*.py", "pyproject.toml", "VERSION.txt"]