Skip to content

Commit 63c0abd

Browse files
authored
Submodule (#177)
* testing with a submodule * update pr workflow * update windows pr * teesting path * update submodules pull in CI/CD * fixing paths
1 parent 600d4e0 commit 63c0abd

8 files changed

Lines changed: 152 additions & 27 deletions

File tree

.github/workflows/main-push-nuget-publish.yml

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,73 @@ on:
88
branches: [ "main" ]
99

1010
jobs:
11-
build:
11+
native-windows:
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: recursive
17+
18+
- uses: dtolnay/rust-toolchain@stable
19+
20+
- name: Build Rust (Windows)
21+
working-directory: cas-core-lib
22+
run: cargo build --release
23+
24+
- name: Stage native
25+
run: |
26+
mkdir cas-dotnet-sdk\artifacts\native\win-x64
27+
copy cas-core-lib\target\release\cas_core_lib.dll cas-dotnet-sdk\artifacts\native\win-x64\
28+
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: native-win
32+
path: cas-dotnet-sdk/artifacts/native/win-x64
33+
34+
native-linux:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: dtolnay/rust-toolchain@stable
1239

40+
- name: Build Rust (Linux)
41+
working-directory: cas-core-lib
42+
run: cargo build --release
43+
44+
- name: Stage native
45+
run: |
46+
mkdir -p cas-dotnet-sdk/artifacts/native/linux-x64
47+
cp cas-core-lib/target/release/libcas_core_lib.so cas-dotnet-sdk/artifacts/native/linux-x64/
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: native-linux
52+
path: cas-dotnet-sdk/artifacts/native/linux-x64
53+
54+
pack-and-publish:
1355
runs-on: ubuntu-latest
56+
needs: [native-windows, native-linux]
1457

1558
steps:
16-
- uses: actions/checkout@v3
17-
- name: Setup .NET
18-
uses: actions/setup-dotnet@v3
19-
with:
20-
dotnet-version: 10.0.x
21-
- name: Restore dependencies
22-
run: dotnet restore
23-
- name: Build
24-
run: dotnet build --configuration Release --no-restore
25-
- name: Publish Nuget Package
26-
run: cd cas-dotnet-sdk/bin/Release && dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
27-
28-
59+
- uses: actions/checkout@v4
60+
61+
- uses: actions/download-artifact@v4
62+
with:
63+
name: native-win
64+
path: cas-dotnet-sdk/artifacts/native/win-x64
65+
66+
- uses: actions/download-artifact@v4
67+
with:
68+
name: native-linux
69+
path: cas-dotnet-sdk/artifacts/native/linux-x64
70+
71+
- uses: actions/setup-dotnet@v4
72+
with:
73+
dotnet-version: "10.0.x"
74+
75+
- name: Pack (includes both natives)
76+
working-directory: cas-dotnet-sdk
77+
run: dotnet pack -c Release -p:BuildNativeRust=false
78+
79+
- name: Publish to NuGet
80+
run: dotnet nuget push cas-dotnet-sdk/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

.github/workflows/pr-tests-linux.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
2729

2830
- name: Setup .NET
2931
uses: actions/setup-dotnet@v4
@@ -35,6 +37,19 @@ jobs:
3537
9.0.x
3638
10.0.x
3739
40+
- name: Build Rust native (Linux)
41+
working-directory: cas-core-lib
42+
run: cargo build --release
43+
44+
- name: Stage native lib for tests
45+
shell: bash
46+
run: |
47+
set -euo pipefail
48+
OUTDIR="cas-dotnet-sdk-tests/bin/Release/${{ matrix.tfm }}"
49+
mkdir -p "$OUTDIR"
50+
cp "cas-core-lib/target/release/libcas_core_lib.so" "$OUTDIR/"
51+
ls -la "$OUTDIR"
52+
3853
- name: Run tests (override framework)
3954
run: |
4055
echo "Running tests for framework ${{ matrix.tfm }}"

.github/workflows/pr-tests-windows.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
2729

2830
- name: Setup .NET
2931
uses: actions/setup-dotnet@v4
@@ -35,6 +37,21 @@ jobs:
3537
9.0.x
3638
10.0.x
3739
40+
- name: Setup Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Build Rust native (Windows)
44+
working-directory: cas-core-lib
45+
run: cargo build --release
46+
47+
- name: Stage native lib for tests
48+
shell: pwsh
49+
run: |
50+
$outDir = "cas-dotnet-sdk-tests\bin\Release\${{ matrix.tfm }}"
51+
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
52+
Copy-Item "cas-core-lib/target/release/cas_core_lib.dll" -Destination $outDir -Force
53+
Get-ChildItem $outDir
54+
3855
- name: Run tests (override framework)
3956
run: |
4057
echo "Running tests for framework ${{ matrix.tfm }}"

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "cas-core-lib"]
2+
path = cas-core-lib
3+
url = https://github.com/Cryptographic-API-Services/cas-core-lib

