diff --git a/.github/workflows/packages-publisher.yml b/.github/workflows/packages-publisher.yml index 9de01c1..962170a 100644 --- a/.github/workflows/packages-publisher.yml +++ b/.github/workflows/packages-publisher.yml @@ -3,7 +3,7 @@ name: NuGet Packages Publisher on: push: tags: - - 'v*' + - "v*" jobs: publish: @@ -11,31 +11,38 @@ jobs: permissions: contents: read - packages: write + id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '10.0.x' + dotnet-version: "10.0.x" - - name: Restore - run: dotnet restore + - run: dotnet restore - - name: Build - run: dotnet build -c Release --no-restore + - run: dotnet build -c Release --no-restore - name: Pack + env: + VERSION: ${{ github.ref_name }} run: | - VERSION=${GITHUB_REF_NAME#v} - dotnet pack -c Release -o ./packages -p:PackageVersion=$VERSION --no-build + dotnet pack \ + -c Release \ + --no-build \ + -o ./artifacts \ + -p:PackageVersion=${VERSION#v} + + - name: NuGet Login (Trusted Publishing) + id: login + uses: NuGet/login@v1 + with: + user: YOUR_NUGET_USERNAME - name: Publish run: | - for file in ./packages/*.nupkg; do - dotnet nuget push "$file" \ - --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ - --api-key ${{ secrets.GITHUB_TOKEN }} \ - --skip-duplicate - done \ No newline at end of file + dotnet nuget push "./artifacts/*.nupkg" \ + --source https://api.nuget.org/v3/index.json \ + --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \ + --skip-duplicate \ No newline at end of file diff --git a/CR.Exceptions.AspNet.UnitTests/CrExceptionHandlerTests.cs b/CR.Exceptions.AspNet.UnitTests/CrExceptionHandlerTests.cs index c2c0afc..331cae7 100644 --- a/CR.Exceptions.AspNet.UnitTests/CrExceptionHandlerTests.cs +++ b/CR.Exceptions.AspNet.UnitTests/CrExceptionHandlerTests.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection; using System.Text.Json; using System.Text.Json.Nodes; -using System.Text.Json.Serialization; using Xunit.Abstractions; namespace CR.Exceptions.AspNet.UnitTests; @@ -27,17 +26,13 @@ public CrExceptionHandlerTests(ITestOutputHelper output) [Fact] public Task Should_Return_404_For_NotFoundException() { - return ShouldReturnStatusCode( - new TestNotFoundException(), - StatusCodes.Status404NotFound); + return ShouldReturnStatusCode(new TestNotFoundException(), StatusCodes.Status404NotFound); } [Fact] public Task Should_Return_500_For_UnhandledException() { - return ShouldReturnStatusCode( - new Exception("Something went wrong"), - StatusCodes.Status500InternalServerError); + return ShouldReturnStatusCode(new Exception("Something went wrong"), StatusCodes.Status500InternalServerError); } private async Task ShouldReturnStatusCode(Exception exception, int expectedStatusCode) @@ -117,11 +112,7 @@ private sealed class ProblemDetailsResponse public int? Status { get; set; } public string? Detail { get; set; } public string? Instance { get; set; } - - [JsonPropertyName(ProblemDetailsExtensionNames.TraceId)] public string? TraceId { get; set; } - - [JsonPropertyName(ProblemDetailsExtensionNames.Errors)] public CrError[]? Errors { get; set; } } } \ No newline at end of file diff --git a/CR.Exceptions.AspNet/ProblemDetailsExtensionNames.cs b/CR.Exceptions.AspNet/ProblemDetailsExtensionNames.cs index 02b43a2..9347db4 100644 --- a/CR.Exceptions.AspNet/ProblemDetailsExtensionNames.cs +++ b/CR.Exceptions.AspNet/ProblemDetailsExtensionNames.cs @@ -1,6 +1,6 @@ namespace CR.Exceptions.AspNet; -public static class ProblemDetailsExtensionNames +internal static class ProblemDetailsExtensionNames { public const string Errors = "errors"; public const string TraceId = "traceId";