diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1a75434 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.100 + - name: Build + run: dotnet build --configuration Release \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3af9d84 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.100 + - name: Build + run: dotnet build --configuration Release + - name: Pack + working-directory: src/Blazor.Extensions.SignalR + run: dotnet pack --configuration Release + - name: Push + working-directory: src/Blazor.Extensions.SignalR/bin/Release + run: | + dotnet nuget push Blazor.Extensions.SignalR.*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json + - name: Create Release + uses: actions/create-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.vsts-ci.yml b/.vsts-ci.yml deleted file mode 100644 index 1130fa6..0000000 --- a/.vsts-ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -queue: 'Hosted VS2017' - -variables: - buildConfiguration: 'Release' - -steps: - - - task: DotNetCoreInstaller@0 - inputs: - packageType: 'sdk' - version: 3.0.100-preview9-014004 - - - task: DotNetCoreCLI@2 - inputs: - command: 'restore' - projects: '**/*.csproj' - - - task: DotNetCoreCLI@2 - inputs: - command: 'build' - projects: '**/*.csproj' - arguments: '--configuration $(buildConfiguration)' - - - task: DotNetCoreCLI@2 - inputs: - command: pack - packagesToPack: 'src/Blazor.Extensions.SignalR/*.csproj' - configuration: '$(buildConfiguration)' - versioningScheme: byPrereleaseNumber - majorVersion: '0' - minorVersion: '1' - patchVersion: '0' \ No newline at end of file diff --git a/.vsts-release.yml b/.vsts-release.yml deleted file mode 100644 index e5936c0..0000000 --- a/.vsts-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -queue: 'Hosted VS2017' - -variables: - buildConfiguration: 'Release' - -steps: - - - task: DotNetCoreInstaller@0 - inputs: - packageType: 'sdk' - version: 3.0.100-preview9-014004 - - - task: DotNetCoreCLI@2 - inputs: - command: 'restore' - projects: '**/*.csproj' - - - task: DotNetCoreCLI@2 - inputs: - command: 'build' - projects: '**/*.csproj' - arguments: '--configuration $(buildConfiguration)' - - - task: DotNetCoreCLI@2 - inputs: - command: pack - packagesToPack: 'src/Blazor.Extensions.SignalR/*.csproj' - packDirectory: '$(build.artifactStagingDirectory)' - configuration: '$(buildConfiguration)' - versioningScheme: byEnvVar - versionEnvVar: Version - - - task: NuGetCommand@2 - inputs: - command: push - packagesToPush: '$(build.ArtifactStagingDirectory)/**/*.nupkg;!$(build.ArtifactStagingDirectory)/**/*.symbols.nupkg' - publishFeedCredentials: 'BlazorExtensions' - nuGetFeedType: external - versioningScheme: byEnvVar - versionEnvVar: Version \ No newline at end of file diff --git a/README.md b/README.md index 8294060..0d85983 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,66 @@ -[![Build status](https://dotnet-ci.visualstudio.com/DotnetCI/_apis/build/status/Blazor-Extensions-SignalR-CI?branch=master)](https://dotnet-ci.visualstudio.com/DotnetCI/_build/latest?definitionId=5&branch=master) -[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR) -[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR) -[![License](https://img.shields.io/github/license/BlazorExtensions/SignalR.svg)](https://github.com/BlazorExtensions/SignalR/blob/master/LICENSE) - -# Blazor Extensions - -Blazor Extensions is a set of packages with the goal of adding useful features to [Blazor](https://blazor.net). - -# Blazor Extensions SignalR - -This package adds a [Microsoft ASP.NET Core SignalR](https://github.com/aspnet/SignalR) client library for [Microsoft ASP.NET Blazor](https://github.com/aspnet/Blazor). - -The package aims to mimic the C# APIs of SignalR Client as much as possible and it is developed by wrapping the TypeScript client by using Blazor's interop capabilities. - -For more information about SignalR development, please check [SignalR documentation](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-2.1). - -# Features - -This package implements all public features of SignalR Typescript client. - -> Note: The _Streaming_ APIs are not implemented yet. We will add it soon. - -# Sample usage - -The following snippet shows how to setup the client to send and receive messages using SignalR. - -The HubConnectionBuilder needs to get injected, which must be registered: -```c# -// in Startup.cs, ConfigureServices() - services.AddTransient(); -``` -```c# -// in Component class -[Inject] -private HubConnectionBuilder _hubConnectionBuilder { get; set; } -``` -```c# -// in Component Initialization code -var connection = _hubConnectionBuilder // the injected one from above. - .WithUrl("/myHub", // The hub URL. If the Hub is hosted on the server where the blazor is hosted, you can just use the relative path. - opt => - { - opt.LogLevel = SignalRLogLevel.Trace; // Client log level - opt.Transport = HttpTransportType.WebSockets; // Which transport you want to use for this connection - }) - .Build(); // Build the HubConnection - -connection.On("Receive", this.Handle); // Subscribe to messages sent from the Hub to the "Receive" method by passing a handle (Func) to process messages. -await connection.StartAsync(); // Start the connection. - -await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod" and pass parameters to it. - -var result = await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod", pass parameters to it and get the result back. -``` - -# Contributions and feedback - -Please feel free to use the component, open issues, fix bugs or provide feedback. - -# Contributors - -The following people are the maintainers of the Blazor Extensions projects: - -- [Attila Hajdrik](https://github.com/attilah) -- [Gutemberg Ribiero](https://github.com/galvesribeiro) +[![Build](https://github.com/BlazorExtensions/SignalR/workflows/CI/badge.svg)](https://github.com/BlazorExtensions/SignalR/actions) +[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR) +[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR) +[![License](https://img.shields.io/github/license/BlazorExtensions/SignalR.svg)](https://github.com/BlazorExtensions/SignalR/blob/master/LICENSE) + +# Blazor Extensions + +Blazor Extensions is a set of packages with the goal of adding useful features to [Blazor](https://blazor.net). + +# Blazor Extensions SignalR + +This package adds a [Microsoft ASP.NET Core SignalR](https://github.com/aspnet/SignalR) client library for [Microsoft ASP.NET Blazor](https://github.com/aspnet/Blazor). + +The package aims to mimic the C# APIs of SignalR Client as much as possible and it is developed by wrapping the TypeScript client by using Blazor's interop capabilities. + +For more information about SignalR development, please check [SignalR documentation](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-2.1). + +# Features + +This package implements all public features of SignalR Typescript client. + +> Note: The _Streaming_ APIs are not implemented yet. We will add it soon. + +# Sample usage + +The following snippet shows how to setup the client to send and receive messages using SignalR. + +The HubConnectionBuilder needs to get injected, which must be registered: +```c# +// in Startup.cs, ConfigureServices() + services.AddTransient(); +``` +```c# +// in Component class +[Inject] +private HubConnectionBuilder _hubConnectionBuilder { get; set; } +``` +```c# +// in Component Initialization code +var connection = _hubConnectionBuilder // the injected one from above. + .WithUrl("/myHub", // The hub URL. If the Hub is hosted on the server where the blazor is hosted, you can just use the relative path. + opt => + { + opt.LogLevel = SignalRLogLevel.Trace; // Client log level + opt.Transport = HttpTransportType.WebSockets; // Which transport you want to use for this connection + }) + .Build(); // Build the HubConnection + +connection.On("Receive", this.Handle); // Subscribe to messages sent from the Hub to the "Receive" method by passing a handle (Func) to process messages. +await connection.StartAsync(); // Start the connection. + +await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod" and pass parameters to it. + +var result = await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod", pass parameters to it and get the result back. +``` + +# Contributions and feedback + +Please feel free to use the component, open issues, fix bugs or provide feedback. + +# Contributors + +The following people are the maintainers of the Blazor Extensions projects: + +- [Attila Hajdrik](https://github.com/attilah) +- [Gutemberg Ribiero](https://github.com/galvesribeiro) diff --git a/src/Blazor.Extensions.SignalR/Blazor.Extensions.SignalR.csproj b/src/Blazor.Extensions.SignalR/Blazor.Extensions.SignalR.csproj index 80c02ae..8ff0662 100644 --- a/src/Blazor.Extensions.SignalR/Blazor.Extensions.SignalR.csproj +++ b/src/Blazor.Extensions.SignalR/Blazor.Extensions.SignalR.csproj @@ -12,10 +12,12 @@ 3.0 true $(TargetsForTfmSpecificBuildOutput);IncludeP2POutput + Blazor.Extensions.SignalR + 1.0.0 - + diff --git a/test/Blazor.Extensions.SignalR.Test.Client/Blazor.Extensions.SignalR.Test.Client.csproj b/test/Blazor.Extensions.SignalR.Test.Client/Blazor.Extensions.SignalR.Test.Client.csproj index 51973da..1e70791 100644 --- a/test/Blazor.Extensions.SignalR.Test.Client/Blazor.Extensions.SignalR.Test.Client.csproj +++ b/test/Blazor.Extensions.SignalR.Test.Client/Blazor.Extensions.SignalR.Test.Client.csproj @@ -10,8 +10,8 @@ 3.0 - - + + diff --git a/test/Blazor.Extensions.SignalR.Test.Server/Blazor.Extensions.SignalR.Test.Server.csproj b/test/Blazor.Extensions.SignalR.Test.Server/Blazor.Extensions.SignalR.Test.Server.csproj index 856bf19..5411f78 100644 --- a/test/Blazor.Extensions.SignalR.Test.Server/Blazor.Extensions.SignalR.Test.Server.csproj +++ b/test/Blazor.Extensions.SignalR.Test.Server/Blazor.Extensions.SignalR.Test.Server.csproj @@ -1,22 +1,22 @@ - - - - netcoreapp3.0 - - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; - https://dotnet.myget.org/F/blazor-dev/api/v3/index.json; - - - - - - - - - - - - - - - + + + + netcoreapp3.0 + + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/blazor-dev/api/v3/index.json; + + + + + + + + + + + + + + +