Skip to content

Commit 168b2a9

Browse files
authored
build: Support manually generating C# bindings via Github action and add a README (microsoft#423)
1 parent 8ee1cf3 commit 168b2a9

5 files changed

Lines changed: 42 additions & 1 deletion

File tree

.github/workflows/test-csharp.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: bindings/csharp
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [ "main" ]
67
pull_request:
@@ -9,6 +10,9 @@ on:
910
# Run at 8:00 AM every day
1011
- cron: "0 8 * * *"
1112

13+
env:
14+
VersionSuffix: ${{ github.event_name == 'workflow_dispatch' && 'manualtrigger' || null }}
15+
1216
jobs:
1317
build-ffi:
1418
name: 'Build Regorus FFI: (${{ matrix.runtime.target }})'

bindings/csharp/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Regorus CSharp
2+
3+
**Regorus** is
4+
5+
- *Rego*-*Rus(t)* - A fast, light-weight [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/)
6+
interpreter written in Rust.
7+
- *Rigorous* - A rigorous enforcer of well-defined Rego semantics.
8+
9+
See main [Regorus page](https://github.com/microsoft/regorus) for more details about the project.
10+
11+
# Building
12+
13+
## Github Actions
14+
15+
The simplest way to build a Nuget for Regorus' C# bindings is to use Github Actions. The action to do so is named `bindings/csharp` and is defined in `.github/workflows/test-csharp.yml`.
16+
17+
There are two ways to trigger a Nuget build.
18+
1. Runs are triggered automatically whenever a push or pull request is made to the `main` branch.
19+
2. A run can be triggered manually by navigating to the action in the Github UI and clicking `Run workflow`. This option allows you to generate a Nuget for any branch, which is useful when testing the integration of in-progress changes to Regorus with other projects. Nuget files that are generated via this flow will have a `manualtrigger` suffix appended to their version number, making it easy to distinguish them from Nugets generated using the `main` branch.
20+
![Image displaying the run workflow button](docs/images/readme/manuallytriggeringrun.png)
21+
22+
Once the workflow run completes, the generated Nuget can be downloaded by following these steps:
23+
1. Open the run.
24+
2. Click on `Build Regorus nuget` on the left.
25+
3. Expand the `Upload Regorus nuget` step.
26+
4. Click the `Artifact download URL` link at the bottom.
27+
5. Save and extract the downloaded zip file to find the `.nupkg` file.
28+
![Image displaying the download URL link](docs/images/readme/downloadnuget.png)
29+
30+
## Local
31+
32+
TODO

bindings/csharp/Regorus.Tests/Regorus.Tests.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
88
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
99
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<!-- If the environment variable is set (such as in a Github Action run), append the suffix to the version number -->
13+
<RegorusPackageVersionSuffix Condition="'$(VersionSuffix)' != ''">-$(VersionSuffix)</RegorusPackageVersionSuffix>
14+
</PropertyGroup>
1015

1116
<ItemGroup>
1217
<None Include="../../../tests/**/*.*" Link="tests/%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
@@ -17,6 +22,6 @@
1722
</ItemGroup>
1823

1924
<ItemGroup>
20-
<PackageReference Include="Regorus" Version="0.5.0"/>
25+
<PackageReference Include="Regorus" Version="0.6.0$(RegorusPackageVersionSuffix)"/>
2126
</ItemGroup>
2227
</Project>
95.5 KB
Loading
72.9 KB
Loading

0 commit comments

Comments
 (0)