Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Feb 27, 2022
1 parent ac31f61 commit 18d8deb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dotnet-releaser/DevHosting/GitHubDevHosting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private async Task<Release> CreateOrUpdateReleaseImpl(string user, string repo,
{
var releases = await _client.Repository.Release.GetAll(user, repo);

string versionTagForDraft = version.DraftBranchName;
string versionTagForDraft = version.DraftName;
var tag = version.IsDraft ? versionTagForDraft : version.Tag;

Release? release = null;
Expand Down
8 changes: 7 additions & 1 deletion src/dotnet-releaser/ReleaseVersion.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
namespace DotNetReleaser;

public record ReleaseVersion(string Version, bool IsDraft, string Tag, string DraftBranchName);
public record ReleaseVersion(string Version, bool IsDraft, string Tag, string DraftName)
{
public override string ToString()
{
return IsDraft ? $"version: {Version}, draft-name: {DraftName}" : $"version: {Version}";
}
}
4 changes: 2 additions & 2 deletions src/dotnet-releaser/ReleaserApp.NuGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private async Task<bool> BuildNuGetPackage(BuildInformation buildInfo)

try
{
_logger.LogStartGroup("NuGet Packaging");
_logger.LogStartGroup($"NuGet Packaging - {buildInfo.Version}");
foreach (var projectPackageInfo in buildInfo.GetAllPackableProjects())
{
var nugetPackages = await BuildNuGetPackageImpl(projectPackageInfo);
Expand Down Expand Up @@ -43,7 +43,7 @@ private async Task<bool> BuildNuGetPackage(BuildInformation buildInfo)

private async Task<List<string>?> BuildNuGetPackageImpl(ProjectPackageInfo projectPackageInfo)
{
Info($"Building NuGet Package");
Info($"Building NuGet Package - {projectPackageInfo.Name}");
var restoreResult = await RunMSBuild(projectPackageInfo.ProjectFullPath, "Restore");
if (restoreResult is null)
{
Expand Down
12 changes: 9 additions & 3 deletions src/dotnet-releaser/ReleaserApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ public partial class ReleaserApp

private ReleaserApp(ISimpleLogger logger)
{
ExeName = "dotnet-releaser";
_logger = logger;
_config = new ReleaserConfiguration();
_assemblyCoverages = new List<AssemblyCoverage>();
_tableBorder = TableBorder.Square;
Version = typeof(ReleaserApp).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "?.?.?";
}

public string ExeName { get; }

public string Version { get; }

/// <summary>
/// Main entry for the releaser. Parser the argument and delegate to <see cref="RunImpl"/>
/// </summary>
Expand Down Expand Up @@ -83,14 +89,13 @@ public static async Task<int> Run(string[] args)
var exeName = "dotnet-releaser";
var logger = SimpleLogger.CreateConsoleLogger(factory, exeName);
var appReleaser = new ReleaserApp(logger);
var version = typeof(ReleaserApp).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "?.?.?";

var app = new CommandLineApplication
{
Name = exeName,
};

app.VersionOption("--version", $"{app.Name} {version} - {DateTime.Now.Year} (c) Copyright Alexandre Mutel", version);
app.VersionOption("--version", $"{app.Name} {appReleaser.Version} - {DateTime.Now.Year} (c) Copyright Alexandre Mutel", appReleaser.Version);
app.HelpOption(inherited: true);
app.Command("publish", AddPublishOrBuildArgs);
app.Command("build", AddPublishOrBuildArgs);
Expand Down Expand Up @@ -257,7 +262,8 @@ private async Task<bool> RunImpl(string configurationFile, BuildKind buildKind,
ChangelogResult? changelog = null;
try
{
_logger.LogStartGroup("Configuring");
_logger.Info($"dotnet-releaser {Version} - {buildKind.ToString().ToLowerInvariant()}");
_logger.LogStartGroup($"Configuring");
var result = await Configuring(configurationFile, buildKind, githubApiToken, githubApiTokenExtra, nugetApiToken, forceArtifactsFolder);
if (result is null) return false;
buildInformation = result.Value.buildInformation!;
Expand Down

0 comments on commit 18d8deb

Please sign in to comment.