diff --git a/.github/config/gitversion.yml b/.github/config/gitversion.yml new file mode 100644 index 0000000..57caa9e --- /dev/null +++ b/.github/config/gitversion.yml @@ -0,0 +1,9 @@ +next-version: 1.0.0 +mode: ContinuousDeployment +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch + +branches: + main: + regex: ^main$ + increment: Patch \ No newline at end of file diff --git a/.github/workflows/pull_request_dev.yml b/.github/workflows/pull_request_dev.yml new file mode 100644 index 0000000..f6adf01 --- /dev/null +++ b/.github/workflows/pull_request_dev.yml @@ -0,0 +1,22 @@ +name: Build NuGet package on dev branch pull request + +on: + pull_request: + branches: + - "dev" + paths: + - "TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build \ No newline at end of file diff --git a/.github/workflows/pull_request_main.yml b/.github/workflows/pull_request_main.yml new file mode 100644 index 0000000..0f1908d --- /dev/null +++ b/.github/workflows/pull_request_main.yml @@ -0,0 +1,22 @@ +name: Build NuGet package on main branch pull request + +on: + pull_request: + branches: + - "main" + paths: + - "TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build diff --git a/.github/workflows/push_dev.yml b/.github/workflows/push_dev.yml new file mode 100644 index 0000000..c221fea --- /dev/null +++ b/.github/workflows/push_dev.yml @@ -0,0 +1,22 @@ +name: Build NuGet package on dev branch push + +on: + push: + branches: + - "dev" + paths: + - "TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build \ No newline at end of file diff --git a/.github/workflows/push_main.yml b/.github/workflows/push_main.yml new file mode 100644 index 0000000..a819c17 --- /dev/null +++ b/.github/workflows/push_main.yml @@ -0,0 +1,72 @@ +name: Build NuGet package on main branch push + +on: + push: + branches: + - "main" + paths: + - "TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi**" + +jobs: + build: + name: Build and pack + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build + - name: Setup GitVersion + uses: gittools/actions/gitversion/setup@v4.2.0 + with: + versionSpec: 6.4.x + - name: Determine version + uses: gittools/actions/gitversion/execute@v4.2.0 + id: gitversion + with: + configFilePath: ./.github/config/gitversion.yml + - name: Create NuGet package + run: dotnet pack -c Release -p:Version=${{steps.gitversion.outputs.SemVer}} -p:PackageVersion=${{steps.gitversion.outputs.SemVer}} --output ${{ github.workspace}}/nuget + - name: Upload artifact + uses: actions/upload-artifact@v6 + with: + name: nuget + path: ${{ github.workspace}}/nuget/*.nupkg + outputs: + version: ${{ steps.gitversion.outputs.SemVer }} + publish: + name: Publish + permissions: write-all + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v6 + with: + name: nuget + path: ${{ github.workspace}}/nuget + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Add source + run: dotnet nuget add source --username TimetableDesigner --password ${{secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/TimetableDesigner/index.json" + - name: Publish + run: dotnet nuget push ${{ github.workspace}}/nuget/*.nupkg --source "github" --api-key ${{ secrets.NUGET_REGISTRY_API_KEY }} --skip-duplicate + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{needs.build.outputs.version}} + release_name: ${{needs.build.outputs.version}} + draft: false + prerelease: false + + diff --git a/.gitignore b/.gitignore index ce89292..fd3d8cd 100644 --- a/.gitignore +++ b/.gitignore @@ -416,3 +416,5 @@ FodyWeavers.xsd *.msix *.msm *.msp + +.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5ef464c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Mateusz Skoczek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.slnx b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.slnx new file mode 100644 index 0000000..dea0161 --- /dev/null +++ b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.slnx @@ -0,0 +1,3 @@ + + + diff --git a/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/ServiceCollectionExtensions.cs b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..cfe95e0 --- /dev/null +++ b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/ServiceCollectionExtensions.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi; + +public static class ServiceCollectionExtensions +{ + public static IServiceCollection AddEventQueue(this IServiceCollection services, Action configuration) where T : EventQueue, new() + { + T builder = new T(); + configuration(builder); + builder.Setup(services); + return services; + } +} \ No newline at end of file diff --git a/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.csproj b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.csproj new file mode 100644 index 0000000..d330218 --- /dev/null +++ b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi.csproj @@ -0,0 +1,20 @@ + + + + net10.0 + enable + enable + + TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi + Mateusz Skoczek + https://github.com/TimetableDesigner/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi + icon.png + https://github.com/TimetableDesigner/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi + + + + + + + + diff --git a/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/WebApplicationExtensions.cs b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/WebApplicationExtensions.cs new file mode 100644 index 0000000..bd19887 --- /dev/null +++ b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/WebApplicationExtensions.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi; + +public static class WebApplicationExtensions +{ + public static void AddEventHandler(this WebApplication app, Func handler) where T : class + { + IEventQueueSubscriber subscriber = app.Services.GetService()!; + subscriber.Subscribe(handler); + } +} \ No newline at end of file diff --git a/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/icon.png b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/icon.png new file mode 100644 index 0000000..98f0c54 Binary files /dev/null and b/TimetableDesigner.Backend.Events.Extensions.AspNetCore.OpenApi/icon.png differ