From 3cc4e4cfe7ac9cf45227efa20de6317a83685bf8 Mon Sep 17 00:00:00 2001 From: Steve Ardalis Smith Date: Wed, 25 Nov 2026 08:38:58 -0500 Subject: [PATCH 1/2] Update to .NET 11 and latest dependencies - Target net11.0 - Ardalis.GuardClauses 6.0.0, Ardalis.Specification 10.0.0, Mediator 3.0.2 - Test packages: Microsoft.NET.Test.Sdk 18.12.0, coverlet.collector 10.1.1, AwesomeAssertions 9.6.0, Moq 4.21.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.1 - Remove Microsoft.Extensions.Logging.Abstractions reference (NU1510: provided by net11.0) - CI/publish workflows: .NET 11 SDK, actions/checkout v7, actions/setup-dotnet v6 - Bump package version to 4.0.0 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 6 ++--- .github/workflows/publish.yml | 6 ++--- Directory.Build.props | 2 +- Directory.Packages.props | 23 +++++++++---------- .../NimblePros.SharedKernel.csproj | 7 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e9b1cd..6113564 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,11 +21,11 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Setup dotnet - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v6 with: - dotnet-version: 10.0.x + dotnet-version: 11.0.x - name: Build run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release - name: Test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index be2cc16..0a10b22 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,12 +18,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup dotnet - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v6 with: - dotnet-version: 10.0.x + dotnet-version: 11.0.x - name: Build run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release diff --git a/Directory.Build.props b/Directory.Build.props index e652862..78839cb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ true true - net8.0 + net11.0 enable enable diff --git a/Directory.Packages.props b/Directory.Packages.props index 3b2c0b9..0f0cda1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,16 +1,15 @@ - - - - - - - - - + + + + + + + + - - + + - \ No newline at end of file + diff --git a/src/NimblePros.SharedKernel/NimblePros.SharedKernel.csproj b/src/NimblePros.SharedKernel/NimblePros.SharedKernel.csproj index 671a3de..c965daa 100644 --- a/src/NimblePros.SharedKernel/NimblePros.SharedKernel.csproj +++ b/src/NimblePros.SharedKernel/NimblePros.SharedKernel.csproj @@ -13,9 +13,11 @@ https://github.com/NimblePros/SharedKernelSample Ardalis;NimblePros;DDD;Shared Kernel;SharedKernel;Domain-Driven Design;Repository;Specification;ValueObject;Value Object;Clean;Clean Architecture;Clean Architecture Template icon.png - 3.1.0 + 4.0.0 - * Make domain event methods public + * Target .NET 11 (net11.0) + * Update dependencies: Ardalis.GuardClauses 6.0.0, Ardalis.Specification 10.0.0, Mediator.Abstractions 3.0.2 + * Remove explicit Microsoft.Extensions.Logging.Abstractions reference (provided by the .NET 11 shared framework) true true @@ -27,7 +29,6 @@ - From 772d1bf193c037852c34b190560c8d15532ff7c7 Mon Sep 17 00:00:00 2001 From: Steve Ardalis Smith Date: Wed, 25 Nov 2026 08:53:44 -0500 Subject: [PATCH 2/2] Modernize GitHub workflows and finish NuGet trusted publishing - ci.yml: broaden path filters, least-privilege permissions, concurrency, locked-mode restore with NuGet caching, TRX + coverage artifacts, pack and upload the nupkg, callable via workflow_call - publish.yml: reuse ci.yml, push the CI-built package; OIDC login and push only run for tag refs, with id-token: write scoped to that job - Pin all actions to commit SHAs (NuGet/login v1.2.0) - Add Dependabot for github-actions and nuget - Enable NuGet lock files Refs #6 Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 27 +++ .github/workflows/ci.yml | 81 ++++++-- .github/workflows/publish.yml | 54 ++--- Directory.Build.props | 1 + .../packages.lock.json | 25 +++ .../packages.lock.json | 195 ++++++++++++++++++ 6 files changed, 342 insertions(+), 41 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 src/NimblePros.SharedKernel/packages.lock.json create mode 100644 tests/NimblePros.SharedKernel.UnitTests/packages.lock.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..88d3475 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,27 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + github-actions: + patterns: + - '*' + + - package-ecosystem: nuget + directory: / + schedule: + interval: weekly + groups: + test-dependencies: + patterns: + - 'Microsoft.NET.Test.Sdk' + - 'xunit*' + - 'coverlet.*' + - 'Moq' + - 'Shouldly' + - 'AwesomeAssertions' + mediator: + patterns: + - 'Mediator.*' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6113564..4c12a1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,33 +1,86 @@ name: Build and Test -on: +on: workflow_dispatch: + workflow_call: push: branches: - main paths: - 'src/**' + - 'tests/**' + - 'Directory.*.props' + - '*.slnx' + - 'nuget.config' + - '.github/workflows/**' pull_request: branches: - main paths: - 'src/**' + - 'tests/**' + - 'Directory.*.props' + - '*.slnx' + - 'nuget.config' + - '.github/workflows/**' + +permissions: + contents: read + +concurrency: + # When called from publish.yml, github.workflow is the caller's name, so releases don't cancel CI runs. + group: ${{ github.workflow }}-ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: SOLUTION_FILE: NimblePros.SharedKernel.slnx - + PACK_OUTPUT: artifacts/package/release + TEST_RESULTS: artifacts/test-results + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + jobs: build: runs-on: ubuntu-latest - + steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup dotnet - uses: actions/setup-dotnet@v6 - with: - dotnet-version: 11.0.x - - name: Build - run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release - - name: Test - run: dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore - + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Setup dotnet + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 + with: + dotnet-version: 11.0.x + cache: true + cache-dependency-path: '**/packages.lock.json' + + - name: Restore + run: dotnet restore "${{ env.SOLUTION_FILE }}" --locked-mode + + - name: Build + run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release --no-restore + + - name: Test + run: > + dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore + --logger trx + --collect "XPlat Code Coverage" + --results-directory "${{ env.TEST_RESULTS }}" + + - name: Pack + run: dotnet pack "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore --output "${{ env.PACK_OUTPUT }}" + + - name: Upload test results and coverage + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: test-results + path: ${{ env.TEST_RESULTS }} + if-no-files-found: warn + + - name: Upload package + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: nuget-package + path: ${{ env.PACK_OUTPUT }}/*.*nupkg + if-no-files-found: error diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a10b22..436b24b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,47 +5,47 @@ on: release: types: [published] -env: - SOLUTION_FILE: NimblePros.SharedKernel.slnx - PACK_OUTPUT: artifacts/package/release +permissions: + contents: read + +concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: false jobs: - build: + ci: + uses: ./.github/workflows/ci.yml + + publish: + needs: ci + # Only push packages for release tags; a manual run on a branch just builds and tests. + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest permissions: contents: read - id-token: write - runs-on: ubuntu-latest + id-token: write # required for NuGet trusted publishing (OIDC) steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup dotnet - uses: actions/setup-dotnet@v6 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 11.0.x - - name: Build - run: dotnet build "${{ env.SOLUTION_FILE }}" --configuration Release - - - name: Test - run: dotnet test "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore - - - name: Pack - run: dotnet pack "${{ env.SOLUTION_FILE }}" --configuration Release --no-build --no-restore --output "${{ env.PACK_OUTPUT }}" + - name: Download package + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: nuget-package + path: packages - name: NuGet login (OIDC -> temp API key) - uses: NuGet/login@v1 + uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0 id: login with: user: ${{ secrets.NUGET_USER }} - name: Push to NuGet - if: startsWith(github.ref, 'refs/tags/') # only push if building a tag - shell: pwsh - run: | - Get-ChildItem "${{ env.PACK_OUTPUT }}" -Filter *.nupkg | ForEach-Object { - dotnet nuget push $_.FullName ` - --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" ` - --source https://api.nuget.org/v3/index.json - } + run: > + dotnet nuget push "packages/*.nupkg" + --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" + --source https://api.nuget.org/v3/index.json + --skip-duplicate diff --git a/Directory.Build.props b/Directory.Build.props index 78839cb..7ec9a86 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,5 +5,6 @@ net11.0 enable enable + true \ No newline at end of file diff --git a/src/NimblePros.SharedKernel/packages.lock.json b/src/NimblePros.SharedKernel/packages.lock.json new file mode 100644 index 0000000..b7fb6f4 --- /dev/null +++ b/src/NimblePros.SharedKernel/packages.lock.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "dependencies": { + "net11.0": { + "Ardalis.GuardClauses": { + "type": "Direct", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "VPCr46YYHjcnunQpixMP/LDH56s85oTvu+wJ4zXu4JNYOm76VD0veDX3gneMV8w1XPnwJWUHrWJXrhaPAJM6QA==" + }, + "Ardalis.Specification": { + "type": "Direct", + "requested": "[10.0.0, )", + "resolved": "10.0.0", + "contentHash": "gzIybrs66DqZPMYwumDHCh3ELPmt77CMOoOma9oPkUaBxtKJfvJtfet4kx4WL9JaVUDDZK3IYq673TPLcU+/FA==" + }, + "Mediator.Abstractions": { + "type": "Direct", + "requested": "[3.0.2, )", + "resolved": "3.0.2", + "contentHash": "TytjnyN8gLObZBxkM7HHPFJF3LHtk6Y8mHW56ONuXRuVEK6Fmed3f0z79H9TpmoZQP2zQAIS4/0O9R2w0v02qw==" + } + } + } +} \ No newline at end of file diff --git a/tests/NimblePros.SharedKernel.UnitTests/packages.lock.json b/tests/NimblePros.SharedKernel.UnitTests/packages.lock.json new file mode 100644 index 0000000..8df4402 --- /dev/null +++ b/tests/NimblePros.SharedKernel.UnitTests/packages.lock.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "dependencies": { + "net11.0": { + "AwesomeAssertions": { + "type": "Direct", + "requested": "[9.6.0, )", + "resolved": "9.6.0", + "contentHash": "8kdtgI+tZIgP46ncnk650/dU4JSrn+n2Dkic8FvjIFn72P6Nv1Afyr5F8F3PsokHg1GBSBVo1/Z+eZOrU5esSA==" + }, + "coverlet.collector": { + "type": "Direct", + "requested": "[10.1.1, )", + "resolved": "10.1.1", + "contentHash": "iRWGpNzKG6/pA0VzAt+WDzFAPMHvs/E4ZxeSYiEaAa7MzFhAcWcIWd7RDNLhCBenpSNdJCwm42UcQP4nGUbwJQ==" + }, + "Mediator.SourceGenerator": { + "type": "Direct", + "requested": "[3.0.2, )", + "resolved": "3.0.2", + "contentHash": "yGQzb8Or3nGsQJnVUQIQHr/04LeThd3qMZV0gvgMtXdgH35Rw2xJ2XyQ87v6HhNYOUZ2iirRjUWceebyNKMF7Q==" + }, + "Microsoft.NET.Test.Sdk": { + "type": "Direct", + "requested": "[18.12.0, )", + "resolved": "18.12.0", + "contentHash": "MdVkskM2ZCKSlNts5DIbz9MZidX7SwcXKBoBqY4XT91b30hAwC8PkjWbdGKRak6BKAD1BQqaZnh/SD0AJGoDCQ==", + "dependencies": { + "Microsoft.CodeCoverage": "18.12.0", + "Microsoft.TestPlatform.TestHost": "18.12.0" + } + }, + "Moq": { + "type": "Direct", + "requested": "[4.21.0, )", + "resolved": "4.21.0", + "contentHash": "HUjrhhzEJ/AfbSBCnR8lPkpveVGpV/dNuOlnpfqBNTME93izly1CRV4N5zBySqz4m2yCRlHLPy/PnPzYokbwIg==", + "dependencies": { + "Castle.Core": "5.2.1" + } + }, + "Shouldly": { + "type": "Direct", + "requested": "[4.3.0, )", + "resolved": "4.3.0", + "contentHash": "sDetrWXrl6YXZ4HeLsdBoNk3uIa7K+V4uvIJ+cqdRa5DrFxeTED7VkjoxCuU1kJWpUuBDZz2QXFzSxBtVXLwRQ==", + "dependencies": { + "DiffEngine": "11.3.0", + "EmptyFiles": "4.4.0" + } + }, + "xunit": { + "type": "Direct", + "requested": "[2.9.3, )", + "resolved": "2.9.3", + "contentHash": "TlXQBinK35LpOPKHAqbLY4xlEen9TBafjs0V5KnA4wZsoQLQJiirCR4CbIXvOH8NzkW4YeJKP5P/Bnrodm0h9Q==", + "dependencies": { + "xunit.analyzers": "1.18.0", + "xunit.assert": "2.9.3", + "xunit.core": "[2.9.3]" + } + }, + "xunit.runner.visualstudio": { + "type": "Direct", + "requested": "[4.0.1, )", + "resolved": "4.0.1", + "contentHash": "8CoAaZkniVekR1ycJyxn+hOz+6ZQCDPcoIsIs6ujd4WyFcBMlxGNU15Qb8Uxd4iO4UmOuETb0M6vzBbwX/mfLA==" + }, + "Castle.Core": { + "type": "Transitive", + "resolved": "5.2.1", + "contentHash": "wHARzQA695jwwKreOzNsq54KiGqKP38tv8hi8e2FXDEC/sA6BtrX90tVPDkOfVu13PbEzr00TCV8coikl+D1Iw==", + "dependencies": { + "System.Diagnostics.EventLog": "6.0.0" + } + }, + "DiffEngine": { + "type": "Transitive", + "resolved": "11.3.0", + "contentHash": "k0ZgZqd09jLZQjR8FyQbSQE86Q7QZnjEzq1LPHtj1R2AoWO8sjV5x+jlSisL7NZAbUOI4y+7Bog8gkr9WIRBGw==", + "dependencies": { + "EmptyFiles": "4.4.0", + "System.Management": "6.0.1" + } + }, + "EmptyFiles": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "gwJEfIGS7FhykvtZoscwXj/XwW+mJY6UbAZk+qtLKFUGWC95kfKXnj8VkxsZQnWBxJemM/q664rGLN5nf+OHZw==" + }, + "Microsoft.CodeCoverage": { + "type": "Transitive", + "resolved": "18.12.0", + "contentHash": "OhOPSaCAQhBJgXF1OrX0uK3eTkwZ1XnM44iGLZplYgKrmgKzQUdv9xtGGaE568RuQ738TlrTJ3pm9aWL5FH7iw==" + }, + "Microsoft.TestPlatform.ObjectModel": { + "type": "Transitive", + "resolved": "18.12.0", + "contentHash": "ilT2o4v/c1joLgsfzS4dYQ71bWAy/RsA6fBY7f5OEUpUsUhwIzoliGeXdS3yctWuy4NZyuSVlO7dPX4ed7R06A==" + }, + "Microsoft.TestPlatform.TestHost": { + "type": "Transitive", + "resolved": "18.12.0", + "contentHash": "WTT912JUqmFa2BkCeXPkMCUpbYOqsbeRfRJdhaIQROx49iokgnGPAlKvXmHWKC9nJwWrHwSQfR+k+Qn7NCxfzw==", + "dependencies": { + "Microsoft.TestPlatform.ObjectModel": "18.12.0" + } + }, + "System.CodeDom": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" + }, + "System.Diagnostics.EventLog": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "lcyUiXTsETK2ALsZrX+nWuHSIQeazhqPphLfaRxzdGaG93+0kELqpgEHtwWOlQe7+jSFnKwaCAgL4kjeZCQJnw==" + }, + "System.Management": { + "type": "Transitive", + "resolved": "6.0.1", + "contentHash": "10J1D0h/lioojphfJ4Fuh5ZUThT/xOVHdV9roGBittKKNP2PMjrvibEdbVTGZcPra1399Ja3tqIJLyQrc5Wmhg==", + "dependencies": { + "System.CodeDom": "6.0.0" + } + }, + "xunit.abstractions": { + "type": "Transitive", + "resolved": "2.0.3", + "contentHash": "pot1I4YOxlWjIb5jmwvvQNbTrZ3lJQ+jUGkGjWE3hEFM0l5gOnBWS+H3qsex68s5cO52g+44vpGzhAt+42vwKg==" + }, + "xunit.analyzers": { + "type": "Transitive", + "resolved": "1.18.0", + "contentHash": "OtFMHN8yqIcYP9wcVIgJrq01AfTxijjAqVDy/WeQVSyrDC1RzBWeQPztL49DN2syXRah8TYnfvk035s7L95EZQ==" + }, + "xunit.assert": { + "type": "Transitive", + "resolved": "2.9.3", + "contentHash": "/Kq28fCE7MjOV42YLVRAJzRF0WmEqsmflm0cfpMjGtzQ2lR5mYVj1/i0Y8uDAOLczkL3/jArrwehfMD0YogMAA==" + }, + "xunit.core": { + "type": "Transitive", + "resolved": "2.9.3", + "contentHash": "BiAEvqGvyme19wE0wTKdADH+NloYqikiU0mcnmiNyXaF9HyHmE6sr/3DC5vnBkgsWaE6yPyWszKSPSApWdRVeQ==", + "dependencies": { + "xunit.extensibility.core": "[2.9.3]", + "xunit.extensibility.execution": "[2.9.3]" + } + }, + "xunit.extensibility.core": { + "type": "Transitive", + "resolved": "2.9.3", + "contentHash": "kf3si0YTn2a8J8eZNb+zFpwfoyvIrQ7ivNk5ZYA5yuYk1bEtMe4DxJ2CF/qsRgmEnDr7MnW1mxylBaHTZ4qErA==", + "dependencies": { + "xunit.abstractions": "2.0.3" + } + }, + "xunit.extensibility.execution": { + "type": "Transitive", + "resolved": "2.9.3", + "contentHash": "yMb6vMESlSrE3Wfj7V6cjQ3S4TXdXpRqYeNEI3zsX31uTsGMJjEw6oD5F5u1cHnMptjhEECnmZSsPxB6ChZHDQ==", + "dependencies": { + "xunit.extensibility.core": "[2.9.3]" + } + }, + "nimblepros.sharedkernel": { + "type": "Project", + "dependencies": { + "Ardalis.GuardClauses": "[6.0.0, )", + "Ardalis.Specification": "[10.0.0, )", + "Mediator.Abstractions": "[3.0.2, )" + } + }, + "Ardalis.GuardClauses": { + "type": "CentralTransitive", + "requested": "[6.0.0, )", + "resolved": "6.0.0", + "contentHash": "VPCr46YYHjcnunQpixMP/LDH56s85oTvu+wJ4zXu4JNYOm76VD0veDX3gneMV8w1XPnwJWUHrWJXrhaPAJM6QA==" + }, + "Ardalis.Specification": { + "type": "CentralTransitive", + "requested": "[10.0.0, )", + "resolved": "10.0.0", + "contentHash": "gzIybrs66DqZPMYwumDHCh3ELPmt77CMOoOma9oPkUaBxtKJfvJtfet4kx4WL9JaVUDDZK3IYq673TPLcU+/FA==" + }, + "Mediator.Abstractions": { + "type": "CentralTransitive", + "requested": "[3.0.2, )", + "resolved": "3.0.2", + "contentHash": "TytjnyN8gLObZBxkM7HHPFJF3LHtk6Y8mHW56ONuXRuVEK6Fmed3f0z79H9TpmoZQP2zQAIS4/0O9R2w0v02qw==" + } + } + } +} \ No newline at end of file