Skip to content
Open
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
193 changes: 193 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Release

permissions:
contents: read

on:
push:
tags:
- 'v*' # Match v0.3.0, v1.0.0, etc.
workflow_dispatch: # Allow manual trigger

jobs:
# ============================================================================
# Linux x64 Build
# ============================================================================
linux-x64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build build-essential

- name: Build libzvec_c_api.so
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_TOOLS=OFF \
-DBUILD_EXAMPLES=OFF
cmake --build build --parallel --target zvec_c_api

- name: Verify library
run: |
echo "=== Library file ==="
ls -lh build/src/c_api/libzvec_c_api.so
echo "=== Check dependencies ==="
ldd build/src/c_api/libzvec_c_api.so || true

- name: Create tarball
run: |
cp src/include/zvec/c_api.h .
cp build/src/c_api/libzvec_c_api.so .
tar -czvf libzvec-capi-linux-x64.tar.gz \
c_api.h \
libzvec_c_api.so

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: zvec-capi-linux-x64
path: libzvec-capi-linux-x64.tar.gz

# ============================================================================
# Linux ARM64 Build
# ============================================================================
linux-arm64:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build build-essential

- name: Build libzvec_c_api.so (ARM64)
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_TOOLS=OFF \
-DBUILD_EXAMPLES=OFF
cmake --build build --parallel --target zvec_c_api

- name: Verify library
run: |
echo "=== Library file ==="
ls -lh build/src/c_api/libzvec_c_api.so
echo "=== Check dependencies ==="
ldd build/src/c_api/libzvec_c_api.so || true

- name: Create tarball
run: |
cp src/include/zvec/c_api.h .
cp build/src/c_api/libzvec_c_api.so .
tar -czvf libzvec-capi-linux-arm64.tar.gz \
c_api.h \
libzvec_c_api.so

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: zvec-capi-linux-arm64
path: libzvec-capi-linux-arm64.tar.gz

# ============================================================================
# macOS Universal Build (arm64 + x86_64)
# ============================================================================
macos-universal:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install dependencies
run: |
brew install cmake ninja

- name: Build libzvec_c_api.dylib (Universal Binary)
env:
CMAKE_OSX_ARCHITECTURES: "arm64;x86_64"
MACOSX_DEPLOYMENT_TARGET: "11.0"
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_TOOLS=OFF \
-DBUILD_EXAMPLES=OFF
cmake --build build --parallel --target zvec_c_api

- name: Verify library
run: |
echo "=== Library file ==="
ls -lh build/src/c_api/libzvec_c_api.dylib
echo "=== Check architectures ==="
lipo -archs build/src/c_api/libzvec_c_api.dylib

- name: Create tarball
run: |
cp src/include/zvec/c_api.h .
cp build/src/c_api/libzvec_c_api.dylib .
tar -czvf libzvec-capi-macos-universal.tar.gz \
c_api.h \
libzvec_c_api.dylib

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: zvec-capi-macos-universal
path: libzvec-capi-macos-universal.tar.gz

# ============================================================================
# Upload to GitHub Releases
# ============================================================================
upload-release:
needs: [linux-x64, linux-arm64, macos-universal]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Download build artifacts for each platform
- uses: actions/download-artifact@v4
with:
name: zvec-capi-linux-x64
path: dist/

- uses: actions/download-artifact@v4
with:
name: zvec-capi-linux-arm64
path: dist/

- uses: actions/download-artifact@v4
with:
name: zvec-capi-macos-universal
path: dist/

- name: List artifacts
run: ls -la dist/

# Upload to GitHub Releases
- uses: softprops/action-gh-release@v1
with:
files: dist/*.tar.gz
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ message(STATUS "BUILD_TOOLS:${BUILD_TOOLS}")
option(USE_OSS_MIRROR "Use OSS mirror for faster third-party downloads" ON)
message(STATUS "USE_OSS_MIRROR:${USE_OSS_MIRROR}")

option(BUILD_EXAMPLES "Build examples" ON)
message(STATUS "BUILD_EXAMPLES:${BUILD_EXAMPLES}")

cc_directory(thirdparty)
cc_directories(src)
cc_directories(tests)
if(BUILD_EXAMPLES)
cc_directories(examples)
endif()

if(BUILD_TOOLS)
cc_directories(tools)
Expand Down
15 changes: 15 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025-present the zvec project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_subdirectory(c_api)
65 changes: 65 additions & 0 deletions examples/c_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2025-present the zvec project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Basic example
add_executable(c_api_basic_example basic_example.c)
target_link_libraries(c_api_basic_example PRIVATE zvec_c_api)
target_include_directories(c_api_basic_example PRIVATE
${PROJECT_SOURCE_DIR}/src/include
)
set_target_properties(c_api_basic_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/c_api
)


# Schema example
add_executable(c_api_collection_schema_example collection_schema_example.c)
target_link_libraries(c_api_collection_schema_example PRIVATE zvec_c_api)
target_include_directories(c_api_collection_schema_example PRIVATE
${PROJECT_SOURCE_DIR}/src/include
)
set_target_properties(c_api_collection_schema_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/c_api
)

# Struct document example
add_executable(c_api_doc_example doc_example.c)
target_link_libraries(c_api_doc_example PRIVATE zvec_c_api)
target_include_directories(c_api_doc_example PRIVATE
${PROJECT_SOURCE_DIR}/src/include
)
set_target_properties(c_api_doc_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/c_api
)

# Index example
add_executable(c_api_index_example index_example.c)
target_link_libraries(c_api_index_example PRIVATE zvec_c_api)
set_target_properties(c_api_index_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/examples/c_api
)

# Newly added field schema example
add_executable(c_api_field_schema_example field_schema_example.c)
target_link_libraries(c_api_field_schema_example PRIVATE zvec_c_api)
set_target_properties(c_api_field_schema_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/examples/c_api
)

# Optimized example
add_executable(c_api_optimized_example optimized_example.c)
target_link_libraries(c_api_optimized_example PRIVATE zvec_c_api)
set_target_properties(c_api_optimized_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/examples/c_api
)
Loading
Loading