Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file check prints the binary type but nothing fails if the binaries are dynamically linked — yet "static musl" is the entire point of this artifact. If the musl build ever regresses (e.g. a dependency forces a dynamic link), CI still passes and releases ship non-static binaries. Assert it:

Suggested change
file dist/coglet_Linux_x86_64 dist/coglet_Linux_arm64
file dist/coglet_Linux_x86_64 dist/coglet_Linux_arm64
file dist/coglet_Linux_x86_64 | grep -q "statically linked"
file dist/coglet_Linux_arm64 | grep -q "statically linked"
dist/coglet_Linux_x86_64 --version

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
Expand Down Expand Up @@ -752,6 +782,7 @@ jobs:
- build-cog
- build-sdk
- build-rust
- build-coglet-binary
- fmt-go
- fmt-rust
- fmt-python
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}" \
Expand Down
43 changes: 40 additions & 3 deletions .github/workflows/release-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -341,25 +376,27 @@ 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 }}"

# Collect all wheels
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 ..
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
15 changes: 15 additions & 0 deletions crates/coglet/src/bin/coglet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::process::ExitCode;

fn main() -> ExitCode {
let args: Vec<String> = 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)
}
}
}
19 changes: 18 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"]
Expand Down
Loading