Skip to content

[diskann-garnet] Support inline filtering (#1162) #17

[diskann-garnet] Support inline filtering (#1162)

[diskann-garnet] Support inline filtering (#1162) #17

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
name: Publish diskann-garnet NuGet
on:
push:
tags:
- "diskann-garnet-v*"
env:
RUST_BACKTRACE: 1
permissions:
contents: read
jobs:
build:
name: build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
artifact-name: linux
lib-path: target/release/libdiskann_garnet.so
- os: windows-latest
env:
EXTRA_RUSTFLAGS: -C control-flow-guard
artifact-name: windows
lib-path: target/release/diskann_garnet.dll
pdb-path: target/release/diskann_garnet.pdb
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Build diskann-garnet (release)
env:
RUSTC_BOOTSTRAP: 1
# NOTE: this overrides flags in /.cargo/config.toml so those must be manually merged in here.
RUSTFLAGS: -Z stack-protector=all -C target-cpu=x86-64-v3 ${{ env.EXTRA_RUSTFLAGS }}
run: cargo build --locked --release --package diskann-garnet
- name: Stage native library
shell: bash
run: |
mkdir -p staging
cp "${{ matrix.lib-path }}" staging/
if [ -n "${{ matrix.pdb-path }}" ] && [ -f "${{ matrix.pdb-path }}" ]; then
cp "${{ matrix.pdb-path }}" staging/
fi
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: staging/
if-no-files-found: error
package:
name: package and publish
needs: build
runs-on: windows-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Validate version consistency
shell: bash
run: |
NUSPEC_VER=$(sed -n 's/.*<version>\(.*\)<\/version>.*/\1/p' diskann-garnet/diskann-garnet.nuspec)
CARGO_VER=$(sed -n 's/^version = "\(.*\)"/\1/p' diskann-garnet/Cargo.toml | head -1)
echo "nuspec version: $NUSPEC_VER"
echo "Cargo.toml version: $CARGO_VER"
if [ "$NUSPEC_VER" != "$CARGO_VER" ]; then
echo "::error::Version mismatch: nuspec=$NUSPEC_VER vs Cargo.toml=$CARGO_VER"
exit 1
fi
if [[ "$GITHUB_REF" == refs/tags/diskann-garnet-v* ]]; then
TAG_VER="${GITHUB_REF#refs/tags/diskann-garnet-v}"
echo "tag version: $TAG_VER"
if [ "$TAG_VER" != "$NUSPEC_VER" ]; then
echo "::error::Tag version ($TAG_VER) does not match package version ($NUSPEC_VER)"
exit 1
fi
fi
- name: Create staging directory
shell: bash
run: mkdir -p staging/linux staging/windows staging/docs
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: linux
path: staging/linux/
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows
path: staging/windows/
- name: Copy docs
shell: bash
run: cp diskann-garnet/README.md staging/docs/README.md
- name: Copy nuspec to staging
shell: bash
run: cp diskann-garnet/diskann-garnet.nuspec staging/
- name: Install NuGet CLI
uses: nuget/setup-nuget@v2
- name: Pack NuGet package
working-directory: staging
run: nuget pack diskann-garnet.nuspec -NonInteractive
- name: List nupkg contents
shell: bash
working-directory: staging
run: |
echo "=== NuGet package files ==="
ls -lh *.nupkg
echo ""
echo "=== Package contents ==="
unzip -l *.nupkg
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: staging/*.nupkg
if-no-files-found: error
- name: Publish to NuGet
if: startsWith(github.ref, 'refs/tags/diskann-garnet-v')
working-directory: staging
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json