Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions .github/workflows/packages-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,46 @@ name: NuGet Packages Publisher
on:
push:
tags:
- 'v*'
- "v*"

jobs:
publish:
runs-on: ubuntu-latest

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
dotnet nuget push "./artifacts/*.nupkg" \
--source https://api.nuget.org/v3/index.json \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--skip-duplicate
13 changes: 2 additions & 11 deletions CR.Exceptions.AspNet.UnitTests/CrExceptionHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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; }
}
}
2 changes: 1 addition & 1 deletion CR.Exceptions.AspNet/ProblemDetailsExtensionNames.cs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Loading