|
1 |
| -name: Publish C# bindings |
| 1 | +name: C# Bindings |
2 | 2 |
|
3 | 3 | on:
|
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
4 | 8 | workflow_dispatch:
|
5 | 9 | inputs:
|
6 | 10 | ref:
|
7 |
| - description: The reference (branch/tag/commit) to checkout |
8 |
| - required: true |
| 11 | + description: 'The reference (branch/tag/commit) to checkout' |
| 12 | + required: false |
| 13 | + release-type: |
| 14 | + type: choice |
| 15 | + required: false |
| 16 | + default: 'none' |
| 17 | + description: 'Indicates whether we want to make a release and if which one' |
| 18 | + options: |
| 19 | + - release |
| 20 | + - none |
9 | 21 |
|
10 |
| -concurrency: |
11 |
| - group: ${{ github.workflow }}-${{ github.ref }} |
12 |
| - cancel-in-progress: true |
| 22 | +env: |
| 23 | + CARGO_TERM_COLOR: always |
13 | 24 |
|
14 | 25 | jobs:
|
15 |
| - publish: |
16 |
| - name: Publish C# bindings |
17 |
| - runs-on: macos-latest |
| 26 | + build: |
| 27 | + name: Build - ${{ matrix.target }} |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - target: x86_64-unknown-linux-gnu |
| 33 | + os: ubuntu-latest |
| 34 | + - target: aarch64-unknown-linux-gnu |
| 35 | + os: ubuntu-latest |
| 36 | + - target: aarch64-apple-darwin |
| 37 | + os: ubuntu-latest |
| 38 | + - target: x86_64-apple-darwin |
| 39 | + os: ubuntu-latest |
| 40 | + - target: x86_64-pc-windows-gnu |
| 41 | + os: windows-latest |
18 | 42 | steps:
|
19 |
| - - name: Checkout sources |
20 |
| - uses: actions/checkout@v4 |
| 43 | + - uses: actions/checkout@v4 |
21 | 44 | with:
|
22 |
| - ref: master |
23 |
| - |
| 45 | + ref: ${{ inputs.ref || github.ref }} |
24 | 46 | - name: Install Rust
|
25 |
| - uses: dtolnay/rust-toolchain@master |
| 47 | + uses: actions-rs/toolchain@v1 |
26 | 48 | with:
|
27 | 49 | toolchain: stable
|
28 |
| - |
29 |
| - - name: Install all of the relevant targets |
| 50 | + target: ${{ matrix.target }} |
| 51 | + override: true |
| 52 | + - name: Install cargo-binstall |
| 53 | + uses: taiki-e/install-action@cargo-binstall |
| 54 | + - name: Install Zig |
| 55 | + uses: goto-bus-stop/setup-zig@v2 |
| 56 | + with: |
| 57 | + version: 0.10.1 |
| 58 | + - name: Install cargo-zigbuild |
| 59 | + run: cargo binstall --no-confirm cargo-zigbuild |
| 60 | + - name: Run compile script |
30 | 61 | run: |
|
31 |
| - chmod +x .github/scripts/install_all_targets.sh |
32 |
| - .github/scripts/install_all_targets.sh |
| 62 | + chmod +x .github/scripts/compile_all_targets_c_sharp_new.sh |
| 63 | + .github/scripts/compile_all_targets_c_sharp_new.sh ${{ matrix.target }} |
| 64 | + shell: bash |
| 65 | + - name: Upload dynamic libs |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: ${{ matrix.target }} |
| 69 | + path: bindings/csharp/csharp_code/EthKZG.bindings/runtimes/${{ matrix.target }} |
33 | 70 |
|
34 |
| - - name: Install .NET SDK |
35 |
| - uses: actions/setup-dotnet@v3 |
| 71 | + test: |
| 72 | + name: Test - ${{ matrix.target }} |
| 73 | + needs: build |
| 74 | + strategy: |
| 75 | + matrix: |
| 76 | + include: |
| 77 | + - target: x86_64-unknown-linux-gnu |
| 78 | + os: ubuntu-latest |
| 79 | + - target: aarch64-unknown-linux-gnu |
| 80 | + os: linux-arm64 |
| 81 | + - target: x86_64-apple-darwin |
| 82 | + os: macos-13 |
| 83 | + - target: aarch64-apple-darwin |
| 84 | + os: macos-14 |
| 85 | + - target: x86_64-pc-windows-gnu |
| 86 | + os: windows-latest |
| 87 | + runs-on: ${{ matrix.os }} |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
36 | 90 | with:
|
37 |
| - dotnet-version: '8.x' |
38 |
| - |
39 |
| - - name: Setup Python |
40 |
| - uses: actions/setup-python@v4 |
| 91 | + ref: ${{ inputs.ref || github.ref }} |
| 92 | + - name: Download artifacts |
| 93 | + uses: actions/download-artifact@v4 |
41 | 94 | with:
|
42 |
| - python-version: '3.x' |
| 95 | + name: ${{ matrix.target }} |
| 96 | + path: bindings/csharp/csharp_code/EthKZG.bindings/runtimes/${{ matrix.target }} |
| 97 | + - name: Set up .NET |
| 98 | + uses: actions/setup-dotnet@v3 |
| 99 | + with: |
| 100 | + dotnet-version: '8.0.x' |
43 | 101 |
|
44 |
| - - name: Install Homebrew |
45 |
| - run: | |
46 |
| - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 102 | + - name: Restore .NET dependencies |
| 103 | + run: dotnet restore |
| 104 | + working-directory: bindings/csharp/csharp_code |
47 | 105 |
|
48 |
| - - name: Install mingw-w64 for Windows cross-compilation |
49 |
| - run: | |
50 |
| - brew install mingw-w64 |
51 |
| - |
52 |
| - - name: Install linker for x86_64-unknown-linux-gnu |
53 |
| - run: | |
54 |
| - brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu |
55 |
| - |
56 |
| - - name: Install linker for aarch64-unknown-linux-gnu |
57 |
| - run: | |
58 |
| - brew tap messense/homebrew-macos-cross-toolchains |
59 |
| - brew install aarch64-unknown-linux-gnu |
| 106 | + - name: Build .NET project |
| 107 | + run: dotnet build --no-restore |
| 108 | + working-directory: bindings/csharp/csharp_code |
60 | 109 |
|
61 |
| - - name: Rename cross.toml file so cargo uses the correct linkers |
62 |
| - run: | |
63 |
| - mv .cargo/config.cross.toml .cargo/config.toml |
| 110 | + - name: Run .NET tests |
| 111 | + run: dotnet test --no-build --verbosity normal |
| 112 | + working-directory: bindings/csharp/csharp_code |
64 | 113 |
|
65 |
| - - name: Strip leading v from tagged version |
66 |
| - # Strip the leading v from the tag name. It should be of the form v0.1.2 |
67 |
| - # dotnet requires it to be of the form 0.1.2 |
68 |
| - run: echo "VERSION=$(echo "${{ inputs.ref }}" | sed 's/^v//')" >> $GITHUB_ENV |
| 114 | + publish: |
| 115 | + name: Publish |
| 116 | + if: ${{ inputs.release-type != 'none' && github.event_name == 'workflow_dispatch' }} |
| 117 | + needs: [build, test] |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v4 |
| 121 | + with: |
| 122 | + ref: ${{ inputs.ref || github.ref }} |
69 | 123 |
|
70 |
| - - name: Run compile script |
71 |
| - run: | |
72 |
| - chmod +x .github/scripts/compile_all_targets_c_sharp.sh |
73 |
| - .github/scripts/compile_all_targets_c_sharp.sh |
| 124 | + - name: Download all artifacts |
| 125 | + uses: actions/download-artifact@v4 |
| 126 | + with: |
| 127 | + path: bindings/csharp/csharp_code/EthKZG.bindings/runtimes |
74 | 128 |
|
75 | 129 | - name: Restore NuGet packages
|
76 | 130 | working-directory: bindings/csharp/csharp_code/EthKZG.bindings
|
77 | 131 | run: dotnet restore
|
78 | 132 |
|
79 | 133 | - name: Package with dotnet pack
|
80 | 134 | working-directory: bindings/csharp/csharp_code/EthKZG.bindings
|
81 |
| - run: dotnet pack -c release --no-restore -o nupkgs -p:Version=${{ env.VERSION }} -p:ContinuousIntegrationBuild=true |
| 135 | + run: dotnet pack -c release --no-restore -o nupkgs -p:ContinuousIntegrationBuild=true |
82 | 136 |
|
83 | 137 | - name: Publish to Nuget
|
84 | 138 | working-directory: bindings/csharp/csharp_code/EthKZG.bindings
|
|
0 commit comments