Skip to content

Commit

Permalink
Merge branch 'release/0.16.0'
Browse files Browse the repository at this point in the history
* release/0.16.0: (36 commits)
  Bump Octokit from 7.1.0 to 9.0.0 in /src
  Bump Microsoft.NET.Test.Sdk from 17.7.2 to 17.8.0 in /src
  Bump NSubstitute from 5.0.0 to 5.1.0 in /src
  Bump Scriban from 5.7.0 to 5.9.0 in /src
  Bump IDisposableAnalyzers from 4.0.6 to 4.0.7 in /src
  Bump Roslynator.Analyzers from 4.5.0 to 4.6.2 in /src
  Bump YamlDotNet from 13.7.0 to 13.7.1 in /src
  Bump NUnit from 3.13.3 to 3.14.0 in /src
  Bump ApprovalTests from 5.8.0 to 5.9.0 in /src
  Remove unnecessary entries in nuspec files
  Update src/GitReleaseManager.Cli/GitReleaseManager.Cli.csproj
  Adjust the nuget nuspec and the chocolatey nuspec to reflect the fact the GitReleaseMAnager.Cli targets net6.0
  Switch Cli to only net6.0 and Core to net6.0 and net7.0
  (maint) Refactor IoC registration
  (maint) Update wording and handling of culture
  (maint) Remove unnecessary code
  (maint) Fix warnings about lack of culture info
  (#146) Alter scriban template
  (#146) Prevent usage of unsupported functionality
  (#146) Add GitLab VCS Provider
  ...
  • Loading branch information
gep13 committed Nov 14, 2023
2 parents f40b2c9 + 8fd591f commit 58b6fb9
Show file tree
Hide file tree
Showing 56 changed files with 961 additions and 230 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
os: [ windows-2022 ]

env:
GITTOOLS_GITHUB_TOKEN: ${{ secrets.GITOOLS_GITHUB_TOKEN }}
GITTOOLS_GITHUB_TOKEN: ${{ secrets.GITTOOLS_GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Fetch all tags and branches
run: git fetch --prune --unshallow

- name: Install .NET SDK 2.1.x and 5.0.x
- name: Install .NET SDK 2.1.x, 3.1.x, 5.0.x, and 6.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
Expand Down
6 changes: 2 additions & 4 deletions nuspec/chocolatey/GitReleaseManager.Portable.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
<tags>github release notes create export</tags>
</metadata>
<files>
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.exe" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.dll" target="tools" exclude="**\Serilog.Sinks.Debug.dll" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.pdb" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.exe.config" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net6.0\*.exe" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net6.0\*.pdb" target="tools" />
<file src="chocolateyInstall.ps1" target="tools"/>
<file src="chocolateyUninstall.ps1" target="tools"/>
<file src="VERIFICATION.TXT" />
Expand Down
8 changes: 3 additions & 5 deletions nuspec/nuget/GitReleaseManager.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
<tags>github release notes create export</tags>
</metadata>
<files>
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.exe" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.exe.config" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.xml" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.dll" target="tools" exclude="**\Serilog.Sinks.Debug.dll" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net48\*.pdb" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net6.0\*.exe" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net6.0\*.xml" target="tools" />
<file src="..\..\BuildArtifacts\temp\_PublishedApplications\GitReleaseManager.Cli\net6.0\*.pdb" target="tools" />
<file src="..\..\icons\package_icon.png" target="" />
</files>
</package>
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="IDisposableAnalyzers" Version="4.0.6">
<PackageReference Include="IDisposableAnalyzers" Version="4.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.4.0">
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/GitReleaseManager.Cli/GitReleaseManager.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<LangVersion>8.0</LangVersion>
<OutputType>Exe</OutputType>
<AssemblyName>GitReleaseManager</AssemblyName>
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Title>GitReleaseManager.Cli</Title>
<Description>Create release notes in markdown given a milestone</Description>
<IsPackable>false</IsPackable>
Expand All @@ -20,7 +23,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Octokit" Version="7.1.0" />
<PackageReference Include="Octokit" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
Expand Down
27 changes: 22 additions & 5 deletions src/GitReleaseManager.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
using GitReleaseManager.Core.Commands;
using GitReleaseManager.Core.Configuration;
using GitReleaseManager.Core.Helpers;
using GitReleaseManager.Core.Model;
using GitReleaseManager.Core.Options;
using GitReleaseManager.Core.Provider;
using GitReleaseManager.Core.ReleaseNotes;
using GitReleaseManager.Core.Templates;
using Microsoft.Extensions.DependencyInjection;
using NGitLab;
using Octokit;
using Serilog;

Expand Down Expand Up @@ -96,7 +98,6 @@ private static void RegisterServices(BaseSubOptions options)
.AddSingleton<IFileSystem>(fileSystem)
.AddSingleton<IReleaseNotesExporter, ReleaseNotesExporter>()
.AddSingleton<IReleaseNotesBuilder, ReleaseNotesBuilder>()
.AddSingleton<IVcsProvider, GitHubProvider>()
.AddSingleton<IVcsService, VcsService>();

if (options is BaseVcsOptions vcsOptions)
Expand All @@ -106,9 +107,7 @@ private static void RegisterServices(BaseSubOptions options)
throw new Exception("The token option is not defined");
}

var gitHubClient = new GitHubClient(new ProductHeaderValue("GitReleaseManager")) { Credentials = new Credentials(vcsOptions.Token) };
serviceCollection = serviceCollection
.AddSingleton<IGitHubClient>(gitHubClient);
RegisterVcsProvider(vcsOptions, serviceCollection);
}

serviceCollection = serviceCollection
Expand Down Expand Up @@ -192,10 +191,28 @@ private static Task<int> ExecuteCommand<TOptions>(TOptions options)
where TOptions : BaseSubOptions
{
var command = _serviceProvider.GetRequiredService<ICommand<TOptions>>();
return command.Execute(options);
return command.ExecuteAsync(options);
}

private static void LogOptions(BaseSubOptions options)
=> Log.Debug("{@Options}", options);

private static void RegisterVcsProvider(BaseVcsOptions vcsOptions, IServiceCollection serviceCollection)
{
Log.Information("Using {Provider} as VCS Provider", vcsOptions.Provider);
if (vcsOptions.Provider == VcsProvider.GitLab)
{
serviceCollection
.AddSingleton<IGitLabClient>((_) => new GitLabClient("https://gitlab.com", vcsOptions.Token))
.AddSingleton<IVcsProvider, GitLabProvider>();
}
else
{
// default to Github
serviceCollection
.AddSingleton<IGitHubClient>((_) => new GitHubClient(new ProductHeaderValue("GitReleaseManager")) { Credentials = new Credentials(vcsOptions.Token) })
.AddSingleton<IVcsProvider, GitHubProvider>();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task Should_Execute_Command()
_vcsService.AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).
Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task Should_Create_Empty_Release()
_vcsService.CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.TargetCommitish, options.Prerelease)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, releaseName, options.TargetCommitish, options.Prerelease).ConfigureAwait(false);
Expand Down Expand Up @@ -72,7 +72,7 @@ public async Task Should_Create_Release_From_Milestone(string name, int logVerbo
_vcsService.CreateReleaseFromMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone, releaseName, options.TargetCommitish, options.AssetPaths, options.Prerelease, options.Template)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateReleaseFromMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone, releaseName, options.TargetCommitish, options.AssetPaths, options.Prerelease, options.Template).ConfigureAwait(false);
Expand All @@ -98,7 +98,7 @@ public async Task Should_Create_Release_From_InputFile()
_vcsService.CreateReleaseFromInputFileAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.InputFilePath, options.TargetCommitish, options.AssetPaths, options.Prerelease)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateReleaseFromInputFileAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.InputFilePath, options.TargetCommitish, options.AssetPaths, options.Prerelease).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.DiscardReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).DiscardReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task Should_Execute_Command()
_vcsService.ExportReleasesAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.SkipPrereleases)
.Returns(releaseText);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

