Skip to content

Commit

Permalink
Adding build for NuGet package (#79)
Browse files Browse the repository at this point in the history
* Adding build for NuGet package

* Add missing files

* Change NuGet output path so it hopefully uploads in CI

* Still trying to get nupkg to upload to artifacts

* Trying again to get NuGet to upload in CI

* Make build logs artifact name unique per build phase

* Removing project URL being explicitly specified to see if the DotNet.ReproducibleBuilds package will actually fill in the repo, branch and commit in CI
  • Loading branch information
Austin-Lamb authored Jul 16, 2024
1 parent fe023bc commit ed29b0e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
with:
ref: ${{ github.ref }}
build_artifact: Build-x64
build_nuget: true
configurations: '["Debug", "Release"]'

# Run the ntosebpfext unit tests in GitHub.
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
- name: Build
if: steps.skip_check.outputs.should_skip != 'true'
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} /bl:${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\build_logs\build.binlog ${{env.BUILD_OPTIONS}} ${{env.SOLUTION_FILE_PATH}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} /bl:${{env.BUILD_PLATFORM}}_${{env.BUILD_CONFIGURATION}}\build_logs\build.binlog ${{env.BUILD_OPTIONS}} ${{env.SOLUTION_FILE_PATH}}

- name: Zip Build Output
if: always() && (steps.skip_check.outputs.should_skip != 'true')
Expand All @@ -184,6 +184,28 @@ jobs:
path: ${{github.workspace}}/build-${{ matrix.configurations }}.zip
retention-days: 5

- name: Build the NuGet package
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} /bl:${{env.BUILD_PLATFORM}}_${{env.BUILD_CONFIGURATION}}\build_logs\nuget_build.binlog ${{env.BUILD_OPTIONS}} tools\nuget\nuget.proj /t:Restore,Build,Pack

- name: Upload the NuGet package
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: ebpf-for-windows-extensions - NuGet package (${{inputs.build_artifact}}_${{env.BUILD_CONFIGURATION}})
path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\*.nupkg
if-no-files-found: error
retention-days: 5

- name: Upload Build Logs
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: ${{inputs.build_artifact}} Build Logs-${{matrix.configurations}}
path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}_${{env.BUILD_CONFIGURATION}}\build_logs\*.binlog
retention-days: 5

- name: Check for crash dumps
# Check for crash dumps even if the workflow failed.
if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true')
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
<CodeAnalysisRuleSet>$(SolutionDir)Analyze.default.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<eBPFExtensionsVersionMajor>0</eBPFExtensionsVersionMajor>
<eBPFExtensionsVersionMinor>1</eBPFExtensionsVersionMinor>
<eBPFExtensionsVersionRevision>0</eBPFExtensionsVersionRevision>
</PropertyGroup>
<PropertyGroup Condition="'$(AddressSanitizer)'=='True' And '$(MSBuildProjectExtension)'!='.csproj'">
<EnableASAN>true</EnableASAN>
</PropertyGroup>
Expand Down
17 changes: 17 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: MIT
-->
<Project>
<ItemGroup Condition="'$(MSBuildProjectExtension)'=='.proj' or '$(MSBuildProjectExtension)' == '.csproj'">
<PackageReference Include="DotNet.ReproducibleBuilds">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>
<ItemGroup>
<!-- Try to keep these in alphabetical order -->
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1"/>
<PackageVersion Include="DotNet.ReproducibleBuilds.Isolated" Version="1.1.1"/>
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.4"/>
<PackageVersion Include="DotNet.ReproducibleBuilds.Isolated" Version="1.2.4"/>
<PackageVersion Include="eBPF-for-Windows" Version="0.17.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
Expand Down
9 changes: 9 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sdk": {
"version": "8.0.000",
"rollForward": "latestPatch"
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.56"
}
}
24 changes: 0 additions & 24 deletions scripts/Get-Version.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/Set-Version.ps1

This file was deleted.

4 changes: 4 additions & 0 deletions tools/nuget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# eBPF for Windows Extensions NuGet Package

This NuGet package includes the binaries for eBPF for Windows Extensions,
such as `ntosebpfext` and `neteventebpfext`.
34 changes: 34 additions & 0 deletions tools/nuget/nuget.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation
SPDX-License-Identifier: MIT
-->
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<OutputPath>$(MSBuildThisFileDirectory)..\..\$(Platform)\$(Configuration)</OutputPath>
<PackageId>eBPF-for-Windows.Extensions</PackageId>
<IsPackable>true</IsPackable>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>eBPF for Windows Contributors</Authors>
<Owners>eBPF for Windows Contributors</Owners>
<Title>eBPF for Windows Extensions</Title>
<PackageDescription>eBPF for Windows Extensions</PackageDescription>
<PackageVersion>$(eBPFExtensionsVersionMajor).$(eBPFExtensionsVersionMinor).$(eBPFExtensionsVersionRevision)</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>native ebpf</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="eBPF-for-Windows" />
</ItemGroup>

<Target Name="_Get_NetNativeContent" BeforeTargets="PrepareForBuild;_IntermediatePack">
<ItemGroup>
<None Include="README.md" PackagePath="." Pack="true" />
<None Include="..\..\$(Platform)\$(Configuration)\ntosebpfext.sys" PackagePath="build\native\bin" Pack="true" />
<None Include="..\..\$(Platform)\$(Configuration)\ntosebpfext.pdb" PackagePath="build\native\bin" Pack="true" />
<None Include="..\..\$(Platform)\$(Configuration)\neteventebpfext.sys" PackagePath="build\native\bin" Pack="true" />
<None Include="..\..\$(Platform)\$(Configuration)\neteventebpfext.pdb" PackagePath="build\native\bin" Pack="true" />
</ItemGroup>
</Target>
</Project>

0 comments on commit ed29b0e

Please sign in to comment.