From 08317934aa7ec24d4b8c05698034c07b10c0cc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 09:49:41 +0100 Subject: [PATCH 01/11] feat: remove nuke --- .github/workflows/compile.yaml | 26 ------- .github/workflows/publish.yaml | 48 ------------ .nuke/build.schema.json | 131 -------------------------------- .nuke/parameters.json | 4 - .vscode/tasks.json | 60 --------------- build.cmd | 7 -- build.ps1 | 74 ------------------ build.sh | 67 ---------------- build/.editorconfig | 11 --- build/Build.cs | 101 ------------------------ build/Configuration.cs | 16 ---- build/Directory.Build.props | 8 -- build/Directory.Build.targets | 8 -- build/_build.csproj | 20 ----- build/_build.csproj.DotSettings | 27 ------- 15 files changed, 608 deletions(-) delete mode 100644 .github/workflows/compile.yaml delete mode 100644 .github/workflows/publish.yaml delete mode 100644 .nuke/build.schema.json delete mode 100644 .nuke/parameters.json delete mode 100644 .vscode/tasks.json delete mode 100755 build.cmd delete mode 100644 build.ps1 delete mode 100755 build.sh delete mode 100644 build/.editorconfig delete mode 100644 build/Build.cs delete mode 100644 build/Configuration.cs delete mode 100644 build/Directory.Build.props delete mode 100644 build/Directory.Build.targets delete mode 100644 build/_build.csproj delete mode 100644 build/_build.csproj.DotSettings diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml deleted file mode 100644 index 930e69c..0000000 --- a/.github/workflows/compile.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: CI Build - -on: - pull_request: - branches: - - "main" - push: - branches: - - "main" - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup .NET 9 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' - - name: Build with Nuke - run: ./build.sh compile - shell: bash \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 9cbc442..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Package Distribution - -on: - push: - tags: - - v* - -jobs: - build: - name: Publish packages - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET 9 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 9.0.* - - - name: Publish to NuGet with Nuke - run: ./build.sh push --nuget-api-key ${{ secrets.NUGET_API_KEY }} - shell: bash - create-issue: - needs: build - name: Create issue in template repo - runs-on: ubuntu-latest - steps: - - name: Set tag - id: vars - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - name: Post Issue - uses: maxkomarychev/oction-create-issue@v0.7.1 - id: create_issue - with: - token: ${{ secrets.TAMPLATE_REPO_TOKEN }} - owner: Intility - repo: templates - title: Intility.Logging packages update to ${{ steps.vars.outputs.tag }} - body: Package references in the dotnet templates should be updated to the latest version (${{ steps.vars.outputs.tag }}) - assignees: emilkje - labels: dotnet - - name: Print outputs - run: | - echo ${{ steps.create_issue.outputs.id }} - echo ${{ steps.create_issue.outputs.number }} \ No newline at end of file diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json deleted file mode 100644 index 4e8d28d..0000000 --- a/.nuke/build.schema.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "definitions": { - "Host": { - "type": "string", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitbucket", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] - }, - "ExecutableTarget": { - "type": "string", - "enum": [ - "Clean", - "Compile", - "Pack", - "Push", - "Restore" - ] - }, - "Verbosity": { - "type": "string", - "description": "", - "enum": [ - "Verbose", - "Normal", - "Minimal", - "Quiet" - ] - }, - "NukeBuild": { - "properties": { - "Continue": { - "type": "boolean", - "description": "Indicates to continue a previously failed build attempt" - }, - "Help": { - "type": "boolean", - "description": "Shows the help text for this build assembly" - }, - "Host": { - "description": "Host for execution. Default is 'automatic'", - "$ref": "#/definitions/Host" - }, - "NoLogo": { - "type": "boolean", - "description": "Disables displaying the NUKE logo" - }, - "Partition": { - "type": "string", - "description": "Partition to use on CI" - }, - "Plan": { - "type": "boolean", - "description": "Shows the execution plan (HTML)" - }, - "Profile": { - "type": "array", - "description": "Defines the profiles to load", - "items": { - "type": "string" - } - }, - "Root": { - "type": "string", - "description": "Root directory during build execution" - }, - "Skip": { - "type": "array", - "description": "List of targets to be skipped. Empty list skips all dependencies", - "items": { - "$ref": "#/definitions/ExecutableTarget" - } - }, - "Target": { - "type": "array", - "description": "List of targets to be invoked. Default is '{default_target}'", - "items": { - "$ref": "#/definitions/ExecutableTarget" - } - }, - "Verbosity": { - "description": "Logging verbosity during build execution. Default is 'Normal'", - "$ref": "#/definitions/Verbosity" - } - } - } - }, - "allOf": [ - { - "properties": { - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", - "enum": [ - "Debug", - "Release" - ] - }, - "NugetApiKey": { - "type": "string", - "description": "Api key to use when pushing the package" - }, - "PackageSource": { - "type": "string", - "description": "NuGet artifact target uri - Defaults to https://api.nuget.org/v3/index.json" - }, - "Solution": { - "type": "string", - "description": "Path to a solution file that is automatically loaded" - } - } - }, - { - "$ref": "#/definitions/NukeBuild" - } - ] -} diff --git a/.nuke/parameters.json b/.nuke/parameters.json deleted file mode 100644 index 55c0667..0000000 --- a/.nuke/parameters.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "./build.schema.json", - "Solution": "Intility.Logging.sln" -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index c4290a0..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "nuke", - "type": "shell", - "windows": { - "command": "${workspaceFolder}\\build.ps1" - }, - "linux": { - "command": "${workspaceFolder}/build.sh" - }, - "osx": { - "command": "${workspaceFolder}/build.sh" - }, - "args": [ - "compile" - ], - "problemMatcher": [ - "$msCompile" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "pack", - "command": "nuke", - "type": "shell", - "windows": { - "command": "${workspaceFolder}\\build.ps1" - }, - "linux": { - "command": "${workspaceFolder}/build.sh" - }, - "osx": { - "command": "${workspaceFolder}/build.sh" - }, - "args": [ - "pack" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/samples/WorkerSample/WorkerSample.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/build.cmd b/build.cmd deleted file mode 100755 index b08cc59..0000000 --- a/build.cmd +++ /dev/null @@ -1,7 +0,0 @@ -:; set -eo pipefail -:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) -:; ${SCRIPT_DIR}/build.sh "$@" -:; exit $? - -@ECHO OFF -powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 4634dc0..0000000 --- a/build.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$BuildArguments -) - -Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" - -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } -$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent - -########################################################################### -# CONFIGURATION -########################################################################### - -$BuildProjectFile = "$PSScriptRoot\build\_build.csproj" -$TempDirectory = "$PSScriptRoot\\.nuke\temp" - -$DotNetGlobalFile = "$PSScriptRoot\\global.json" -$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" -$DotNetChannel = "STS" - -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:DOTNET_NOLOGO = 1 - -########################################################################### -# EXECUTION -########################################################################### - -function ExecSafe([scriptblock] $cmd) { - & $cmd - if ($LASTEXITCODE) { exit $LASTEXITCODE } -} - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` - $(dotnet --version) -and $LASTEXITCODE -eq 0) { - $env:DOTNET_EXE = (Get-Command "dotnet").Path -} -else { - # Download install script - $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) - - # If global.json exists, load expected version - if (Test-Path $DotNetGlobalFile) { - $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) - if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { - $DotNetVersion = $DotNetGlobal.sdk.version - } - } - - # Install by channel or version - $DotNetDirectory = "$TempDirectory\dotnet-win" - if (!(Test-Path variable:DotNetVersion)) { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } - } else { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } - } - $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" - $env:PATH = "$DotNetDirectory;$env:PATH" -} - -Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)" - -if (Test-Path env:NUKE_ENTERPRISE_TOKEN) { - & $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null - & $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null -} - -ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } -ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh deleted file mode 100755 index fdff0c6..0000000 --- a/build.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -bash --version 2>&1 | head -n 1 - -set -eo pipefail -SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) - -########################################################################### -# CONFIGURATION -########################################################################### - -BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" - -DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" -DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" -DOTNET_CHANNEL="STS" - -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_NOLOGO=1 - -########################################################################### -# EXECUTION -########################################################################### - -function FirstJsonValue { - perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" -} - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then - export DOTNET_EXE="$(command -v dotnet)" -else - # Download install script - DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" - mkdir -p "$TEMP_DIRECTORY" - curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" - chmod +x "$DOTNET_INSTALL_FILE" - - # If global.json exists, load expected version - if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then - DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") - if [[ "$DOTNET_VERSION" == "" ]]; then - unset DOTNET_VERSION - fi - fi - - # Install by channel or version - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - if [[ -z ${DOTNET_VERSION+x} ]]; then - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path - else - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path - fi - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" - export PATH="$DOTNET_DIRECTORY:$PATH" -fi - -echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)" - -if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then - "$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true - "$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true -fi - -"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet -"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/build/.editorconfig b/build/.editorconfig deleted file mode 100644 index 31e43dc..0000000 --- a/build/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -[*.cs] -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_property = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_event = false:warning -dotnet_style_require_accessibility_modifiers = never:warning - -csharp_style_expression_bodied_methods = true:silent -csharp_style_expression_bodied_properties = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_accessors = true:warning diff --git a/build/Build.cs b/build/Build.cs deleted file mode 100644 index 0a1e380..0000000 --- a/build/Build.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using Nuke.Common; -using Nuke.Common.CI; -using Nuke.Common.Execution; -using Nuke.Common.Git; -using Nuke.Common.IO; -using Nuke.Common.ProjectModel; -using Nuke.Common.Tooling; -using Nuke.Common.Tools.DotNet; -using Nuke.Common.Tools.GitVersion; -using Nuke.Common.Utilities.Collections; -using static Nuke.Common.EnvironmentInfo; -using static Nuke.Common.IO.PathConstruction; -using static Nuke.Common.Tools.DotNet.DotNetTasks; - -[ShutdownDotNetAfterServerBuild] -class Build : NukeBuild -{ - /// Support plugins are available for: - /// - JetBrains ReSharper https://nuke.build/resharper - /// - JetBrains Rider https://nuke.build/rider - /// - Microsoft VisualStudio https://nuke.build/visualstudio - /// - Microsoft VSCode https://nuke.build/vscode - - public static int Main() => Execute(x => x.Compile); - - [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] - readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - - [Parameter("Api key to use when pushing the package")] - readonly string NugetApiKey; - - [Parameter("NuGet artifact target uri - Defaults to https://api.nuget.org/v3/index.json")] - readonly string PackageSource = "https://api.nuget.org/v3/index.json"; - - [Solution] readonly Solution Solution; - [GitRepository] readonly GitRepository GitRepository; - [GitVersion(NoFetch = true, Framework = "net9.0")] readonly GitVersion GitVersion; - - AbsolutePath SourceDirectory => RootDirectory / "src"; - AbsolutePath TestsDirectory => RootDirectory / "tests"; - AbsolutePath OutputDirectory => RootDirectory / "output"; - - Target Clean => _ => _ - .Before(Restore) - .Executes(() => - { - SourceDirectory.GlobDirectories("**/bin", "**/obj").DeleteDirectories(); - TestsDirectory.GlobDirectories("**/bin", "**/obj").DeleteDirectories(); - OutputDirectory.CreateOrCleanDirectory(); - }); - - Target Restore => _ => _ - .Executes(() => - { - DotNetRestore(s => s - .SetProjectFile(Solution)); - }); - - Target Compile => _ => _ - .DependsOn(Restore) - .Executes(() => - { - DotNetBuild(s => s - .SetProjectFile(Solution) - .SetTreatWarningsAsErrors(true) - .SetConfiguration(Configuration) - .SetAssemblyVersion(GitVersion.AssemblySemVer) - .SetFileVersion(GitVersion.AssemblySemFileVer) - .SetInformationalVersion(GitVersion.InformationalVersion) - .EnableNoRestore()); - }); - - Target Pack => _ => _ - .DependsOn(Clean, Compile) - .Executes(() => - { - DotNetPack(s => s - .SetProject(Solution) - .SetTreatWarningsAsErrors(true) - .EnableNoBuild() - .SetConfiguration(Configuration) - .SetVersion(GitVersion.NuGetVersionV2) - .SetOutputDirectory(OutputDirectory)); - }); - - Target Push => _ => _ - .DependsOn(Pack) - .Requires(() => NugetApiKey) - .Requires(() => PackageSource) - .Executes(() => - { - DotNetNuGetPush(s => s - .SetTargetPath(OutputDirectory / $"*.nupkg") - .EnableSkipDuplicate() - .SetApiKey(NugetApiKey) - .SetSource(PackageSource)); - }); -} diff --git a/build/Configuration.cs b/build/Configuration.cs deleted file mode 100644 index 9c08b1a..0000000 --- a/build/Configuration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.ComponentModel; -using System.Linq; -using Nuke.Common.Tooling; - -[TypeConverter(typeof(TypeConverter))] -public class Configuration : Enumeration -{ - public static Configuration Debug = new Configuration { Value = nameof(Debug) }; - public static Configuration Release = new Configuration { Value = nameof(Release) }; - - public static implicit operator string(Configuration configuration) - { - return configuration.Value; - } -} diff --git a/build/Directory.Build.props b/build/Directory.Build.props deleted file mode 100644 index e147d63..0000000 --- a/build/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/build/Directory.Build.targets b/build/Directory.Build.targets deleted file mode 100644 index 2532609..0000000 --- a/build/Directory.Build.targets +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/build/_build.csproj b/build/_build.csproj deleted file mode 100644 index e407451..0000000 --- a/build/_build.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - net9.0 - - CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006 - .. - .. - 1 - false - - - - - - - - - diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings deleted file mode 100644 index a778f33..0000000 --- a/build/_build.csproj.DotSettings +++ /dev/null @@ -1,27 +0,0 @@ - - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - Implicit - Implicit - ExpressionBody - 0 - NEXT_LINE - True - False - 120 - IF_OWNER_IS_SINGLE_LINE - WRAP_IF_LONG - False - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - True - True - True - True - True - True - True - True From b39b2f5089e4367ce5094407bc3e32c01ab78a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 09:50:00 +0100 Subject: [PATCH 02/11] feat: add new dependabot --- .github/{dependabot.yml => dependabot.yaml} | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) rename .github/{dependabot.yml => dependabot.yaml} (72%) diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 72% rename from .github/dependabot.yml rename to .github/dependabot.yaml index 29e431a..a85ca0a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yaml @@ -8,16 +8,9 @@ updates: interval: "monthly" time: "09:00" timezone: "Europe/Oslo" - + - package-ecosystem: "nuget" - directory: "/build" - schedule: - interval: "monthly" - time: "09:00" - timezone: "Europe/Oslo" - - - package-ecosystem: "nuget" - directory: "/src" + directory: "/src" schedule: interval: "monthly" time: "09:00" @@ -28,4 +21,3 @@ updates: all: patterns: - "*" - From a510f7d02c0125d9c90e570bb107594fb291e7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 09:50:18 +0100 Subject: [PATCH 03/11] feat: add new pipeline --- .github/workflows/build-and-release.yaml | 43 +++++++++++++++++++ .../LoggerBuilderExtensions.cs | 8 ++-- .../LoggerBuilder.cs | 18 ++------ 3 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/build-and-release.yaml diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml new file mode 100644 index 0000000..582c253 --- /dev/null +++ b/.github/workflows/build-and-release.yaml @@ -0,0 +1,43 @@ +name: Package Distribution + +on: + push: + tags: + - v* + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET 9 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.* + + - name: Restore dotnet + run: dotnet restore + + - name: Build dotnet + run: dotnet build --no-restore + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + sep-tags: ";" + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + + - name: Pack .NET project + run: dotnet pack src/Intility.Logging -o Intility.Logging/output --no-build --property:TreatWarningsAsErrors=true --property:Version=${{ steps.meta.outputs.tags }} + + - name: Publish to NuGet + run: dotnet nuget push Intility.Logging/output/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/src/Intility.Extensions.Logging.Elasticsearch/LoggerBuilderExtensions.cs b/src/Intility.Extensions.Logging.Elasticsearch/LoggerBuilderExtensions.cs index 5863cd7..245ae5e 100644 --- a/src/Intility.Extensions.Logging.Elasticsearch/LoggerBuilderExtensions.cs +++ b/src/Intility.Extensions.Logging.Elasticsearch/LoggerBuilderExtensions.cs @@ -3,7 +3,6 @@ using Elastic.Ingest.Elasticsearch.DataStreams; using Elastic.Serilog.Sinks; using Elastic.Transport; -using Microsoft.Extensions.Options; using Serilog.Debugging; using System; using System.Linq; @@ -72,17 +71,18 @@ public static ILoggerBuilder UseElasticsearch(this ILoggerBuilder builder, strin { DataStream = new DataStreamName(indexFormat, dataSet, namespaceName), BootstrapMethod = BootstrapMethod.Silent, - ChannelDiagnosticsCallback = channel => { + ChannelDiagnosticsCallback = channel => + { SelfLog.WriteLine( $"Failure={channel.PublishSuccess}, " + $"Message={channel}, " + $"Exception={channel.ObservedException}" - ); + ); }, TextFormatting = new EcsTextFormatterConfiguration() }; - if(!string.IsNullOrWhiteSpace(llmPolicy)) + if (!string.IsNullOrWhiteSpace(llmPolicy)) { sinkOptions.IlmPolicy = llmPolicy; } diff --git a/src/Intility.Extensions.Logging/LoggerBuilder.cs b/src/Intility.Extensions.Logging/LoggerBuilder.cs index 6249458..d588b4e 100644 --- a/src/Intility.Extensions.Logging/LoggerBuilder.cs +++ b/src/Intility.Extensions.Logging/LoggerBuilder.cs @@ -3,23 +3,13 @@ namespace Intility.Extensions.Logging { - public class LoggerBuilder : ILoggerBuilder + public class LoggerBuilder(HostBuilderContext host, LoggerConfiguration config, IHostBuilder hostBuilder) : ILoggerBuilder { - private readonly HostBuilderContext _host; - private readonly LoggerConfiguration _config; - private readonly IHostBuilder _hostBuilder; public ConsoleFormat ConsoleFormat { get; private set; } = ConsoleFormat.Pretty; - public LoggerBuilder(HostBuilderContext host, LoggerConfiguration config, IHostBuilder hostBuilder) - { - _host = host; - _config = config; - _hostBuilder = hostBuilder; - } - - public HostBuilderContext Host => _host; - public IHostBuilder HostBuilder => _hostBuilder; - public LoggerConfiguration Configuration => _config; + public HostBuilderContext Host => host; + public IHostBuilder HostBuilder => hostBuilder; + public LoggerConfiguration Configuration => config; public ILoggerBuilder UseConsoleFormat(ConsoleFormat format) { From 5ce6c9b69b10760c0c36908f064977d11daa8ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 10:01:25 +0100 Subject: [PATCH 04/11] fix: remove schedule --- .github/workflows/build-and-release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 582c253..834066d 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -31,7 +31,6 @@ jobs: with: sep-tags: ";" tags: | - type=schedule type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} From e6659f870ce668b304f9aaa2b301c53af083dab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 10:09:50 +0100 Subject: [PATCH 05/11] ci: pack sln --- .github/workflows/build-and-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 834066d..1a1c4f0 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -36,7 +36,7 @@ jobs: type=semver,pattern={{version}} - name: Pack .NET project - run: dotnet pack src/Intility.Logging -o Intility.Logging/output --no-build --property:TreatWarningsAsErrors=true --property:Version=${{ steps.meta.outputs.tags }} + run: dotnet pack Intility.Logging.sln -o Intility.Logging/output --no-build --property:TreatWarningsAsErrors=true --property:Version=${{ steps.meta.outputs.tags }} - name: Publish to NuGet run: dotnet nuget push Intility.Logging/output/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json From c5c94eeb43015e984986a274581e8b3525e7b964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 10:52:43 +0100 Subject: [PATCH 06/11] ci: do not run publish if pr --- .github/workflows/build-and-release.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 1a1c4f0..8b6ac1f 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -27,16 +27,18 @@ jobs: - name: Docker meta id: meta + if: github.event_name != 'pull_request' uses: docker/metadata-action@v5 with: sep-tags: ";" tags: | type=ref,event=branch - type=ref,event=pr type=semver,pattern={{version}} - name: Pack .NET project + if: github.event_name != 'pull_request' run: dotnet pack Intility.Logging.sln -o Intility.Logging/output --no-build --property:TreatWarningsAsErrors=true --property:Version=${{ steps.meta.outputs.tags }} - name: Publish to NuGet + if: github.event_name != 'pull_request' run: dotnet nuget push Intility.Logging/output/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json From 32de143e0a2c85a54272a1765ab140cec23a86ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 10:54:22 +0100 Subject: [PATCH 07/11] ci: rename workflow --- .github/workflows/build-and-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 8b6ac1f..2b58c51 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -1,4 +1,4 @@ -name: Package Distribution +name: Build and release on: push: From 972bb0627f0cd671cf240be3f2f3c8342828cde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 11:01:33 +0100 Subject: [PATCH 08/11] build: set TreatWarningsAsErrors --- .github/workflows/build-and-release.yaml | 2 +- .../Intility.Extensions.Logging.Elasticsearch.csproj | 11 ++++++----- .../Intility.Extensions.Logging.Sentry.csproj | 11 ++++++----- .../Intility.Extensions.Logging.csproj | 11 ++++++----- .../Intility.Logging.AspNetCore.csproj | 1 + 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 2b58c51..668f03a 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -37,7 +37,7 @@ jobs: - name: Pack .NET project if: github.event_name != 'pull_request' - run: dotnet pack Intility.Logging.sln -o Intility.Logging/output --no-build --property:TreatWarningsAsErrors=true --property:Version=${{ steps.meta.outputs.tags }} + run: dotnet pack Intility.Logging.sln -o Intility.Logging/output --property:Version=${{ steps.meta.outputs.tags }} - name: Publish to NuGet if: github.event_name != 'pull_request' diff --git a/src/Intility.Extensions.Logging.Elasticsearch/Intility.Extensions.Logging.Elasticsearch.csproj b/src/Intility.Extensions.Logging.Elasticsearch/Intility.Extensions.Logging.Elasticsearch.csproj index 9d2ee71..2fa48ed 100644 --- a/src/Intility.Extensions.Logging.Elasticsearch/Intility.Extensions.Logging.Elasticsearch.csproj +++ b/src/Intility.Extensions.Logging.Elasticsearch/Intility.Extensions.Logging.Elasticsearch.csproj @@ -11,11 +11,12 @@ Enable Elasticsearch logging provider. - Intility - Intility - Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard - https://github.com/Intility/Intility.Logging - intility-logo.png + Intility + Intility + Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard + https://github.com/Intility/Intility.Logging + intility-logo.png + true diff --git a/src/Intility.Extensions.Logging.Sentry/Intility.Extensions.Logging.Sentry.csproj b/src/Intility.Extensions.Logging.Sentry/Intility.Extensions.Logging.Sentry.csproj index ac4f3ec..2666fe5 100644 --- a/src/Intility.Extensions.Logging.Sentry/Intility.Extensions.Logging.Sentry.csproj +++ b/src/Intility.Extensions.Logging.Sentry/Intility.Extensions.Logging.Sentry.csproj @@ -11,11 +11,12 @@ Enable Sentry instrumentation and logging provider. - Intility - Intility - Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard - https://github.com/Intility/Intility.Logging - intility-logo.png + Intility + Intility + Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard + https://github.com/Intility/Intility.Logging + intility-logo.png + true diff --git a/src/Intility.Extensions.Logging/Intility.Extensions.Logging.csproj b/src/Intility.Extensions.Logging/Intility.Extensions.Logging.csproj index 8180f9a..7b5b09f 100644 --- a/src/Intility.Extensions.Logging/Intility.Extensions.Logging.csproj +++ b/src/Intility.Extensions.Logging/Intility.Extensions.Logging.csproj @@ -12,11 +12,12 @@ Common logging infrastructure with extension primitives. Please do not install this package directly. - Intility - Intility - Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard - https://github.com/Intility/Intility.Logging - intility-logo.png + Intility + Intility + Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard + https://github.com/Intility/Intility.Logging + intility-logo.png + true diff --git a/src/Intility.Logging.AspNetCore/Intility.Logging.AspNetCore.csproj b/src/Intility.Logging.AspNetCore/Intility.Logging.AspNetCore.csproj index 58ba9c9..ad3cb3a 100644 --- a/src/Intility.Logging.AspNetCore/Intility.Logging.AspNetCore.csproj +++ b/src/Intility.Logging.AspNetCore/Intility.Logging.AspNetCore.csproj @@ -18,6 +18,7 @@ Herman Jensen, Emil Kjelsrud, Thorstein Løkensgard https://github.com/Intility/Intility.Logging intility-logo.png + true From 03e6c9160fb9da77ce11b7876bb15b440d46494c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 11:05:03 +0100 Subject: [PATCH 09/11] ci: set name for workflow --- .github/workflows/build-and-release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 668f03a..007146b 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -10,6 +10,7 @@ on: jobs: build: + name: Build and release runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From eaebc4f997fe2ce217073839a66e0f7a03ca268c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 11:08:51 +0100 Subject: [PATCH 10/11] docs: add CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..924cc25 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @Intility/dotnet-devs From 6d2ab1deca51e6e66c3da67250c51b8505a60ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorstein=20L=C3=B8kensgard?= Date: Fri, 21 Feb 2025 11:10:25 +0100 Subject: [PATCH 11/11] fix: make dependabot listen to sln --- .github/dependabot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index a85ca0a..0186092 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -10,7 +10,7 @@ updates: timezone: "Europe/Oslo" - package-ecosystem: "nuget" - directory: "/src" + directory: "/" schedule: interval: "monthly" time: "09:00"