Skip to content

Commit

Permalink
Fix NuGet packaging for C# bindings (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo authored Jan 15, 2025
1 parent d56533e commit d1168fc
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 84 deletions.
52 changes: 25 additions & 27 deletions .github/workflows/csharp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ckzg-library-wrapper-${{ matrix.target.location }}-${{ matrix.target.arch || 'default' }}
name: ckzg-library-wrapper-${{ matrix.target.location }}
path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native

test-ckzg-dotnet:
Expand All @@ -68,7 +68,7 @@ jobs:
strategy:
matrix:
target:
- host: ubuntu-22.04
- host: ubuntu-latest
location: linux-x64
- host: macos-latest
location: osx-arm64
Expand All @@ -84,9 +84,16 @@ jobs:
run: cd bindings/csharp && dotnet restore
- uses: actions/download-artifact@v4
with:
pattern: 'ckzg-library-wrapper-${{ matrix.target.location }}-*'
path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native
merge-multiple: true
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes
- name: Move artifacts
working-directory: bindings/csharp/Ckzg.Bindings/runtimes
run: |
mv ckzg-library-wrapper-linux-arm64/ckzg.so linux-arm64/native/ckzg.so
mv ckzg-library-wrapper-linux-x64/ckzg.so linux-x64/native/ckzg.so
mv ckzg-library-wrapper-osx-arm64/ckzg.dylib osx-arm64/native/ckzg.dylib
mv ckzg-library-wrapper-osx-x64/ckzg.dylib osx-x64/native/ckzg.dylib
mv ckzg-library-wrapper-win-x64/ckzg.dll win-x64/native/ckzg.dll
- name: Test
run: dotnet test -c release bindings/csharp/Ckzg.sln

