Skip to content

Improve/api and packaging#3

Merged
mar4elkin merged 4 commits into
masterfrom
improve/api-and-packaging
Mar 17, 2026
Merged

Improve/api and packaging#3
mar4elkin merged 4 commits into
masterfrom
improve/api-and-packaging

Conversation

@mar4elkin

Copy link
Copy Markdown
Contributor

Summary

This PR adds NuGet packaging and for both .NET and Unity.

The repository now supports:

  • a shared managed wrapper source without duplicated C# API files
  • Unity distribution through annoy.net.unitypackage
  • .NET distribution through the Annoy.Net NuGet package
  • automated release publishing for native binaries, the Unity package, and the NuGet package

What changed

Shared managed source

  • removed the duplicated annoy_sharp/Annoy.cs
  • kept a single managed API source
  • exposed the non-Unity wrapper through src/Annoy.Net/Annoy.Net.csproj

Unity packaging improvements

  • relaxed Unity asmdef platform restrictions so the managed assembly is no longer Windows-only
  • added Unity package samples under Samples~
  • added Unity runtime tests under Tests/Runtime
  • updated the Unity package metadata
  • fixed .unitypackage generation so it imports cleanly into Assets/Annoy.NET
  • ensured the release unitypackage includes native libraries for Windows, Linux, and macOS

NuGet packaging

  • added package metadata for Annoy.Net
  • added native runtime assets to the .nupkg for:
    • win-x64
    • linux-x64
    • osx-x64
  • added a packaging script to build the NuGet artifact locally
  • added a smoke test project that validates the package through a real PackageReference

CI and release pipeline

  • extended GitHub Actions so release builds now:
  • build and test native binaries on Windows, Linux, and macOS
  • run managed smoke tests
  • build annoy.net.unitypackage
  • build Annoy.Net.nupkg
  • attach native binaries, the Unity package, and the NuGet package to GitHub Releases
  • added optional NuGet.org publishing on version tags when NUGET_API_KEY is configured

Validation

Validated locally with:

  • native wrapper tests
  • managed smoke tests against the native library
  • local .unitypackage generation
  • local .nupkg generation
  • NuGet smoke test through a local package source and PackageReference

Notes

  • the GitHub actions need to be tested; I'm not sure if they work

@mar4elkin mar4elkin self-assigned this Mar 17, 2026
@mar4elkin mar4elkin added the enhancement New feature or request label Mar 17, 2026
package-nuget:
name: Package NuGet package
needs: build-native
runs-on: ubuntu-24.04

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.

NuGet consumption is currently only tested on Linux, although package publishes native assets for win-x64, linux-x64 and osx-x64. There is a risk of missing the broken packaging path for Windows/macOS can safely reach the release unnoticed

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.

collect .nupkg once, and then check its consumption on each target OS with a separate matrix-job. Now package-nuget and smoke test live only on ubuntu-24.04, although the package is assembled from Windows/Linux/macOS native artifacts, and .NET/NuGet choose native assets by runtimes/{ rid }/native/ for a specific runtime. Therefore, a successful Linux run does not validate win-x64 and osx-x64 boot paths.

@mar4elkin mar4elkin merged commit 14bd7bb into master Mar 17, 2026
@mar4elkin mar4elkin deleted the improve/api-and-packaging branch March 17, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants