Skip to content

Commit

Permalink
Build and publish AutoDiscovery in this repository too (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
hach-que authored Dec 23, 2024
1 parent 894b725 commit ab6c1b3
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 9 deletions.
35 changes: 35 additions & 0 deletions .github/actions/dotnet-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ inputs:
runs:
using: 'composite'
steps:
- name: Cache .NET SDK (Windows)
if: ${{ runner.os == 'Windows' }}
id: cache-sdk-win
uses: actions/cache@v4
with:
key: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}
restore-keys: dotnet-sdk-windows-${{ inputs.UET_FRAMEWORK_TARGET }}
path: .dotnet-${{ inputs.UET_FRAMEWORK_TARGET }}
- name: Cache .NET SDK (macOS)
if: ${{ runner.os == 'macOS' }}
id: cache-sdk-mac
Expand All @@ -15,6 +23,26 @@ runs:
key: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}
restore-keys: dotnet-sdk-mac-${{ inputs.UET_FRAMEWORK_TARGET }}
path: .dotnet-${{ inputs.UET_FRAMEWORK_TARGET }}
- name: Download .NET SDK (Windows)
if: ${{ runner.os == 'Windows' && steps.cache-sdk-win.outputs.cache-hit != 'true' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
UET_DOTNET_WIN_DL: https://download.visualstudio.microsoft.com/download/pr/6902745c-34bd-4d66-8e84-d5b61a17dfb7/e61732b00f7e144e162d7e6914291f16/dotnet-sdk-8.0.101-win-x64.zip
run: |
if (!(Test-Path .dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet\dotnet-extracted)) {
if (Test-Path ".dotnet-${env:UET_FRAMEWORK_TARGET}") {
Remove-Item -Recurse -Force ".dotnet-${env:UET_FRAMEWORK_TARGET}"
}
Write-Host "Setting up .NET SDK..."
New-Item -ItemType Directory ".dotnet-${env:UET_FRAMEWORK_TARGET}" | Out-Null
curl.exe -L -o ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet.zip" "${env:UET_DOTNET_WIN_DL}"
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
Expand-Archive -Path ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet.zip" -DestinationPath ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet" -Force | Out-Null
Set-Content -Path .dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet\dotnet-extracted -Value "done"
}
- name: Download .NET SDK (macOS)
if: ${{ runner.os == 'macOS' && steps.cache-sdk-mac.outputs.cache-hit != 'true' }}
shell: pwsh
Expand All @@ -41,6 +69,13 @@ runs:
}
Set-Content -Path .dotnet-${env:UET_FRAMEWORK_TARGET}/dotnet/dotnet-extracted -Value "done"
}
- name: Add .NET SDK to PATH (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
env:
UET_FRAMEWORK_TARGET: ${{ inputs.UET_FRAMEWORK_TARGET }}
run: |
Add-Content -Path "${env:GITHUB_PATH}" -Value ".dotnet-${env:UET_FRAMEWORK_TARGET}\dotnet"
- name: Add .NET SDK to PATH (macOS)
if: ${{ runner.os == 'macOS' }}
shell: pwsh
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/autodiscovery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Redpoint.AutoDiscovery

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
UET_FRAMEWORK_TARGET: net8.0
UET_BUILDING_ON_BUILD_SERVER: "true"

jobs:
autodiscovery:
name: "Build and Publish"
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET SDK
uses: ./.github/actions/dotnet-sdk
with:
UET_FRAMEWORK_TARGET: ${{ env.UET_FRAMEWORK_TARGET }}
- name: Build Redpoint.AutoDiscovery
shell: pwsh
run: |
$Timestamp = ([DateTime]::UtcNow)
$PackageVersion = "$($Timestamp.Year).$($Timestamp.DayOfYear + 1000).$(($Timestamp.Hour * 60) + $Timestamp.Minute)"
Write-Host "Package version: $PackageVersion"
Write-Host "Building Redpoint.AutoDiscovery version '$PackageVersion'..."
dotnet `
msbuild `
-restore `
-p:RuntimeIdentifier=win-x86 `
-p:Configuration=Release `
-p:Platform=x86 `
"-p:BaseUetVersion=$PackageVersion" `
"-p:PackageVersion=$PackageVersion" `
Redpoint.AutoDiscovery.Win32/Redpoint.AutoDiscovery.Win32.csproj
if ($LastExitCode -ne 0) { exit $LastExitCode }
dotnet `
msbuild `
-restore `
-p:RuntimeIdentifier=win-x64 `
-p:Configuration=Release `
-p:Platform=x64 `
"-p:BaseUetVersion=$PackageVersion" `
"-p:PackageVersion=$PackageVersion" `
Redpoint.AutoDiscovery.Win64/Redpoint.AutoDiscovery.Win64.csproj
if ($LastExitCode -ne 0) { exit $LastExitCode }
- name: Publish Redpoint.AutoDiscovery
shell: pwsh
if: github.ref == 'refs/heads/main'
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY (Get-ChildItem -Recurse -Filter "Redpoint.AutoDiscovery.Win32/bin/Release/Redpoint.AutoDiscovery.Win32.*.nupkg" | % { $_.FullName })
if ($LastExitCode -ne 0) { exit $LastExitCode }
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY (Get-ChildItem -Recurse -Filter "Redpoint.AutoDiscovery.Win64/bin/Release/Redpoint.AutoDiscovery.Win64.*.nupkg" | % { $_.FullName })
if ($LastExitCode -ne 0) { exit $LastExitCode }
8 changes: 2 additions & 6 deletions .github/workflows/mac-logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ env:

jobs:
mac-logging:
name: "Build and Publish Redpoint.Logging.Mac.Native"
name: "Build and Publish"
runs-on: macos-latest
env:
UET_PACKAGE_VERSION: ${{ needs.timestamp.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,8 +28,6 @@ jobs:
run: |
$Timestamp = ([DateTime]::UtcNow)
$PackageVersion = "$($Timestamp.Year).$($Timestamp.DayOfYear + 1000).$(($Timestamp.Hour * 60) + $Timestamp.Minute)"
Set-Content -NoNewline -Path "package.version" -Value "$($PackageVersion)"
Set-Content -NoNewline -Path "$env:GITHUB_OUTPUT" -Value "version=$($PackageVersion)"
Write-Host "Package version: $PackageVersion"
Expand Down Expand Up @@ -59,5 +55,5 @@ jobs:
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY (Get-ChildItem -Recurse -Filter "Redpoint.Logging.Mac.Native/bin/Redpoint.Logging.Mac.Native.*.nupkg" | % { $_.FullName })
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY (Get-ChildItem -Recurse -Filter "bin/Redpoint.Logging.Mac.Native.*.nupkg" | % { $_.FullName })
if ($LastExitCode -ne 0) { exit $LastExitCode }
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.sln
bin/
obj/
39 changes: 39 additions & 0 deletions Lib/Common.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)./Framework.Build.props" />

<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>

<PropertyGroup>
<IsPackable Condition="'$(UetSkipNuGetPackaging)' == 'true'">false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsTrimmable>
<EnableTrimAnalyzer Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</EnableTrimAnalyzer>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnableSingleFileAnalyzer Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</EnableSingleFileAnalyzer>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>All</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);SYSLIB1224</NoWarn>
</PropertyGroup>

<ItemGroup>
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)../.analyzerconfig" />
</ItemGroup>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
19 changes: 19 additions & 0 deletions Lib/CsWin32.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- CsWin32 does not add the 'in' keyword properly yet. -->
<NoWarn>$(NoWarn);CS9195</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.18-beta" NoWarn="NU5104">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Win32Docs" Version="0.1.42-alpha" NoWarn="NU5104" />
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="54.0.44-preview" NoWarn="NU5104" />
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.8.2-experimental" NoWarn="NU5104" />
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions Lib/Framework.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>

<!-- This is used for libraries that we want to make available to .NET Framework. -->
<RedpointTargetFrameworks>net8.0;net48</RedpointTargetFrameworks>

<RedpointSystemLibraryVersion>8.*</RedpointSystemLibraryVersion>
</PropertyGroup>

</Project>
30 changes: 30 additions & 0 deletions Lib/LibraryPackaging.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project>
<PropertyGroup>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Copyright>Redpoint Games</Copyright>
<PackageProjectUrl></PackageProjectUrl>
<RepositoryUrl>https://src.redpoint.games/redpointgames/uet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>June Rhodes</Authors>
<Company>Redpoint Games</Company>
<PackageIcon>PackageIcon.png</PackageIcon>
<PackageReadmeFile Condition="Exists('$(ProjectDir)README.md')">README.md</PackageReadmeFile>

<PackageYear>$([System.DateTime]::UtcNow.Year)</PackageYear>
<PackageDayOfYear>$([System.DateTime]::UtcNow.DayOfYear)</PackageDayOfYear>
<PackageHour>$([System.DateTime]::UtcNow.Hour)</PackageHour>
<PackageMinute>$([System.DateTime]::UtcNow.Minute)</PackageMinute>
<PackageVersionMajor>$(PackageYear)</PackageVersionMajor>
<PackageVersionMinor>$([MSBuild]::Add($(PackageDayOfYear), 1000))</PackageVersionMinor>
<PackageVersionPatch>$([MSBuild]::Add($([MSBuild]::Multiply($(PackageHour), 60)), $(PackageMinute)))</PackageVersionPatch>

<PackageVersion Condition="'$(PackageVersion)' == ''">$(PackageVersionMajor).$(PackageVersionMinor).$(PackageVersionPatch)-pre</PackageVersion>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)PackageIcon.png" Pack="True" PackagePath="" />
<None Condition="Exists('$(ProjectDir)README.md')" Include="$(ProjectDir)README.md" Pack="True" PackagePath="" />
</ItemGroup>
</Project>
48 changes: 48 additions & 0 deletions Lib/XunitTesting.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)Framework.Build.props" Condition="'$(TargetFramework)' == ''" />

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<RestoreAdditionalProjectSources>$(MSBuildThisFileDirectory)../Redpoint.Logging.Mac/bin;$(MSBuildThisFileDirectory)../Redpoint.AutoDiscovery/bin/$(Configuration)</RestoreAdditionalProjectSources>
</PropertyGroup>

<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(RedpointSystemLibraryVersion)" />
<ProjectReference Include="$(MSBuildThisFileDirectory)Redpoint.ThirdParty.Microsoft.Extensions.Logging.Console\Redpoint.ThirdParty.Microsoft.Extensions.Logging.Console.csproj" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(RedpointSystemLibraryVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)../Redpoint.XunitFramework/Redpoint.XunitFramework.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)../Redpoint.XunitFramework/xunit.runner.json" CopyToOutputDirectory="PreserveNewest">
<Link>xunit.runner.json</Link>
</None>
<Compile Include="$(MSBuildThisFileDirectory)../Redpoint.XunitFramework/UseRedpointTestFramework.cs">
<Link>UseRedpointTestFramework.cs</Link>
</Compile>
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Redpoint.Logging.Mac.Native
# UET (native libraries)

This repository builds and publishes the `Redpoint.Logging.Mac.Native` NuGet package, which provides the native macOS `.dylib` files that are necessary to support logging to the macOS system log in `Redpoint.Logging.Mac`.
This repository builds and publishes libraries for UET that are dependent on native APIs: `Redpoint.Logging.Mac.Native` which provides the native macOS `.dylib` files that are necessary to support logging to the macOS system log in `Redpoint.Logging.Mac`, and `Redpoint.AutoDiscovery` which can only be built on Windows.

This folder used to be part of the [UET](https://github.com/RedpointGames/uet) repository, but was moved here to simplify the build process of UET when developing on a local machine. This library basically never changes it's implementation, so having it build and publish from it's own repository, and having UET simply depend on the published NuGet package was considered far more maintainable.
The C# projects in this repository used to be part of the [UET](https://github.com/RedpointGames/uet) repository, but they were moved here to simplify the build process of UET when developing on a local machine. These library implementations basically never change, so having it build and publish from it's own repository, and having UET simply depend on the published NuGet packages was considered far more maintainable.

All bug reports should be reported in the [UET](https://github.com/RedpointGames/uet) repository.

Expand Down
4 changes: 4 additions & 0 deletions Redpoint.AutoDiscovery.Win32/NativeMethods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"public": true
}
12 changes: 12 additions & 0 deletions Redpoint.AutoDiscovery.Win32/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DnsServiceRegister
DnsServiceRegisterCancel
DnsServiceDeRegister
DnsServiceBrowse
DnsServiceBrowseCancel
DnsServiceConstructInstance
DnsServiceFreeInstance
DnsFree
DNS_QUERY_OPTIONS
DNS_REQUEST_PENDING
DNS_TYPE
WIN32_ERROR
5 changes: 5 additions & 0 deletions Redpoint.AutoDiscovery.Win32/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Redpoint.AutoDiscovery.Win32

Provides native binaries for the Redpoint.AutoDiscovery library.

You should depend on `Redpoint.AutoDiscovery` instead of this NuGet package.
23 changes: 23 additions & 0 deletions Redpoint.AutoDiscovery.Win32/Redpoint.AutoDiscovery.Win32.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(MSBuildThisFileDirectory)../Lib/Common.Build.props" />
<Import Project="$(MSBuildThisFileDirectory)../Lib/LibraryPackaging.Build.props" />

<PropertyGroup>
<RootNamespace>Redpoint.AutoDiscovery.Win32</RootNamespace>
<AssemblyName>Redpoint.AutoDiscovery.Win32</AssemblyName>
<Platforms>x86</Platforms>
<Platform>x86</Platform>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)../Lib/CsWin32.Build.props" />

<ItemGroup>
<None Remove="NativeMethods.json" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="NativeMethods.json" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions Redpoint.AutoDiscovery.Win64/NativeMethods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"public": true
}
12 changes: 12 additions & 0 deletions Redpoint.AutoDiscovery.Win64/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DnsServiceRegister
DnsServiceRegisterCancel
DnsServiceDeRegister
DnsServiceBrowse
DnsServiceBrowseCancel
DnsServiceConstructInstance
DnsServiceFreeInstance
DnsFree
DNS_QUERY_OPTIONS
DNS_REQUEST_PENDING
DNS_TYPE
WIN32_ERROR
Loading

0 comments on commit ab6c1b3

Please sign in to comment.