Skip to content

Commit 9e24978

Browse files
committed
Feat#: add CI/CD build
Add CI/CD for the solution in two stages: - Build the native library on a windows-latest runner - Assemble the final NuGet package from the native library The location of the native library during the build process is not really optimal, but works well enough. Triggers on both pushes and release published events; NuGet package is only published on release published.
1 parent 7c8d6e7 commit 9e24978

2 files changed

Lines changed: 82 additions & 7 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: 'Build and release NuGet package'
2+
3+
on:
4+
push:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
build-native:
11+
name: 'Build native library'
12+
runs-on: windows-latest
13+
14+
outputs:
15+
native-id: ${{ steps.artup.outputs.artifact-id }}
16+
17+
steps:
18+
- name: 'Checkout repo'
19+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
20+
21+
- name: 'Install msbuild'
22+
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3
23+
24+
- name: 'Install NuGet'
25+
uses: NuGet/setup-nuget@fd55a6f3b34392fa83fde1454582407d8c714123 # v4.0
26+
27+
- name: 'Restore NuGet packages'
28+
run: nuget restore Native\ApplicationLoopback.vcxproj -PackagesDirectory Native\packages
29+
30+
- name: 'Build project'
31+
run: msbuild /t:build /p:Platform=x64 /p:Configuration=Release Native\ApplicationLoopback.vcxproj
32+
33+
- name: 'Upload artifact'
34+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
35+
id: artup
36+
with:
37+
name: 'native-lib'
38+
path: Native\x64\Release\ApplicationLoopback.dll
39+
40+
build-publish:
41+
name: 'Build and push NuGet'
42+
runs-on: ubuntu-latest
43+
44+
needs:
45+
- build-native
46+
47+
env:
48+
IS_RELEASE: ${{ github.event_name == 'release' && github.event.action == 'published' }}
49+
50+
steps:
51+
- name: 'Checkout repo'
52+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
53+
54+
- name: 'Download native lib'
55+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
56+
with:
57+
artifact-ids: ${{ needs.build-native.outputs.native-id }}
58+
59+
- name: 'Build NuGet'
60+
uses: Yellow-Dog-Man/composite-actions-templates/.github/actions/dotnet-build@606ac289d701be7b7d90e5ff8647dedf57d6d755 # main
61+
with:
62+
dotnet-build-args: ${{ env.IS_RELEASE == 'true' && format('-p:Version={0} -o nupkgs', github.ref_name) || '-o nupkgs' }}
63+
dotnet-project-path: 'ApplicationLoopback.NET/ApplicationLoopback.NET/ApplicationLoopback.NET.csproj'
64+
dotnet-build-type: 'pack'
65+
66+
- name: 'Upload artifact'
67+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
68+
with:
69+
name: 'nuget-packages'
70+
path: nupkgs/*.nupkg
71+
72+
- name: 'Push nuget'
73+
if: ${{ env.IS_RELEASE == 'true' }}
74+
uses: Yellow-Dog-Man/composite-actions-templates/.github/actions/dotnet-build-push-nuget@606ac289d701be7b7d90e5ff8647dedf57d6d755 # main
75+
with:
76+
dotnet-nuget-auth-token: ${{ secrets.NUGET_TOKEN }}

ApplicationLoopback.NET/ApplicationLoopback.NET/ApplicationLoopback.NET.csproj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
6+
7+
<PackageId>YellowDogMan.ApplicationLoobpack.NET</PackageId>
68
</PropertyGroup>
79

810
<ItemGroup>
9-
<None Remove="ApplicationLoopback.dll" />
10-
</ItemGroup>
11-
12-
<ItemGroup>
13-
<Content Include="ApplicationLoopback.dll">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</Content>
11+
<None Include="../../ApplicationLoopback.dll"
12+
Pack="true"
13+
PackagePath="runtimes/win-x64/native/"
14+
CopyToOutputDirectory="PreserveNewest" />
1615
</ItemGroup>
1716

1817
<ItemGroup>

0 commit comments

Comments
 (0)