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
56 changes: 56 additions & 0 deletions .github/tests/dotnet/test_installation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0

using System;
using Agntcy.Slim;

/// <summary>
/// Installation test for SLIM .NET bindings.
///
/// This test verifies that the slim_bindings package can be imported
/// and initialized successfully.
/// </summary>
class Program
{
static void Main(string[] args)
{
Console.WriteLine("SLIM .NET Bindings Installation Test");
Console.WriteLine("==================================================");

try
{
// Initialize SLIM (required before any operations)
Slim.Initialize();
Console.WriteLine("SLIM initialized successfully");

// Verify initialization state
if (!Slim.IsInitialized)
{
Console.WriteLine("SLIM initialization check failed");
Environment.Exit(1);
}
Console.WriteLine("SLIM is initialized");

// Get and display version information
string version = Slim.Version;
Console.WriteLine($"SLIM version: {version}");

// Get and display build information
string buildInfo = Slim.BuildInfo;
Console.WriteLine($"SLIM build info: {buildInfo}");

// Clean shutdown
Slim.Shutdown();
Console.WriteLine("SLIM shutdown successfully");

Console.WriteLine("Installation test passed!");
Environment.Exit(0);
}
catch (Exception ex)
{
Console.WriteLine($"Test failed with exception: {ex.Message}");
Console.WriteLine(ex.StackTrace);
Environment.Exit(1);
}
}
}
83 changes: 49 additions & 34 deletions .github/workflows/release-bindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ on:
env:
LIBRARY_NAME: slim_bindings
GO_BINDINGS_REPO: agntcy/slim-bindings-go
NUGET_PACKAGE_NAME: Agntcy.Slim
UNIFFI_BINDGEN_GO_VERSION: v0.4.0+v0.28.3
UNIFFI_BINDGEN_CS_VERSION: v0.9.0+v0.28.3
DOTNET_VERSION: "8.0.x"

jobs:
# ==========================================================================
Expand All @@ -21,6 +24,8 @@ jobs:
build-and-test-bindings:
name: "Build and Test Bindings"
uses: ./.github/workflows/reusable-bindings-build-and-test.yaml
with:
tag-name: ${{ github.ref_name }}

