diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index eba58a5..9042237 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -42,3 +42,104 @@ jobs: run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normal + add_tag: + runs-on: ubuntu-latest + needs: + - build + if: >- + needs.build.result == 'success' && + + github.event.pull_request.merged && + + github.event.pull_request.base.ref == 'main' && + + startsWith(github.event.pull_request.title, 'RELEASES:') && + + contains(github.event.pull_request.labels.*.name, 'RELEASES') + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT_FOR_TAGGING }} + - name: Configure Git + run: >- + git config user.name "GitHub Action" + + git config user.email "action@github.com" + - name: Extract Version + id: extract_version + run: > + # Running on Linux/Unix + + sudo apt-get install xmlstarlet + + version_number=$(xmlstarlet sel -t -v "//Version" -n STX.EFxceptions.Core/STX.EFxceptions.Core.csproj) + + echo "$version_number" + + echo "version_number<> $GITHUB_OUTPUT + + echo "$version_number" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + shell: bash + - name: Display Version + run: 'echo "Version number: ${{ steps.extract_version.outputs.version_number }}"' + - name: Extract Package Release Notes + id: extract_package_release_notes + run: > + # Running on Linux/Unix + + sudo apt-get install xmlstarlet + + package_release_notes=$(xmlstarlet sel -t -v "//PackageReleaseNotes" -n STX.EFxceptions.Core/STX.EFxceptions.Core.csproj) + + echo "$package_release_notes" + + echo "package_release_notes<> $GITHUB_OUTPUT + + echo "$package_release_notes" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + shell: bash + - name: Display Package Release Notes + run: 'echo "Package Release Notes: ${{ steps.extract_package_release_notes.outputs.package_release_notes }}"' + - name: Create GitHub Tag + run: >- + git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}" + + git push origin --tags + - name: Create GitHub Release + uses: actions/create-release@v1 + with: + tag_name: v${{ steps.extract_version.outputs.version_number }} + release_name: Release - v${{ steps.extract_version.outputs.version_number }} + body: >- + ## Release - v${{ steps.extract_version.outputs.version_number }} + + + ### Release Notes + + ${{ steps.extract_package_release_notes.outputs.package_release_notes }} + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }} + publish: + runs-on: ubuntu-latest + needs: + - add_tag + if: needs.add_tag.result == 'success' + steps: + - name: Check out + uses: actions/checkout@v3 + - name: Setup .Net + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.201 + - name: Restore + run: dotnet restore + - name: Build + run: dotnet build --no-restore --configuration Release + - name: Pack NuGet Package + run: dotnet pack --configuration Release --include-symbols + - name: Push NuGet Package + run: dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ACCESS }} --skip-duplicate diff --git a/STX.EFxceptions.Interfaces/Brokers/DbErrorBroker/IDbErrorBroker.cs b/STX.EFxceptions.Abstractions/Brokers/DbErrorBroker/IDbErrorBroker.cs similarity index 69% rename from STX.EFxceptions.Interfaces/Brokers/DbErrorBroker/IDbErrorBroker.cs rename to STX.EFxceptions.Abstractions/Brokers/DbErrorBroker/IDbErrorBroker.cs index 4bfdfc2..5307b04 100644 --- a/STX.EFxceptions.Interfaces/Brokers/DbErrorBroker/IDbErrorBroker.cs +++ b/STX.EFxceptions.Abstractions/Brokers/DbErrorBroker/IDbErrorBroker.cs @@ -1,10 +1,10 @@ // ---------------------------------------------------------------------------------- -// Copyright(c) The Standard Organization: A coalition of the Good-Hearted Engineers +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- using System; -namespace STX.EFxceptions.Interfaces.Brokers.DbErrorBroker +namespace STX.EFxceptions.Abstractions.Brokers.DbErrorBroker { public interface IDbErrorBroker where TException : Exception { diff --git a/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyException.cs b/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyException.cs new file mode 100644 index 0000000..db7a62f --- /dev/null +++ b/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyException.cs @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Microsoft.EntityFrameworkCore; + +namespace STX.EFxceptions.Abstractions.Models.Exceptions +{ + public class DuplicateKeyException : DbUpdateException + { + public DuplicateKeyException(string message) : base(message) { } + } +} diff --git a/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyWithUniqueIndexException.cs b/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyWithUniqueIndexException.cs new file mode 100644 index 0000000..fe875be --- /dev/null +++ b/STX.EFxceptions.Abstractions/Models/Exceptions/DuplicateKeyWithUniqueIndexException.cs @@ -0,0 +1,24 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Microsoft.EntityFrameworkCore; + +namespace STX.EFxceptions.Abstractions.Models.Exceptions +{ + public class DuplicateKeyWithUniqueIndexException : DbUpdateException + { + public string DuplicateKeyValue { get; } + + public DuplicateKeyWithUniqueIndexException(string message) + : base(message) + { + string[] subStrings = message.Split('(', ')'); + + if (subStrings.Length == 3) + { + DuplicateKeyValue = subStrings[1]; + } + } + } +} diff --git a/STX.EFxceptions.Abstractions/Models/Exceptions/ForeignKeyConstraintConflictException.cs b/STX.EFxceptions.Abstractions/Models/Exceptions/ForeignKeyConstraintConflictException.cs new file mode 100644 index 0000000..cd56e0f --- /dev/null +++ b/STX.EFxceptions.Abstractions/Models/Exceptions/ForeignKeyConstraintConflictException.cs @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Microsoft.EntityFrameworkCore; + +namespace STX.EFxceptions.Abstractions.Models.Exceptions +{ + public class ForeignKeyConstraintConflictException : DbUpdateException + { + public ForeignKeyConstraintConflictException(string message) : base(message) { } + } +} diff --git a/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidColumnNameException.cs b/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidColumnNameException.cs new file mode 100644 index 0000000..4633c06 --- /dev/null +++ b/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidColumnNameException.cs @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Microsoft.EntityFrameworkCore; + +namespace STX.EFxceptions.Abstractions.Models.Exceptions +{ + public class InvalidColumnNameException : DbUpdateException + { + public InvalidColumnNameException(string message) : base(message) { } + } +} diff --git a/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidObjectNameException.cs b/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidObjectNameException.cs new file mode 100644 index 0000000..b0a1dc0 --- /dev/null +++ b/STX.EFxceptions.Abstractions/Models/Exceptions/InvalidObjectNameException.cs @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Microsoft.EntityFrameworkCore; + +namespace STX.EFxceptions.Abstractions.Models.Exceptions +{ + public class InvalidObjectNameException : DbUpdateException + { + public InvalidObjectNameException(string message) : base(message) { } + } +} diff --git a/STX.EFxceptions.Interfaces/STX.EFxceptions.Interfaces.csproj b/STX.EFxceptions.Abstractions/STX.EFxceptions.Abstractions.csproj similarity index 78% rename from STX.EFxceptions.Interfaces/STX.EFxceptions.Interfaces.csproj rename to STX.EFxceptions.Abstractions/STX.EFxceptions.Abstractions.csproj index 4131730..a01b579 100644 --- a/STX.EFxceptions.Interfaces/STX.EFxceptions.Interfaces.csproj +++ b/STX.EFxceptions.Abstractions/STX.EFxceptions.Abstractions.csproj @@ -4,16 +4,16 @@ net8.0 disable disable - STX.EFxceptions.Interfaces - STX.EFxceptions.Interfaces - STX.EFxceptions.Interfaces + STX.EFxceptions.Abstractions + STX.EFxceptions.Abstractions + STX.EFxceptions.Abstractions The Standard Community The Standard Community - A Standardized .NET library that provides interfaces for the core components to capture exceptions thrown by EntityFramework and converts them into meaningful exceptions... + A Standardized .NET library that provides abstractions for the core components to capture exceptions thrown by EntityFramework and converts them into meaningful exceptions... The Standard Community 2024 (c) EFxceptions.png - https://github.com/The-Standard-Organization/STX.EFxceptions - https://github.com/The-Standard-Organization/STX.EFxceptions + https://github.com/The-Standard-Organization/STX.EFxceptions.Core + https://github.com/The-Standard-Organization/STX.EFxceptions.Core git .NET; EF; Entity Framework; Exceptions; The Standard diff --git a/STX.EFxceptions.Interfaces/Services/EFxceptions/IEFxceptionService.cs b/STX.EFxceptions.Abstractions/Services/EFxceptions/IEFxceptionService.cs similarity index 70% rename from STX.EFxceptions.Interfaces/Services/EFxceptions/IEFxceptionService.cs rename to STX.EFxceptions.Abstractions/Services/EFxceptions/IEFxceptionService.cs index db0e394..7d300c9 100644 --- a/STX.EFxceptions.Interfaces/Services/EFxceptions/IEFxceptionService.cs +++ b/STX.EFxceptions.Abstractions/Services/EFxceptions/IEFxceptionService.cs @@ -1,10 +1,10 @@ // ---------------------------------------------------------------------------------- -// Copyright(c) The Standard Organization: A coalition of the Good-Hearted Engineers +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- using Microsoft.EntityFrameworkCore; -namespace STX.EFxceptions.Interfaces.Services.EFxceptions +namespace STX.EFxceptions.Abstractions.Services.EFxceptions { public interface IEFxceptionService { diff --git a/STX.EFxceptions.Core.sln b/STX.EFxceptions.Core.sln index b76b7ee..163f782 100644 --- a/STX.EFxceptions.Core.sln +++ b/STX.EFxceptions.Core.sln @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STX.EFxceptions.Identity.Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STX.EFxceptions.Infrastructure.Build", "STX.EFxceptions.Infrastructure.Build\STX.EFxceptions.Infrastructure.Build.csproj", "{C35BF826-899D-406B-96BC-499297A11A34}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STX.EFxceptions.Interfaces", "STX.EFxceptions.Interfaces\STX.EFxceptions.Interfaces.csproj", "{9AB17DCF-0E92-42B1-9B76-12C07DF23F10}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STX.EFxceptions.Abstractions", "STX.EFxceptions.Abstractions\STX.EFxceptions.Abstractions.csproj", "{9AB17DCF-0E92-42B1-9B76-12C07DF23F10}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/STX.EFxceptions.Core/DbContextBase.cs b/STX.EFxceptions.Core/DbContextBase.cs index d983c34..b294467 100644 --- a/STX.EFxceptions.Core/DbContextBase.cs +++ b/STX.EFxceptions.Core/DbContextBase.cs @@ -1,13 +1,13 @@ // ---------------------------------------------------------------------------------- -// Copyright(c) The Standard Organization: A coalition of the Good-Hearted Engineers +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- using System; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using STX.EFxceptions.Interfaces.Brokers.DbErrorBroker; -using STX.EFxceptions.Interfaces.Services.EFxceptions; +using STX.EFxceptions.Abstractions.Brokers.DbErrorBroker; +using STX.EFxceptions.Abstractions.Services.EFxceptions; namespace STX.EFxceptions.Core { diff --git a/STX.EFxceptions.Core/STX.EFxceptions.Core.csproj b/STX.EFxceptions.Core/STX.EFxceptions.Core.csproj index 8a54dca..aeacd30 100644 --- a/STX.EFxceptions.Core/STX.EFxceptions.Core.csproj +++ b/STX.EFxceptions.Core/STX.EFxceptions.Core.csproj @@ -12,8 +12,8 @@ A Standardized .NET library that provides an abstract DBContext to capture exceptions thrown by EntityFramework and converts them into meaningful exceptions... The Standard Community 2024 (c) EFxceptions.png - https://github.com/The-Standard-Organization/STX.EFxceptions - https://github.com/The-Standard-Organization/STX.EFxceptions + https://github.com/The-Standard-Organization/STX.EFxceptions.Core + https://github.com/The-Standard-Organization/STX.EFxceptions.Core git .NET; EF; Entity Framework; Exceptions; The Standard @@ -50,7 +50,7 @@ - + diff --git a/STX.EFxceptions.Identity.Core/IndentityDbContextBase.cs b/STX.EFxceptions.Identity.Core/IndentityDbContextBase.cs index e9a57ea..4dadab0 100644 --- a/STX.EFxceptions.Identity.Core/IndentityDbContextBase.cs +++ b/STX.EFxceptions.Identity.Core/IndentityDbContextBase.cs @@ -1,5 +1,5 @@ // ---------------------------------------------------------------------------------- -// Copyright(c) The Standard Organization: A coalition of the Good-Hearted Engineers +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- using System; @@ -8,12 +8,12 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -using STX.EFxceptions.Interfaces.Brokers.DbErrorBroker; -using STX.EFxceptions.Interfaces.Services.EFxceptions; +using STX.EFxceptions.Abstractions.Brokers.DbErrorBroker; +using STX.EFxceptions.Abstractions.Services.EFxceptions; namespace STX.EFxceptions.Identity.Core { - public class IdentityDbContextBase : IdentityDbContext + public abstract class IdentityDbContextBase : IdentityDbContext where TUser : IdentityUser { protected IdentityDbContextBase() : base() diff --git a/STX.EFxceptions.Identity.Core/STX.EFxceptions.Identity.Core.csproj b/STX.EFxceptions.Identity.Core/STX.EFxceptions.Identity.Core.csproj index 43b31d9..5f08190 100644 --- a/STX.EFxceptions.Identity.Core/STX.EFxceptions.Identity.Core.csproj +++ b/STX.EFxceptions.Identity.Core/STX.EFxceptions.Identity.Core.csproj @@ -12,8 +12,8 @@ A Standardized .NET library that provides an abstract DBContext that implements AspNetCore.Identity to capture exceptions thrown by EntityFramework and converts them into meaningful exceptions... The Standard Community 2024 (c) EFxceptions.png - https://github.com/The-Standard-Organization/STX.EFxceptions - https://github.com/The-Standard-Organization/STX.EFxceptions + https://github.com/The-Standard-Organization/STX.EFxceptions.Core + https://github.com/The-Standard-Organization/STX.EFxceptions.Core git .NET; EF; Entity Framework; Exceptions; The Standard @@ -49,7 +49,7 @@ - + diff --git a/STX.EFxceptions.Infrastructure.Build/Program.cs b/STX.EFxceptions.Infrastructure.Build/Program.cs index afa797b..76bc84e 100644 --- a/STX.EFxceptions.Infrastructure.Build/Program.cs +++ b/STX.EFxceptions.Infrastructure.Build/Program.cs @@ -82,6 +82,22 @@ static void Main(string[] args) } } } + }, + { + "add_tag", + new TagJob( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "build", + projectRelativePath: "STX.EFxceptions.Core/STX.EFxceptions.Core.csproj", + githubToken: "${{ secrets.PAT_FOR_TAGGING }}", + branchName: branchName) + }, + { + "publish", + new PublishJob( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "add_tag", + nugetApiKey: "${{ secrets.NUGET_ACCESS }}") } } };