Expand All @@ -99,34 +106,25 @@ jobs:
- uses: actions/download-artifact@v4
with:
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes/linux-x64/native
- uses: actions/download-artifact@v4
with:
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes/osx-x64/native
- uses: actions/download-artifact@v4
with:
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes/win-x64/native
- uses: actions/download-artifact@v4
with:
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes/osx-arm64/native
- uses: actions/download-artifact@v4
with:
pattern: ckzg-library-wrapper-*
path: bindings/csharp/Ckzg.Bindings/runtimes/linux-arm64/native
path: bindings/csharp/Ckzg.Bindings/runtimes
- name: Move artifacts
working-directory: bindings/csharp/Ckzg.Bindings/runtimes
run: |
mv -f ckzg-library-wrapper-linux-arm64/ckzg.so linux-arm64/native/ckzg.so
mv -f ckzg-library-wrapper-linux-x64/ckzg.so linux-x64/native/ckzg.so
mv -f ckzg-library-wrapper-osx-arm64/ckzg.dylib osx-arm64/native/ckzg.dylib
mv -f ckzg-library-wrapper-osx-x64/ckzg.dylib osx-x64/native/ckzg.dylib
mv -f ckzg-library-wrapper-win-x64/ckzg.dll win-x64/native/ckzg.dll
- name: Set up .NET
uses: actions/setup-dotnet@v4
- name: Install dependencies
run: cd bindings/csharp && dotnet restore
- name: Build
run: cd bindings/csharp && dotnet pack -c release --no-restore -o nupkgs -p:Version=${{ inputs.version || env.binding_build_number_based_version }} -p:ContinuousIntegrationBuild=true
- name: Pack
working-directory: bindings/csharp
run: dotnet pack -c release -o nupkgs -p:Version=${{ inputs.version || env.binding_build_number_based_version }} -p:ContinuousIntegrationBuild=true
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: Ckzg.Bindings-${{ inputs.version || env.binding_build_number_based_version }}
path: bindings/csharp/nupkgs/Ckzg.Bindings.*.nupkg
- name: Publish .NET package
- name: Publish package
if: github.ref == 'refs/heads/main'
run: dotnet nuget push bindings/csharp/nupkgs/*.nupkg -k ${{ secrets.CSHARP_NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
96 changes: 48 additions & 48 deletions bindings/csharp/Ckzg.Bindings/Ckzg.Bindings.csproj
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<RootNamespace>Ckzg</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<Authors>Ethereum Foundation</Authors>
<Copyright>Ethereum Foundation</Copyright>
<Description>The C# bindings for the Polynomial Commitments API library for EIP-4844 and EIP-7594</Description>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<PackageId>Ckzg.Bindings</PackageId>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>c-kzg eip-4844 eip-7594</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/ethereum/c-kzg-4844</RepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>0.2.0.1</Version>
<!-- Disable the warnings about using UInt64-->
<NoWarn>$(NoWarn);IDE0049</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Content CopyToOutputDirectory="PreserveNewest" Condition="Exists('runtimes/win-x64/native/ckzg.dll')" Include="runtimes/win-x64/native/ckzg.dll" Pack="true" PackagePath="runtimes/win-x64/native/ckzg.dll" />

<Content CopyToOutputDirectory="PreserveNewest" Condition="Exists('runtimes/linux-x64/native/ckzg.so')" Include="runtimes/linux-x64/native/ckzg.so" Pack="true" PackagePath="runtimes/linux-x64/native/ckzg.so" />
<Content CopyToOutputDirectory="PreserveNewest" Condition="Exists('runtimes/linux-arm64/native/ckzg.so')" Include="runtimes/linux-arm64/native/ckzg.so" Pack="true" PackagePath="runtimes/linux-arm64/native/ckzg.so" />

<Content CopyToOutputDirectory="PreserveNewest" Condition="Exists('runtimes/osx-x64/native/ckzg.dylib')" Include="runtimes/osx-x64/native/ckzg.dylib" Pack="true" PackagePath="runtimes/osx-x64/native/ckzg.dylib" />
<Content CopyToOutputDirectory="PreserveNewest" Condition="Exists('runtimes/osx-arm64/native/ckzg.dylib')" Include="runtimes/osx-arm64/native/ckzg.dylib" Pack="true" PackagePath="runtimes/osx-arm64/native/ckzg.dylib" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<RootNamespace>Ckzg</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<Authors>Ethereum Foundation</Authors>
<Copyright>Ethereum Foundation</Copyright>
<Description>The C# bindings for the Polynomial Commitments API library for EIP-4844 and EIP-7594</Description>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<PackageId>Ckzg.Bindings</PackageId>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>c-kzg eip-4844 eip-7594</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/ethereum/c-kzg-4844</RepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>0.2.0.1</Version>
<!-- Disable the warnings about using UInt64-->
<NoWarn>$(NoWarn);IDE0049</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Content CopyToOutputDirectory="PreserveNewest" Include="runtimes/win-x64/native/ckzg.dll" Pack="true" PackagePath="runtimes/win-x64/native/ckzg.dll" />

<Content CopyToOutputDirectory="PreserveNewest" Include="runtimes/linux-x64/native/ckzg.so" Pack="true" PackagePath="runtimes/linux-x64/native/ckzg.so" />
<Content CopyToOutputDirectory="PreserveNewest" Include="runtimes/linux-arm64/native/ckzg.so" Pack="true" PackagePath="runtimes/linux-arm64/native/ckzg.so" />

<Content CopyToOutputDirectory="PreserveNewest" Include="runtimes/osx-x64/native/ckzg.dylib" Pack="true" PackagePath="runtimes/osx-x64/native/ckzg.dylib" />
<Content CopyToOutputDirectory="PreserveNewest" Include="runtimes/osx-arm64/native/ckzg.dylib" Pack="true" PackagePath="runtimes/osx-arm64/native/ckzg.dylib" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
18 changes: 9 additions & 9 deletions bindings/csharp/Ckzg.Test/Ckzg.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand All @@ -11,15 +11,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="YamlDotNet" Version="13.2.0" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d1168fc

Please sign in to comment.