diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index b7c61552..08ceca2b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -193,6 +193,35 @@ jobs: if: contains(matrix.architecture, 'win-') run: | $(Get-FileHash ./${{ env.release }}/dev-proxy-installer-${{ matrix.architecture }}-${{ github.ref_name }}.exe -Algorithm SHA256).Hash + publish_nuget: + name: Publish to NuGet + needs: [publish_binaries] + runs-on: ubuntu-latest + environment: + name: gh_releases + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 + with: + dotnet-version: 10.0.x + - name: Get version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + - name: Pack + run: > + dotnet pack ./DevProxy.Abstractions/DevProxy.Abstractions.csproj + -c Release + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + -p:Version=${{ steps.get_version.outputs.VERSION }} + -o ./nupkg + - name: Push to NuGet + run: > + dotnet nuget push ./nupkg/DevProxy.Abstractions.${{ steps.get_version.outputs.VERSION }}.nupkg + --api-key ${{ secrets.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --skip-duplicate create_release: name: Create Release needs: [publish_binaries] diff --git a/DevProxy.Abstractions/DevProxy.Abstractions.csproj b/DevProxy.Abstractions/DevProxy.Abstractions.csproj index dc9f818f..30ae57d6 100644 --- a/DevProxy.Abstractions/DevProxy.Abstractions.csproj +++ b/DevProxy.Abstractions/DevProxy.Abstractions.csproj @@ -10,8 +10,27 @@ true true AllEnabledByDefault + true + DevProxy.Abstractions + Dev Proxy Abstractions + Dev Proxy + Abstractions for building custom Dev Proxy plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path. + devproxy;api;proxy;testing;mocking;plugins + MIT + https://aka.ms/devproxy + https://github.com/dotnet/dev-proxy + git + README.md + icon.png + + NU5104 + + + + + diff --git a/DevProxy.Abstractions/README.md b/DevProxy.Abstractions/README.md new file mode 100644 index 00000000..6e41bd96 --- /dev/null +++ b/DevProxy.Abstractions/README.md @@ -0,0 +1,42 @@ +# Dev Proxy Abstractions + +[![NuGet Version](https://img.shields.io/nuget/v/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions) +[![NuGet Downloads](https://img.shields.io/nuget/dt/DevProxy.Abstractions)](https://www.nuget.org/packages/DevProxy.Abstractions) + +Abstractions for building custom [Dev Proxy](https://aka.ms/devproxy) plugins. Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path. + +## What This Package Does + +This package provides the interfaces, base classes, and models needed to build custom Dev Proxy plugins. Use it when you want to extend Dev Proxy with your own functionality. + +## Usage + +Create a new class library project and add a reference to this package: + +```bash +dotnet add package DevProxy.Abstractions +``` + +Then, implement the `IPlugin` interface or inherit from `BasePlugin`: + +```csharp +using DevProxy.Abstractions.Plugins; +using DevProxy.Abstractions.Proxy; +using Microsoft.Extensions.Logging; + +public class MyPlugin( + ILogger logger, + ISet urlsToWatch) : BasePlugin(logger, urlsToWatch) +{ + public override string Name => nameof(MyPlugin); + + public override async Task BeforeRequestAsync( + ProxyRequestArgs e, + CancellationToken cancellationToken) + { + // Your custom logic here + } +} +``` + +For more information, see the [Dev Proxy documentation](https://aka.ms/devproxy/docs). diff --git a/DevProxy.Plugins/DevProxy.Plugins.csproj b/DevProxy.Plugins/DevProxy.Plugins.csproj index fe23cfe0..c4b8ec3d 100644 --- a/DevProxy.Plugins/DevProxy.Plugins.csproj +++ b/DevProxy.Plugins/DevProxy.Plugins.csproj @@ -11,6 +11,7 @@ true true AllEnabledByDefault + false CS1998 diff --git a/DevProxy/DevProxy.csproj b/DevProxy/DevProxy.csproj index bc3f80ca..00c4dacc 100644 --- a/DevProxy/DevProxy.csproj +++ b/DevProxy/DevProxy.csproj @@ -17,6 +17,7 @@ true true AllEnabledByDefault + false