# ==========================================================================
# Job 2: Create GitHub release with library artifacts (for test tags)
Expand Down Expand Up @@ -90,41 +95,51 @@ jobs:
files: ./release-artifacts/*.zip
draft: false

# # ==========================================================================
# # Job 3: Generate and publish Go bindings
# # ==========================================================================
# release-go-bindings:
# name: "Release Go Bindings"
# needs: build-and-test-bindings
# uses: ./.github/workflows/reusable-go-bindings-release.yaml
# secrets:
# gh-token: ${{ secrets.AGNTCY_BUILD_BOT_GH_TOKEN }}

# # ==========================================================================
# # Job 4: Release Python bindings to PyPI
# # ==========================================================================
# release-python-bindings:
# name: Upload release to PyPI
# runs-on: ubuntu-latest
# needs:
# - build-and-test-bindings
# permissions:
# # IMPORTANT: this permission is mandatory for Trusted Publishing
# id-token: write
# contents: read
# steps:
# - name: Download artifacts
# uses: actions/download-artifact@v4
# with:
# merge-multiple: true
# path: dist
# pattern: wheels-*

# - name: Show files
# run: ls -l dist

# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
# packages-dir: dist

# ==========================================================================
# Job 3: Generate and publish Go bindings
# Job 5: Release .NET bindings to NuGet
# ==========================================================================
release-go-bindings:
name: "Release Go Bindings"
release-dotnet-bindings:
name: "Release .NET Bindings"
needs: build-and-test-bindings
uses: ./.github/workflows/reusable-go-bindings-release.yaml
uses: ./.github/workflows/reusable-dotnet-bindings-release.yaml
secrets:
gh-token: ${{ secrets.AGNTCY_BUILD_BOT_GH_TOKEN }}

# ==========================================================================
# Job 4: Release Python bindings to PyPI
# ==========================================================================
release-python-bindings:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs:
- build-and-test-bindings
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
pattern: wheels-*

- name: Show files
run: ls -l dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist
nuget-api-token: ${{ secrets.NUGET_API_TOKEN }}
72 changes: 72 additions & 0 deletions .github/workflows/reusable-bindings-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
required: false
type: string
default: ubuntu-latest
tag-name:
description: Git tag name for version extraction (e.g., slim-bindings-1.2.3)
required: false
type: string
default: ""
rust-workspace:
description: Rust workspace directory for caching
required: false
Expand Down Expand Up @@ -149,6 +154,7 @@ jobs:
with:
workspace: ./data-plane
- name: Build library
working-directory: ./data-plane/bindings/rust
run: |
task bindings:build:all TARGET=${{ matrix.platform.target }} PROFILE=release
- name: Strip and rename artifacts
Expand Down Expand Up @@ -408,3 +414,69 @@ jobs:
run: |
echo "✅ Python wheel verification completed successfully on ${{ matrix.platform.target }}"
echo "The wheel can be safely published."

dotnet-bindings-build-and-test:
name: Build .NET Bindings
runs-on: ${{ inputs.runner }}
needs:
- generate-matrix
- build-libraries

defaults:
run:
shell: bash
working-directory: ./data-plane/bindings/dotnet

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
workspace: ${{ inputs.rust-workspace }}

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"

- name: Setup Task
uses: ./.github/actions/setup-task
with:
version: latest
github-token: ${{ secrets.GITHUB_TOKEN }}

# Download all library artifacts from the build-libraries job
- name: Download library artifacts
uses: actions/download-artifact@v4
with:
pattern: bindings-*
path: ./data-plane/bindings/dotnet/artifacts/

- name: List downloaded artifacts
run: |
echo "📦 Downloaded artifacts:"
find ./artifacts -type f -name "*.so" -o -name "*.dll" -o -name "*.dylib" -o -name "*.a" | sort

# Run complete CI pipeline using task command
# This generates bindings, copies runtimes, builds, tests, and packs
- name: Run CI pipeline
run: |
TAG_NAME_PARAM=""
if [[ -n "${{ inputs.tag-name }}" ]]; then
TAG_NAME_PARAM="TAG_NAME=${{ inputs.tag-name }}"
fi

task ci \
ARTIFACTS_DIR=./artifacts \
OUTPUT_DIR=./nupkg \
BINDGEN_TARGET=x86_64-unknown-linux-gnu \
$TAG_NAME_PARAM

- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: dotnet-bindings-nuget
path: ./data-plane/bindings/dotnet/nupkg/*.nupkg
if-no-files-found: error
101 changes: 101 additions & 0 deletions .github/workflows/reusable-dotnet-bindings-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0

---
name: Reusable .NET Bindings Release

on:
workflow_call:
inputs:
library-name:
description: Name of the library
required: false
type: string
default: slim_bindings
dotnet-version:
description: .NET SDK version
required: false
type: string
default: "8.0.x"
dotnet-bindings-working-directory:
description: Working directory for .NET bindings
required: false
type: string
default: ./data-plane/bindings/dotnet
nuget-package-name:
description: NuGet package name
required: false
type: string
default: Agntcy.Slim
secrets:
nuget-api-token:
description: NuGet API token for publishing
required: true

env:
LIBRARY_NAME: ${{ inputs.library-name }}
NUGET_PACKAGE_NAME: ${{ inputs.nuget-package-name }}

jobs:
release-dotnet-bindings:
name: Release .NET Bindings
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ inputs.dotnet-bindings-working-directory }}
steps:
- name: Checkout source repo
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet-version }}

# Download NuGet package artifact
- name: Download NuGet Package Artifact
uses: actions/download-artifact@v4
with:
name: dotnet-bindings-nuget
path: ${{ inputs.dotnet-bindings-working-directory }}/nupkg

- name: List downloaded artifacts
run: |
echo "Downloaded NuGet package:"
ls -lah ./nupkg/

- name: Extract version from package name
id: extract-version
run: |
# Extract version from the .nupkg filename
PACKAGE=$(ls ./nupkg/*.nupkg | head -1)
FILENAME=$(basename "$PACKAGE")
# Extract version from Agntcy.Slim.X.Y.Z.nupkg
VERSION=$(echo "$FILENAME" | sed -n 's/Agntcy\.Slim\.\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*.*\)\.nupkg/\1/p')
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Determine if pre-release
id: prerelease
run: |
VERSION="${{ steps.extract-version.outputs.version }}"
if [[ "$VERSION" =~ (alpha|beta|rc) ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "This is a pre-release version"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "This is a stable release"
fi

- name: Publish to NuGet.org
run: |
PACKAGE=$(ls ./nupkg/*.nupkg | head -1)
echo "Publishing package: $PACKAGE"

dotnet nuget push "$PACKAGE" \
--api-key "${{ secrets.nuget-api-token }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate

echo "Successfully published to NuGet.org"
Loading
Loading