Skip to content

Commit

Permalink
Upgrade, cleanup, add workflow actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobThree committed Mar 7, 2024
1 parent cb0c52f commit 714edc2
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [RobThree]
custom: ["https://paypal.me/robiii"]
40 changes: 40 additions & 0 deletions .github/workflows/publishnuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish Nuget Package

on:
release:
types:
- created

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '8.0.x' ]

steps:
- uses: actions/checkout@v4

- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Setup NuGet
uses: NuGet/setup-nuget@v2

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore /p:Version="${{ github.event.release.tag_name }}"

- name: Run tests
run: dotnet test -c Release --no-restore --no-build

- name: Create packages
run: dotnet pack ${{ github.event.repository.name }} -c Release --no-restore --no-build -p:Version="${{ github.event.release.tag_name }}"

- name: Publish
run: dotnet nuget push **\*.nupkg -s 'https://api.nuget.org/v3/index.json' -k ${{secrets.NUGET_API_KEY}}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
push

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '8.0.x' ]

steps:
- uses: actions/checkout@v4

- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Setup NuGet
uses: NuGet/setup-nuget@v2

- name: Restore dependencies
run: dotnet restore

- name: Run tests
run: dotnet test --no-restore
7 changes: 2 additions & 5 deletions NEnvoy/EnvoyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,9 @@ private static HttpClient GetUnsafeClient(Uri baseAddress, EnvoySession? session
return client;
}

private class EnvoyHttpClientHandler : HttpClientHandler
private class EnvoyHttpClientHandler(EnvoySession? session) : HttpClientHandler
{
private readonly EnvoySession? _session;

public EnvoyHttpClientHandler(EnvoySession? session)
=> _session = session;
private readonly EnvoySession? _session = session;

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Expand Down
4 changes: 1 addition & 3 deletions NEnvoy/Exceptions/EnvoyException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
namespace NEnvoy.Exceptions;
public class EnvoyException : Exception
public class EnvoyException(string message, Exception? innerException = null) : Exception(message, innerException)
{
public EnvoyException(string message, Exception? innerException = null)
: base(message, innerException) { }
}
7 changes: 2 additions & 5 deletions NEnvoy/Exceptions/LoginFailedException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
namespace NEnvoy.Exceptions;

public class LoginFailedException : EnvoyException
public class LoginFailedException(string? responseMessage) : EnvoyException("Login failed")
{
public string? ResponseMessage { get; init; }

public LoginFailedException(string? responseMessage)
: base("Login failed") => ResponseMessage = responseMessage;
public string? ResponseMessage { get; init; } = responseMessage;
}
9 changes: 4 additions & 5 deletions NEnvoy/NEnvoy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand All @@ -18,8 +18,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>api-client;envoy;enphase-api;enphase;envoy-api</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright © 2023 Devcorner.nl</Copyright>
<Version>0.3.1-alpha</Version>
<Copyright>Copyright © 2023 - 2024 Devcorner.nl</Copyright>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

Expand All @@ -31,11 +30,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Refit.Xml" Version="6.3.2" />
<PackageReference Include="Refit.Xml" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
46 changes: 25 additions & 21 deletions TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>bb70e725-2135-46e1-916c-401c35941915</UserSecretsId>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AnalysisLevel>latest</AnalysisLevel>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<UserSecretsId>bb70e725-2135-46e1-916c-401c35941915</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NEnvoy\NEnvoy.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NEnvoy\NEnvoy.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

0 comments on commit 714edc2

Please sign in to comment.