name: C# on: workflow_dispatch: inputs: version: description: "Binding version override" push: branches: - main pull_request: branches: - main env: binding_build_number_based_version: 0.3.1.${{ github.run_number }} jobs: build-ckzg: name: Build ckzg runs-on: ${{ matrix.target.host }} strategy: matrix: target: - arch: x86_64-linux-gnu location: linux-x64 host: ubuntu-22.04 ext: .so reqs: - arch: aarch64-linux-gnu location: linux-arm64 host: ubuntu-22.04 ext: .so reqs: sudo apt update && sudo apt install -y clang binutils-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross crossbuild-essential-arm64 - arch: arm64-apple-macos11 location: osx-arm64 host: macos-latest ext: .dylib reqs: - arch: x86_64-darwin location: osx-x64 host: macos-latest ext: .dylib reqs: - arch: location: win-x64 host: windows-latest ext: .dll reqs: steps: - uses: ilammy/msvc-dev-cmd@v1 - uses: actions/checkout@v3 with: submodules: recursive - name: Install requirements if: ${{ matrix.target.reqs }} run: ${{ matrix.target.reqs }} - name: Build native library for ${{ matrix.target.location }} using native capabilities run: make ckzg -C bindings/csharp CC=clang EXTENSION=${{matrix.target.ext}} LOCATION=${{matrix.target.location}} ARCH=${{matrix.target.arch}} - name: Upload artifacts uses: actions/upload-artifact@v3 with: name: ckzg-library-wrapper-${{ matrix.target.location }} path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native test-ckzg-dotnet: name: Test .NET wrapper runs-on: ${{ matrix.target.host }} needs: build-ckzg strategy: matrix: target: - host: ubuntu-22.04 location: linux-x64 - host: macos-latest location: osx-x64 - host: windows-latest location: win-x64 steps: - uses: actions/checkout@v3 with: submodules: recursive - name: Set up .NET uses: actions/setup-dotnet@v3 - name: Install dependencies run: cd bindings/csharp && dotnet restore - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-${{ matrix.target.location }} path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native - name: Test run: dotnet test -c release bindings/csharp/Ckzg.sln build-ckzg-dotnet: name: Build .NET wrapper runs-on: ubuntu-latest needs: test-ckzg-dotnet steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-linux-x64 path: bindings/csharp/Ckzg.Bindings/runtimes/linux-x64/native - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-osx-x64 path: bindings/csharp/Ckzg.Bindings/runtimes/osx-x64/native - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-win-x64 path: bindings/csharp/Ckzg.Bindings/runtimes/win-x64/native - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-osx-arm64 path: bindings/csharp/Ckzg.Bindings/runtimes/osx-arm64/native - uses: actions/download-artifact@v3 with: name: ckzg-library-wrapper-linux-arm64 path: bindings/csharp/Ckzg.Bindings/runtimes/linux-arm64/native - name: Set up .NET uses: actions/setup-dotnet@v3 - 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: Upload package uses: actions/upload-artifact@v3 with: name: Ckzg.Bindings-${{ inputs.version || env.binding_build_number_based_version }} path: bindings/csharp/nupkgs/Ckzg.Bindings.*.nupkg - name: Publish .NET 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