forked from devonfw/devon4net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge JosepFe/clean_arquitecture_template
Clean arquitecture template
- Loading branch information
Showing
112 changed files
with
2,547 additions
and
618 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Build and Publish NuGet Package | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
project: | ||
description: 'Select the project to build' | ||
required: true | ||
default: 'Path/To/Project1.csproj' | ||
options: | ||
- 'Path/To/Project1.csproj' | ||
- 'Path/To/Project2.csproj' | ||
version_type: | ||
description: 'Select the version type' | ||
required: true | ||
default: 'patch' | ||
options: | ||
- 'major' | ||
- 'minor' | ||
- 'patch' | ||
- 'preview' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: '7.x' | ||
|
||
- name: Get latest version from GitHub Packages | ||
run: | | ||
LATEST_VERSION=$(dotnet nuget list source --source "https://nuget.pkg.github.com/<YOUR_GITHUB_USERNAME>/index.json" | grep "<PackageName>" | head -n 1 | awk '{print $2}') | ||
echo "Latest version: $LATEST_VERSION" | ||
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV | ||
- name: Determine new version | ||
id: version | ||
run: | | ||
VERSION_TYPE="${{ github.event.inputs.version_type }}" | ||
LATEST_VERSION="${{ env.LATEST_VERSION }}" | ||
# Extract major, minor, patch from latest version (assumes format major.minor.patch or major.minor.patch-preview) | ||
MAJOR=$(echo $LATEST_VERSION | cut -d. -f1) | ||
MINOR=$(echo $LATEST_VERSION | cut -d. -f2) | ||
PATCH=$(echo $LATEST_VERSION | cut -d. -f3 | cut -d- -f1) # Removes preview suffix if present | ||
# Increment version based on user input | ||
if [ "$VERSION_TYPE" == "major" ]; then | ||
NEW_VERSION="$((MAJOR + 1)).0.0" | ||
elif [ "$VERSION_TYPE" == "minor" ]; then | ||
NEW_VERSION="$MAJOR.$((MINOR + 1)).0" | ||
elif [ "$VERSION_TYPE" == "patch" ]; then | ||
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | ||
elif [ "$VERSION_TYPE" == "preview" ]; then | ||
PREVIEW_SUFFIX="-preview" | ||
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))$PREVIEW_SUFFIX" | ||
fi | ||
echo "New version: $NEW_VERSION" | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Restore dependencies | ||
run: dotnet restore ${{ github.event.inputs.project }} | ||
|
||
- name: Build project | ||
run: dotnet build ${{ github.event.inputs.project }} --configuration Release --no-restore | ||
|
||
- name: Pack NuGet package | ||
run: dotnet pack ${{ github.event.inputs.project }} --configuration Release --no-build --output ./nuget-packages /p:PackageVersion=${{ env.NEW_VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.suo | ||
*.user | ||
*.sln.docstates | ||
*.env | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...evon4Net.Infrastructure.Common/Application/Attributes/ExceptionHandlingFilterAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Devon4Net.Infrastructure.Common.Exceptions; | ||
|
||
namespace Devon4Net.Infrastructure.Common.Application.Attributes | ||
{ | ||
public class ExceptionHandlingFilterAttribute : ExceptionFilterAttribute | ||
{ | ||
public ExceptionHandlingFilterAttribute() { } | ||
|
||
public override Task OnExceptionAsync(ExceptionContext context) | ||
{ | ||
if (context.Exception.InnerException != null) | ||
Devon4NetLogger.Debug(context.Exception.InnerException?.ToString()!); | ||
|
||
context.Result = context.Exception switch | ||
{ | ||
WebApiException webApiException => HandleContext(webApiException.StatusCode, webApiException.Message, webApiException.ShowMessage), | ||
HttpRequestException httpRequestException => HandleContext((int?)httpRequestException.StatusCode, httpRequestException.Message), | ||
_ => HandleContext(), | ||
}; | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private IActionResult HandleContext(int? statusCode = null, string errorMessage = null, bool showMessage = false) | ||
{ | ||
statusCode ??= StatusCodes.Status500InternalServerError; | ||
|
||
if (!showMessage || statusCode == StatusCodes.Status204NoContent || string.IsNullOrEmpty(errorMessage)) | ||
{ | ||
return new ContentResult | ||
{ | ||
StatusCode = (int)statusCode, | ||
Content = string.Empty, | ||
}; | ||
} | ||
|
||
var response = new { error = errorMessage }; | ||
|
||
return new JsonResult(response) | ||
{ | ||
StatusCode = (int)statusCode, | ||
}; | ||
} | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
...Net.Infrastructure.Common/Application/Middleware/Exception/ExceptionHandlingMiddleware.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.