Skip to content

Commit dcc7004

Browse files
PABannierclaude
andcommitted
ci: add CI build and release workflows
CI workflow verifies compilation on macOS (Clang), Linux (GCC), and Windows (MSVC) on every push/PR. Release workflow builds artifacts for 5 platform/arch targets and publishes them to GitHub Releases on tag push. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0d3e3ec commit dcc7004

2 files changed

Lines changed: 244 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: ${{ matrix.name }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- name: macOS (Clang)
22+
os: macos-latest
23+
cmake_args: ""
24+
build_args: ""
25+
26+
- name: Linux (GCC)
27+
os: ubuntu-latest
28+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF"
29+
build_args: ""
30+
31+
- name: Windows (MSVC)
32+
os: windows-latest
33+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF -A x64"
34+
build_args: "--config Release"
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
with:
40+
submodules: recursive
41+
42+
- name: Install Ninja (Linux)
43+
if: runner.os == 'Linux'
44+
run: sudo apt-get update && sudo apt-get install -y ninja-build
45+
46+
- name: Install Ninja (macOS)
47+
if: runner.os == 'macOS'
48+
run: brew install ninja
49+
50+
- name: ccache
51+
uses: hendrikmuhs/ccache-action@v1
52+
with:
53+
key: ci-${{ matrix.os }}
54+
55+
- name: Configure
56+
run: >
57+
cmake -B build
58+
${{ runner.os != 'Windows' && '-G Ninja' || '' }}
59+
${{ matrix.cmake_args }}
60+
${{ runner.os != 'Windows' && '-DCMAKE_BUILD_TYPE=Release' || '' }}
61+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
62+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
63+
64+
- name: Build
65+
run: cmake --build build ${{ matrix.build_args }} --parallel
66+
67+
- name: Verify library
68+
shell: bash
69+
run: |
70+
if [ -f build/libsam3.a ]; then
71+
echo "Found build/libsam3.a"
72+
elif [ -f build/Release/sam3.lib ]; then
73+
echo "Found build/Release/sam3.lib"
74+
elif [ -f build/sam3.lib ]; then
75+
echo "Found build/sam3.lib"
76+
else
77+
echo "ERROR: sam3 library not found"
78+
exit 1
79+
fi

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
name: Build ${{ matrix.name }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- name: macOS arm64 (Metal)
17+
os: macos-latest
18+
artifact: sam3-darwin-arm64
19+
cmake_args: "-DBUILD_SHARED_LIBS=OFF"
20+
build_args: ""
21+
ext: tar.gz
22+
23+
- name: macOS x86_64
24+
os: macos-13
25+
artifact: sam3-darwin-x86_64
26+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF -DBUILD_SHARED_LIBS=OFF"
27+
build_args: ""
28+
ext: tar.gz
29+
30+
- name: Linux x86_64
31+
os: ubuntu-latest
32+
artifact: sam3-linux-x86_64
33+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF -DBUILD_SHARED_LIBS=OFF"
34+
build_args: ""
35+
ext: tar.gz
36+
37+
- name: Linux arm64
38+
os: ubuntu-24.04-arm
39+
artifact: sam3-linux-arm64
40+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF -DBUILD_SHARED_LIBS=OFF"
41+
build_args: ""
42+
ext: tar.gz
43+
44+
- name: Windows x86_64
45+
os: windows-latest
46+
artifact: sam3-win-x86_64
47+
cmake_args: "-DGGML_METAL=OFF -DSAM3_METAL=OFF -DBUILD_SHARED_LIBS=OFF -A x64"
48+
build_args: "--config Release"
49+
ext: zip
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
with:
55+
submodules: recursive
56+
57+
- name: Install Ninja (Linux)
58+
if: runner.os == 'Linux'
59+
run: sudo apt-get update && sudo apt-get install -y ninja-build
60+
61+
- name: Install Ninja (macOS)
62+
if: runner.os == 'macOS'
63+
run: brew install ninja
64+
65+
- name: ccache
66+
uses: hendrikmuhs/ccache-action@v1
67+
with:
68+
key: release-${{ matrix.artifact }}
69+
70+
- name: Configure
71+
run: >
72+
cmake -B build
73+
${{ runner.os != 'Windows' && '-G Ninja' || '' }}
74+
${{ matrix.cmake_args }}
75+
${{ runner.os != 'Windows' && '-DCMAKE_BUILD_TYPE=Release' || '' }}
76+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
77+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
78+
79+
- name: Build
80+
run: cmake --build build ${{ matrix.build_args }} --parallel
81+
82+
- name: Package (Unix)
83+
if: runner.os != 'Windows'
84+
run: |
85+
mkdir -p staging/${{ matrix.artifact }}/{lib,include,bin}
86+
87+
cp build/libsam3.a staging/${{ matrix.artifact }}/lib/
88+
find build/ggml -name "*.a" -exec cp {} staging/${{ matrix.artifact }}/lib/ \;
89+
90+
cp sam3.h staging/${{ matrix.artifact }}/include/
91+
cp -r ggml/include/* staging/${{ matrix.artifact }}/include/
92+
93+
for bin in sam3_quantize sam3_benchmark sam3_profile_edgetam; do
94+
if [ -f "build/examples/${bin}" ]; then
95+
cp "build/examples/${bin}" staging/${{ matrix.artifact }}/bin/
96+
fi
97+
done
98+
99+
cd staging
100+
tar czf ../${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
101+
102+
- name: Package (Windows)
103+
if: runner.os == 'Windows'
104+
shell: pwsh
105+
run: |
106+
New-Item -ItemType Directory -Force -Path staging/${{ matrix.artifact }}/lib
107+
New-Item -ItemType Directory -Force -Path staging/${{ matrix.artifact }}/include
108+
New-Item -ItemType Directory -Force -Path staging/${{ matrix.artifact }}/bin
109+
110+
# Library (MSVC multi-config puts outputs in Release/)
111+
$libPaths = @("build/Release/sam3.lib", "build/sam3.lib")
112+
foreach ($p in $libPaths) {
113+
if (Test-Path $p) { Copy-Item $p staging/${{ matrix.artifact }}/lib/; break }
114+
}
115+
116+
# ggml static libs
117+
Get-ChildItem -Path build/ggml -Recurse -Filter "*.lib" | Copy-Item -Destination staging/${{ matrix.artifact }}/lib/
118+
119+
# Headers
120+
Copy-Item sam3.h staging/${{ matrix.artifact }}/include/
121+
Get-ChildItem -Path ggml/include -Filter "*.h" | Copy-Item -Destination staging/${{ matrix.artifact }}/include/
122+
123+
# Example binaries
124+
foreach ($bin in @("sam3_quantize", "sam3_benchmark", "sam3_profile_edgetam")) {
125+
$paths = @("build/examples/Release/${bin}.exe", "build/examples/${bin}.exe")
126+
foreach ($p in $paths) {
127+
if (Test-Path $p) { Copy-Item $p staging/${{ matrix.artifact }}/bin/; break }
128+
}
129+
}
130+
131+
Compress-Archive -Path staging/${{ matrix.artifact }} -DestinationPath ${{ matrix.artifact }}.zip
132+
133+
- name: Upload artifact
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: ${{ matrix.artifact }}
137+
path: ${{ matrix.artifact }}.${{ matrix.ext }}
138+
139+
release:
140+
name: Create Release
141+
needs: build
142+
runs-on: ubuntu-latest
143+
permissions:
144+
contents: write
145+
146+
steps:
147+
- name: Download all artifacts
148+
uses: actions/download-artifact@v4
149+
with:
150+
path: artifacts
151+
152+
- name: Create GitHub Release
153+
uses: softprops/action-gh-release@v2
154+
with:
155+
tag_name: ${{ github.ref_name }}
156+
name: sam3.cpp ${{ github.ref_name }}
157+
draft: false
158+
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
159+
generate_release_notes: true
160+
files: |
161+
artifacts/sam3-darwin-arm64/*.tar.gz
162+
artifacts/sam3-darwin-x86_64/*.tar.gz
163+
artifacts/sam3-linux-x86_64/*.tar.gz
164+
artifacts/sam3-linux-arm64/*.tar.gz
165+
artifacts/sam3-win-x86_64/*.zip

0 commit comments

Comments
 (0)