mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 00:02:18 +00:00
C# CI
This commit is contained in:
@@ -137,6 +137,62 @@ jobs:
|
||||
run: ./gradlew publishMavenKotlinPublicationToCentralPortal publishMavenJavaPublicationToCentralPortal
|
||||
|
||||
|
||||
release-csharp:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ build ]
|
||||
if: "startsWith(github.event.head_commit.message, 'chore(release): publish uniffi')"
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ env.UNIFFI_DIRECTORY }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Setup Rust Toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: build/generated/resources
|
||||
|
||||
- name: Move artifacts
|
||||
run: mv ../../build ./
|
||||
|
||||
- name: Install uniffi-bindgen-cs
|
||||
run: cargo install uniffi-bindgen-cs --git https://github.com/aspect-build/uniffi-bindgen-cs --tag v0.10.0+v0.29.4
|
||||
|
||||
- name: Generate C# bindings
|
||||
run: |
|
||||
uniffi-bindgen-cs \
|
||||
--library build/generated/resources/darwin-x86-64/libzen_uniffi.dylib \
|
||||
--out-dir build/generated/csharp
|
||||
|
||||
- name: Fix async callback interfaces
|
||||
run: bash scripts/fix-csharp-bindings.sh build/generated/csharp/zen_uniffi.cs
|
||||
|
||||
- name: Extract version from Cargo.toml
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "Detected version: $VERSION"
|
||||
|
||||
- name: Pack NuGet package
|
||||
run: dotnet pack nuget/GoRules.ZenEngine.csproj -c Release -p:Version=$VERSION
|
||||
|
||||
- name: Push to NuGet.org
|
||||
run: |
|
||||
dotnet nuget push nuget/bin/Release/*.nupkg \
|
||||
--api-key ${{ secrets.NUGET_API_KEY }} \
|
||||
--source https://api.nuget.org/v3/index.json \
|
||||
--skip-duplicate
|
||||
|
||||
build-ios:
|
||||
if: "!contains(github.event.head_commit.message, 'skip ci')"
|
||||
env:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
.idea
|
||||
.gradle
|
||||
build/
|
||||
build-android/
|
||||
jniLibs/
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace GoRules.ZenEngine;
|
||||
|
||||
using System.Text;
|
||||
|
||||
public class JsonBuffer
|
||||
{
|
||||
public byte[] Value { get; }
|
||||
|
||||
public JsonBuffer(byte[] value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public JsonBuffer(string json)
|
||||
{
|
||||
Value = Encoding.UTF8.GetBytes(json);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Encoding.UTF8.GetString(Value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<PackageId>GoRules.ZenEngine</PackageId>
|
||||
<Authors>GoRules</Authors>
|
||||
<Description>ZEN Engine - Business Rules Engine for .NET. Execute JSON Decision Models (JDM) with native performance via Rust FFI bindings.</Description>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/gorules/zen</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/gorules/zen</RepositoryUrl>
|
||||
<PackageTags>rules-engine;business-rules;decision-engine;jdm;gorules</PackageTags>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- C# source files (generated + custom) -->
|
||||
<ItemGroup>
|
||||
<Compile Include="../build/generated/csharp/zen_uniffi.cs" Link="zen_uniffi.cs" />
|
||||
<Compile Include="../lib/csharp/GoRules/ZenEngine/JsonBuffer.cs" Link="JsonBuffer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Native libraries for each platform (NuGet RID layout) -->
|
||||
<ItemGroup>
|
||||
<!-- macOS x64 -->
|
||||
<None Include="../build/generated/resources/darwin-x86-64/libzen_uniffi.dylib"
|
||||
Pack="true"
|
||||
PackagePath="runtimes/osx-x64/native/"
|
||||
Visible="false" />
|
||||
|
||||
<!-- macOS arm64 -->
|
||||
<None Include="../build/generated/resources/darwin-aarch64/libzen_uniffi.dylib"
|
||||
Pack="true"
|
||||
PackagePath="runtimes/osx-arm64/native/"
|
||||
Visible="false" />
|
||||
|
||||
<!-- Linux x64 -->
|
||||
<None Include="../build/generated/resources/linux-x86-64/libzen_uniffi.so"
|
||||
Pack="true"
|
||||
PackagePath="runtimes/linux-x64/native/"
|
||||
Visible="false" />
|
||||
|
||||
<!-- Linux arm64 -->
|
||||
<None Include="../build/generated/resources/linux-aarch64/libzen_uniffi.so"
|
||||
Pack="true"
|
||||
PackagePath="runtimes/linux-arm64/native/"
|
||||
Visible="false" />
|
||||
|
||||
<!-- Windows x64 -->
|
||||
<None Include="../build/generated/resources/win32-x86-64/zen_uniffi.dll"
|
||||
Pack="true"
|
||||
PackagePath="runtimes/win-x64/native/"
|
||||
Visible="false" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# fix-csharp-bindings.sh
|
||||
#
|
||||
# Fixes the async callback interface bug in C# bindings generated by uniffi-bindgen-cs.
|
||||
#
|
||||
# The generator produces sync interface methods (returning T directly) but the
|
||||
# calling code uses await + .WaitAsync(), causing compilation errors. This script
|
||||
# patches the interface method signatures to return Task<T> instead.
|
||||
#
|
||||
# Usage: ./fix-csharp-bindings.sh <path-to-zen_uniffi.cs>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 <path-to-zen_uniffi.cs>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILE="$1"
|
||||
|
||||
if [ ! -f "$FILE" ]; then
|
||||
echo "Error: File not found: $FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Fixing async callback interfaces in $FILE..."
|
||||
|
||||
# Fix ZenCustomNodeCallback.Handle: sync → async (Task<>)
|
||||
sed -i.bak 's/ZenEngineHandlerResponse Handle(ZenEngineHandlerRequest @key)/Task<ZenEngineHandlerResponse> Handle(ZenEngineHandlerRequest @key)/' "$FILE"
|
||||
|
||||
# Fix ZenDecisionLoaderCallback.Load: sync → async (Task<>)
|
||||
sed -i.bak 's/JsonBuffer? Load(string @key)/Task<JsonBuffer?> Load(string @key)/' "$FILE"
|
||||
|
||||
# Clean up backup file
|
||||
rm -f "${FILE}.bak"
|
||||
|
||||
echo "Done. Fixed async interfaces in $FILE"
|
||||
Reference in New Issue
Block a user