cas-core-lib

Submodule cas-core-lib added at 56c3192

cas-dotnet-sdk/cas-dotnet-sdk.csproj

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,63 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<Title>cas-dotnet-sdk</Title>
99
<PackageIcon>icon.jpeg</PackageIcon>
10-
<Version>1.8.3</Version>
10+
<Version>1.8.5</Version>
1111
<Authors>Mike Mulchrone</Authors>
1212
<Description>A Nuget package that provides a implementation of the RustCrypto suite of cryptographic algorithms.</Description>
1313
<RepositoryUrl>https://github.com/Cryptographic-API-Services/cas-dotnet-sdk</RepositoryUrl>
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
<Platforms>AnyCPU;x64</Platforms>
16+
<!-- Paths -->
17+
<RustProjectDir>../cas-core-lib</RustProjectDir>
18+
<CasSdkDir>$(MSBuildProjectDirectory)</CasSdkDir>
19+
<NativeArtifactsDir>$(MSBuildProjectDirectory)\artifacts\native</NativeArtifactsDir>
1620
</PropertyGroup>
1721

22+
<PropertyGroup>
23+
<BuildNativeRust Condition="'$(BuildNativeRust)'==''">true</BuildNativeRust>
24+
</PropertyGroup>
25+
26+
<Target Name="BuildRust" BeforeTargets="Build"
27+
Condition="'$(BuildNativeRust)'=='true'">
28+
<Exec Command="cargo build --release" WorkingDirectory="$(RustProjectDir)" />
29+
</Target>
30+
31+
<Target Name="StageRustArtifacts" AfterTargets="BuildRust"
32+
Condition="'$(BuildNativeRust)'=='true'">
33+
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
34+
<_RustOut Include="$(RustProjectDir)\target\release\cas_core_lib.dll" />
35+
<_DestDir Include="$(NativeArtifactsDir)\win-x64\" />
36+
</ItemGroup>
37+
38+
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
39+
<_RustOut Include="$(RustProjectDir)/target/release/libcas_core_lib.so" />
40+
<_DestDir Include="$(NativeArtifactsDir)\linux-x64\" />
41+
</ItemGroup>
42+
43+
<MakeDir Directories="@(_DestDir)" />
44+
<Copy SourceFiles="@(_RustOut)" DestinationFolder="@(_DestDir)" SkipUnchangedFiles="true" />
45+
</Target>
46+
47+
<!-- Pack staged native artifacts into runtimes/<rid>/native -->
48+
<ItemGroup>
49+
<None Include="$(NativeArtifactsDir)\win-x64\cas_core_lib.dll"
50+
Condition="Exists('$(NativeArtifactsDir)\win-x64\cas_core_lib.dll')">
51+
<Pack>true</Pack>
52+
<PackagePath>runtimes/win-x64/native</PackagePath>
53+
<Link>cas_core_lib.dll</Link>
54+
<!-- Optional: helps for projects that reference this library directly -->
55+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
56+
</None>
57+
58+
<None Include="$(NativeArtifactsDir)\linux-x64\libcas_core_lib.so"
59+
Condition="Exists('$(NativeArtifactsDir)\linux-x64\libcas_core_lib.so')">
60+
<Pack>true</Pack>
61+
<PackagePath>runtimes/linux-x64/native</PackagePath>
62+
<Link>libcas_core_lib.so</Link>
63+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
64+
</None>
65+
</ItemGroup>
66+
1867
<ItemGroup>
1968
<Content Include="..\icon.jpeg">
2069
<Pack>True</Pack>
@@ -37,16 +86,4 @@
3786
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.2.0" />
3887
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
3988
</ItemGroup>
40-
41-
<!-- Native assets packaged to runtimes/<rid>/native so runtime probing works correctly -->
42-
<ItemGroup>
43-
<Content Include="cas_core_lib.dll">
44-
<PackagePath>runtimes/win-x64/native</PackagePath>
45-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
46-
</Content>
47-
<Content Include="libcas_core_lib.so">
48-
<PackagePath>runtimes/linux-x64/native</PackagePath>
49-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
50-
</Content>
51-
</ItemGroup>
5289
</Project>

cas-dotnet-sdk/cas_core_lib.dll

-10.9 MB
Binary file not shown.

cas-dotnet-sdk/libcas_core_lib.so

-16.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)