diff --git a/.github/workflows/publish_nuget.yml b/.github/workflows/publish_nuget.yml index bf9f73b..d3c8dc9 100644 --- a/.github/workflows/publish_nuget.yml +++ b/.github/workflows/publish_nuget.yml @@ -10,6 +10,12 @@ on: description: 'NuGet package version to publish (optional, will read from project if not set)' required: false type: string + workflow_call: + inputs: + version: + description: 'NuGet package version to publish (optional, will read from project if not set)' + required: false + type: string jobs: publish: @@ -38,7 +44,9 @@ jobs: --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" - name: Restore dependencies - run: dotnet restore + run: | + dotnet restore DataPlane.Sdk.Core/DataPlane.Sdk.Core.csproj + dotnet restore DataPlane.Sdk.Api/DataPlane.Sdk.Api.csproj - name: Get version id: get_version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f36a9a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,109 @@ +name: Create Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (e.g., 1.0.0 or v1.0.0)' + required: true + type: string + +jobs: + create-tag: + name: Create Tag + runs-on: ubuntu-latest + + permissions: + contents: write + + outputs: + version: ${{ steps.normalize_version.outputs.version }} + tag: ${{ steps.normalize_version.outputs.tag }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Normalize version + id: normalize_version + run: | + version="${{ github.event.inputs.version }}" + # Remove 'v' prefix if present + version="${version#v}" + # Add 'v' prefix for tag + tag="v${version}" + echo "version=$version" >> $GITHUB_OUTPUT + echo "tag=$tag" >> $GITHUB_OUTPUT + + - name: Check if tag exists + run: | + if git rev-parse "${{ steps.normalize_version.outputs.tag }}" >/dev/null 2>&1; then + echo "Error: Tag ${{ steps.normalize_version.outputs.tag }} already exists" + exit 1 + fi + + - name: Update version in .csproj files + run: | + # Find all .csproj files with tags and update them + find . -name "*.csproj" -type f | while read file; do + if grep -q "" "$file"; then + sed -i.bak "s|.*|${{ steps.normalize_version.outputs.version }}|g" "$file" + rm "${file}.bak" + echo "Updated version in $file" + fi + done + + - name: Commit version bump + run: | + git add "*.csproj" + if git diff --cached --quiet; then + echo "No version changes to commit" + else + git commit -m "chore: bump version to ${{ steps.normalize_version.outputs.version }}" + git push origin HEAD + fi + + - name: Create and push tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "${{ steps.normalize_version.outputs.tag }}" -m "Release ${{ steps.normalize_version.outputs.tag }}" + git push origin "${{ steps.normalize_version.outputs.tag }}" + + publish-nuget: + name: Publish NuGet Packages + needs: create-tag + uses: ./.github/workflows/publish_nuget.yml + with: + version: ${{ needs.create-tag.outputs.version }} + permissions: + packages: write + contents: read + + create-release: + name: Create GitHub Release + needs: [create-tag, publish-nuget] + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ needs.create-tag.outputs.tag }} + name: Release ${{ needs.create-tag.outputs.tag }} + generateReleaseNotes: true + body: | + NuGet packages published to GitHub Packages. + + ### Installation + ```bash + dotnet add package DataPlane.Sdk.Core --version ${{ needs.create-tag.outputs.version }} + dotnet add package DataPlane.Sdk.Api --version ${{ needs.create-tag.outputs.version }} + ``` + draft: false + prerelease: false diff --git a/README.md b/README.md index 6502abf..e2d970f 100644 --- a/README.md +++ b/README.md @@ -7,21 +7,23 @@ Planes via the Data Plane Signaling API (DPS API). The SDK includes callbacks on and mutual authentication and authorization scaffolding. + * [Dataplane SDK .NET](#dataplane-sdk-net) - * [1. Installation and requirements](#1-installation-and-requirements) - * [2. Usage (with API)](#2-usage-with-api) - * [2.1 Configuring the SDK](#21-configuring-the-sdk) - * [2.2 Configuring SDK services](#22-configuring-sdk-services) - * [2.3 Setting up authentication for incoming requests](#23-setting-up-authentication-for-incoming-requests) - * [2.4 Setting up authorization of incoming HTTP requests](#24-setting-up-authorization-of-incoming-http-requests) - * [2.5 Setting up authorization of outgoing HTTP requests](#25-setting-up-authorization-of-outgoing-http-requests) - * [Named vs unnamed `HttpClient`](#named-vs-unnamed-httpclient) - * [3. Usage (core only)](#3-usage-core-only) - * [4. Required configuration](#4-required-configuration) - * [5. DataPlane Signaling API callbacks](#5-dataplane-signaling-api-callbacks) - * [6. In-memory vs PostgreSQL persistence](#6-in-memory-vs-postgresql-persistence) - * [7. Using the Control API](#7-using-the-control-api) - * [8. Reporting issues and bugs](#8-reporting-issues-and-bugs) + * [1. Installation and requirements](#1-installation-and-requirements) + * [2. Usage (with API)](#2-usage-with-api) + * [2.1 Configuring the SDK](#21-configuring-the-sdk) + * [2.2 Configuring SDK services](#22-configuring-sdk-services) + * [2.3 Setting up authentication for incoming requests](#23-setting-up-authentication-for-incoming-requests) + * [2.4 Setting up authorization of incoming HTTP requests](#24-setting-up-authorization-of-incoming-http-requests) + * [2.5 Setting up authorization of outgoing HTTP requests](#25-setting-up-authorization-of-outgoing-http-requests) + * [Named vs unnamed `HttpClient`](#named-vs-unnamed-httpclient) + * [3. Usage (core only)](#3-usage-core-only) + * [4. Required configuration](#4-required-configuration) + * [5. DataPlane Signaling API callbacks](#5-dataplane-signaling-api-callbacks) + * [6. In-memory vs PostgreSQL persistence](#6-in-memory-vs-postgresql-persistence) + * [7. Using the Control API](#7-using-the-control-api) + * [8. Reporting issues and bugs](#8-reporting-issues-and-bugs) + ## 1. Installation and requirements @@ -219,7 +221,7 @@ In situations where the built-in API server for DataPlane Signaling cannot be us `DataPlane.Sdk.Core` module. While this will forego all API controllers, authentication and authorization, it will still provide core services and persistence. To do that, add the `DataPlane.Sdk.Core` package to your .NET project: -`dotnet add package DataPlane.Sdk.Core --version 0.0.1-alpha`. +`dotnet add package DataPlane.Sdk.Core --version `. Depending on the type of project (console, webapi) an `IHost` may or may not be available. If it is, client code can still utilize the dependency injection facilities built into the SDK by calling the `AddSdkServices(sdk)` extension