Skip to content

Commit

Permalink
Initial release automation (#71)
Browse files Browse the repository at this point in the history
* Initial release automation

* release: read version from version.txt

Signed-off-by: Caleb Lloyd <[email protected]>

* Test fixes

* move signing back up one level

Signed-off-by: Caleb Lloyd <[email protected]>

* move signing back up one level

Signed-off-by: Caleb Lloyd <[email protected]>

* Test unused function clean-up

---------

Signed-off-by: Caleb Lloyd <[email protected]>
Co-authored-by: Caleb Lloyd <[email protected]>
  • Loading branch information
mtmk and Caleb Lloyd committed Jun 30, 2023
1 parent 953692e commit f5e4b7f
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 46 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on: workflow_dispatch

permissions:
contents: write

jobs:
nuget:
name: dotnet
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- id: tag
name: Determine tag
run: |
version="$(head -n 1 version.txt)"
ref_name="v$version"
create=true
if ["$(git ls-remote origin "refs/tags/$ref_name" | wc -l)" = "1" ]; then
create=false
fi
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
echo "ref-name=$ref_name" | tee -a "$GITHUB_OUTPUT"
echo "create=$create" | tee -a "$GITHUB_OUTPUT"
- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.x'

- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Pack
run: dotnet pack -c Release -o dist

- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Push
run: dotnet nuget push dist/*.nupkg -s https://api.nuget.org/v3/index.json -k "${{ secrets.NUGET_API_KEY }}" --skip-duplicate

- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Tag
run: |
git tag "${{ steps.tag.outputs.ref-name }}"
git push origin "${{ steps.tag.outputs.ref-name }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@ nuget/*.unitypackage
# Jetbrains Rider
.idea/

# Unity
# NuGet package
/dist

13 changes: 0 additions & 13 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)opensource.snk</AssemblyOriginatorKeyFile>

<!-- NuGet Packaging -->
<PackageVersion>$(Version)</PackageVersion>
<Company>CNCF</Company>
<Authors>The NATS Authors</Authors>
<Copyright>Copyright © The NATS Authors 2016-$([System.DateTime]::Now.ToString(yyyy))</Copyright>
<PackageProjectUrl>https://github.com/nats-io/nats.net.v2</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageIcon>Icon.png</PackageIcon>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)opensource.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
41 changes: 21 additions & 20 deletions sandbox/BlazorWasm/Server/BlazorWasm.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Client\BlazorWasm.Client.csproj" />
<ProjectReference Include="..\Shared\BlazorWasm.Shared.csproj" />
</ItemGroup>


</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Client\BlazorWasm.Client.csproj" />
<ProjectReference Include="..\Shared\BlazorWasm.Shared.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Example.Core.Subscribe</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions sandbox/MinimumWebApp/MinimumWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 18 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<Project>
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<!-- NuGet Packaging -->
<PackageVersion>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)..\version.txt"))</PackageVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Company>CNCF</Company>
<Authors>The NATS Authors</Authors>
<Copyright>Copyright © The NATS Authors 2016-$([System.DateTime]::Now.ToString(yyyy))</Copyright>
<PackageProjectUrl>https://github.com/nats-io/nats.net.v2</PackageProjectUrl>
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageIcon>Icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\LICENSE" Pack="true" PackagePath=""/>
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="true" PackagePath=""/>
<None Include="$(MSBuildThisFileDirectory)..\README.md" Pack="true" PackagePath=""/>
<None Include="$(MSBuildThisFileDirectory)..\Icon.png" Pack="true" PackagePath=""/>
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/NATS.Client.Core/NATS.Client.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</PropertyGroup>

<ItemGroup>
<None Include="../../Icon.png" Pack="true" PackagePath="/" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.1.46">
Expand Down
6 changes: 0 additions & 6 deletions src/NATS.Client.Hosting/NATS.Client.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
<IsPackable>true</IsPackable>
</PropertyGroup>


<ItemGroup>
<None Include="../../Icon.png" Pack="true" PackagePath="/" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/NATS.Client.Core.Tests/ProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ public async Task Unsubscribe_max_msgs()

// Manual unsubscribe
{
proxy.ClearFrames();
await proxy.FlushFramesAsync(nats);

await using var sub = await nats.SubscribeAsync<int>("foo2");

await sub.UnsubscribeAsync();

var sid = ((INatsSub)sub).Sid;

await Retry.Until("all frames arrived", () => proxy.ClientFrames.Count >= 2);
await Retry.Until("all frames arrived", () => proxy.ClientFrames.Count == 2);

Assert.Equal($"SUB foo2 {sid}", proxy.ClientFrames[0].Message);
Assert.Equal($"UNSUB {sid}", proxy.ClientFrames[1].Message);
Expand Down
13 changes: 11 additions & 2 deletions tests/NATS.Client.Core.Tests/_NatsServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public class NatsProxy : IDisposable
private readonly List<TcpClient> _clients = new();
private readonly List<Frame> _frames = new();
private readonly Stopwatch _watch = new();
private int _syncCount;

public NatsProxy(int port, ITestOutputHelper outputHelper)
{
Expand Down Expand Up @@ -419,14 +420,22 @@ public void Reset()
}
}

ClearFrames();
lock (_frames) _frames.Clear();

_watch.Restart();
}
}

public void ClearFrames()
public async Task FlushFramesAsync(NatsConnection nats)
{
var subject = $"_SIGNAL_SYNC_{Interlocked.Increment(ref _syncCount)}";

await nats.PublishAsync(subject);

await Retry.Until(
"flush sync frame",
() => AllFrames.Any(f => f.Message == $"PUB {subject} 0␍␊"));

lock (_frames) _frames.Clear();
}

Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0-alpha.0

0 comments on commit f5e4b7f

Please sign in to comment.