var exportFileExists = File.Exists(_fileOutputPath);
Expand Down
4 changes: 2 additions & 2 deletions src/GitReleaseManager.Core.Tests/Commands/InitCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task Should_Execute_Command()
{
var options = new InitSubOptions { TargetDirectory = _targetDirectory };

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

var configFilePath = Path.Combine(_targetDirectory, "GitReleaseManager.yml");
Expand Down Expand Up @@ -70,7 +70,7 @@ public async Task Should_Not_Execute_Command_For_Legacy_FileName()
File.WriteAllText(configFilePath, "s");
var expectedHash = GetHash(configFilePath);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0); // Should this perhaps return 1

var actualHash = GetHash(configFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task Should_Execute_Command()
_vcsService.CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.OpenMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).OpenMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.PublishReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.TagName)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).PublishReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.TagName).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Threading.Tasks;
using GitReleaseManager.Core.Commands;
using GitReleaseManager.Core.Configuration;
using GitReleaseManager.Core.Helpers;
using GitReleaseManager.Core.Options;
using NSubstitute;
Expand All @@ -21,15 +23,18 @@ public void Setup()
{
_fileSystem = Substitute.For<IFileSystem>();
_logger = Substitute.For<ILogger>();
_command = new ShowConfigCommand(_fileSystem, _logger);

var currentDirectory = Environment.CurrentDirectory;
var configuration = ConfigurationProvider.Provide(currentDirectory, _fileSystem);
_command = new ShowConfigCommand(_logger, configuration);
}

[Test]
public async Task Should_Execute_Command()
{
var options = new ShowConfigSubOptions();

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

_logger.Received(1).Information(Arg.Any<string>(), Arg.Any<string>());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Title>GitReleaseManager.Core.Tests</Title>
<Description>Test Project for GitReleaseManager.Core</Description>
<NoWarn>$(NoWarn);CA1707;Serilog004;</NoWarn>
Expand All @@ -17,16 +17,16 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="ApprovalTests" Version="5.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="ApprovalTests" Version="5.9.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Octokit" Version="7.1.0" />
<PackageReference Include="Octokit" Version="9.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>
</Project>
Loading

0 comments on commit 58b6fb9

Please sign in to comment.