diff --git a/.changeset/serious-seahorses-enjoy.md b/.changeset/serious-seahorses-enjoy.md new file mode 100644 index 00000000..9963fdd9 --- /dev/null +++ b/.changeset/serious-seahorses-enjoy.md @@ -0,0 +1,5 @@ +--- +'dotnet-sdk': patch +--- + +Publish FeatureBoard dotnet-sdk diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e19fc0e..ba6e7919 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,12 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Setup NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-api-key: ${{ secrets.NUGET_API_KEY }} + nuget-version: '5.x' + - uses: pnpm/action-setup@v2 name: Install pnpm with: @@ -55,6 +61,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Update DotNet SDK version and copyright year + run: | + version=$(node -pe "require('./libs/dotnet-sdk/package.json').version") + currentYear=$(node -pe "new Date().getFullYear()") + csproj_path=libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj + sed -i "s/.*<\/Version>/$version<\/Version>/" $csproj_path + sed -i "s/.*<\/Copyright>/Copyright (c) Arkahna $currentYear<\/Copyright>/" $csproj_path + - name: Push changes run: | pnpm i -r --no-frozen-lockfile @@ -76,7 +90,10 @@ jobs: - name: Package libs run: pnpm package - - name: Release packages + - name: Release NPM packages run: pnpm publish -r --access public env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release NuGet package + run: nuget push dist/libs/dotnet-sdk/FeatureBoard.DotnetSdk.$version.nupkg -Source 'https://api.nuget.org/v3/index.json' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aae24a99..a92c82ba 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -46,6 +46,23 @@ jobs: - name: Tests run: pnpm run test - + + - name: Version command + id: version + run: | + npx changeset version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update DotNet SDK version and copyright year + run: | + version=$(node -pe "require('./libs/dotnet-sdk/package.json').version") + echo "Version: $version" + currentYear=$(node -pe "new Date().getFullYear()") + csproj_path=libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj + sed -i "s/.*<\/Version>/$version<\/Version>/" $csproj_path + sed -i "s/.*<\/Copyright>/Copyright (c) Arkahna $currentYear<\/Copyright>/" $csproj_path + cat $csproj_path + - name: Package libs - run: pnpm package \ No newline at end of file + run: pnpm package diff --git a/libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj b/libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj index ed564518..56dae01f 100644 --- a/libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj +++ b/libs/dotnet-sdk/FeatureBoard.DotnetSdk.csproj @@ -5,6 +5,19 @@ enable enable latest + true + 0.0.1 + FeatureBoard .NET SDK for .NET core and framework applications. + feature toggle flags + Arkahna + Copyright (c) Arkahna 2023 + featureboard-logo.png + README.md + https://github.com/arkahna/featureboard-sdks/blob/main/libs/dotnet-sdk/CHANGELOG.md + https://docs.featurebard.app + https://github.com/arkahna/featureboard-sdks/ + git + MIT @@ -28,6 +41,11 @@ + + + + + True diff --git a/libs/dotnet-sdk/README.md b/libs/dotnet-sdk/README.md index 93bfb5cc..7632ecea 100644 --- a/libs/dotnet-sdk/README.md +++ b/libs/dotnet-sdk/README.md @@ -1,129 +1,24 @@ -## DotNet SDK -## Installation +## What is FeatureBoard? -```powershell -dotnet add package FeatureBoard.DotnetSdk -``` - - -## Setup - -1) Create a Features model -Note that FeatureKeyName can be used here to apply the correct feature key to a property, otherwise feature board will do it's best to convert the property to a kebab case key. -```csharp -using FeatureBoard.DotnetSdk.Models; - -public class WeatherFeatures : IFeatures -{ - [FeatureKeyName("weather-imperial")] - public bool WeatherImperial { get; set; } -} -``` - -2) Implement the audiance provider. -This should provide the audiance of the current user or application context and could pull from the users token or app settings etc. -```csharp -using FeatureBoard.DotnetSdk; - -public class ClaimsAudienceProvider : IAudienceProvider -{ - public List AudienceKeys { get; } - - public ClaimsAudienceProvider(IHttpContextAccessor contextAccessor) - { - AudienceKeys = contextAccessor.HttpContext?.User.Claims - .Where(x => x.Type == "audience") - .Select(x => x.Value).ToList() ?? new List(); - } -} -``` - - -3) Register the provider in `program.cs` -```csharp -// Register feature board -builder.Services.AddFeatureBoard() - .WithPollingUpdateStrategy(); -``` +FeatureBoard is the future of Feature Toggling and is tailored for SaaS teams on the hunt for a simplified yet highly potent feature toggling solution. FeatureBoard enhances team productivity by allowing everyone to manage software features seamlessly, not just developers. -4) Add any required middleware -```csharp -// Add feature board middleware -app.UseFeatureBoard(); -``` - -5) Add the enviroment key to your appsettings.json file -```json -{ - .... - "AllowedHosts": "*", - "FeatureBoardOptions": { - "EnvironmentApiKey": "YOUR KEY HERE" - } -} -``` - - - -## Usage -```csharp -using FeatureBoard.DotnetSdk; -using FeatureBoardSdks.Examples.DotnetApi.Models; -using Microsoft.AspNetCore.Mvc; - -namespace FeatureBoardSdks.Examples.DotnetApi.Controllers; - -[ApiController] -[Route("[controller]")] -public class WeatherForecastController : ControllerBase -{ +## How do I get started? - private readonly IFeatureBoardClient _featureBoardClient; +To get started checkout our [getting started guide](https://docs.featureboard.app). - public WeatherForecastController(ILogger logger, IFeatureBoardClient featureBoardClient) - { - _featureBoardClient = featureBoardClient; - } +## Install FeatureBoard .Net SDK - [HttpGet(Name = "GetWeatherForecast")] - public async Task> Get() - { - if (_featureBoardClient.GetFeatureValue(features => features.WeatherImperial, false)) - { - // Return Fahrenheit - } - else - { - // Return Celsius - } - } -} +FeatureBoard .Net SDK is installed from NuGet. +```powershell +dotnet add package FeatureBoard.DotnetSdk ``` +## Setup and example -## External State Store -You can create an external state to provide state in case that feature board is unavilable by implementing `IFeatureBoardExternalState` +How to setup and use FeatureBoard .Net SDK can be found in our [documentation](https://docs.featureboard.app/sdks/dotnet-sdk/). -```csharp -using FeatureBoard.DotnetSdk.Models; -using FeatureBoard.DotnetSdk.States; +## Release notes -public class MyExternalState: IFeatureBoardExternalState -{ - public Task> GetState(CancellationToken cancellationToken) - {....} - - public Task UpdateState(Dictionary? features, CancellationToken cancellationToken) - {....} -} -``` - -And registering it in `program.cs` - -```csharp -builder.Services.AddFeatureBoard() - .WithPollingUpdateStrategy() - .WithExternalState(); -``` +Our changelog [can be found on GitHub](https://github.com/arkahna/featureboard-sdks/blob/main/libs/dotnet-sdk/CHANGELOG.md). diff --git a/libs/dotnet-sdk/assets/featureboard-logo.png b/libs/dotnet-sdk/assets/featureboard-logo.png new file mode 100644 index 00000000..2d8f7298 Binary files /dev/null and b/libs/dotnet-sdk/assets/featureboard-logo.png differ diff --git a/libs/dotnet-sdk/package.json b/libs/dotnet-sdk/package.json index 92d07c67..21aa5161 100644 --- a/libs/dotnet-sdk/package.json +++ b/libs/dotnet-sdk/package.json @@ -1,5 +1,5 @@ { - "name": "dontnet-sdk", - "version": "1.0.0", + "name": "dotnet-sdk", + "version": "0.0.1", "private": true -} +} \ No newline at end of file diff --git a/libs/dotnet-sdk/project.json b/libs/dotnet-sdk/project.json index 8394b4a4..40dee55e 100644 --- a/libs/dotnet-sdk/project.json +++ b/libs/dotnet-sdk/project.json @@ -22,7 +22,17 @@ }, "lint": { "executor": "@nx-dotnet/core:format" + }, + "package": { + "executor": "@nx-dotnet/core:build", + "outputs": [ + "{workspaceRoot}/dist/libs/dotnet-sdk" + ], + "options": { + "configuration": "Release", + "noDependencies": true + } } }, "tags": [] -} +} \ No newline at end of file