Skip to content

Commit

Permalink
Implement an Changelog generator for Qsor.Deploy (#47)
Browse files Browse the repository at this point in the history
* add a basic changelog generator

* Finish the implementation
  • Loading branch information
mempler authored Apr 10, 2020
1 parent 634b3fe commit 30d3351
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
28 changes: 28 additions & 0 deletions Qsor.Deploy/ChangelogGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Linq;
using LibGit2Sharp;

namespace Qsor.Deploy
{
public static class ChangelogGenerator
{
public static string GenerateChangelog()
{
var repoPath = Repository.Discover(".");
var repo = new Repository(repoPath);

var changeLog = string.Empty;

foreach (var commit in repo.Commits)
{
var lastTag = repo.Tags.Last();
if (commit.Sha == lastTag.Target.Sha)
break;

changeLog += $"`{commit.Sha.Remove(7)}` {commit.MessageShort} - {commit.Author.Name} {Environment.NewLine}";
}

return changeLog;
}
}
}
7 changes: 6 additions & 1 deletion Qsor.Deploy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private static void Main()
Console.WriteLine($"Package: Qsor");
Console.WriteLine($"Release Version: {currentDate}");
Console.WriteLine($"Release Directory: {releaseDirectory.GetFullPath(".")}");
Console.WriteLine($"Changelog: \n{ChangelogGenerator.GenerateChangelog()}");

var logo = solutionDirectory.GetFullPath("Qsor.Game/Resources/Textures/Logo-256x256.png");
var icon = solutionDirectory.GetFullPath("Qsor.Desktop/icon.ico");
Expand Down Expand Up @@ -70,11 +71,12 @@ private static void Main()
{
Name = currentDate,
Draft = true,
Body = ChangelogGenerator.GenerateChangelog()
}));

req.AddHeader("Authorization", $"token {GithubAccessToken}");
req.Perform();

var targetRelease = req.ResponseObject;

var assetUploadUrl = targetRelease.UploadUrl.Replace("{?name,label}", "?name={0}");
Expand Down Expand Up @@ -146,5 +148,8 @@ public class GitHubRelease

[JsonProperty(@"upload_url")]
public string UploadUrl;

[JsonProperty(@"body")]
public string Body;
}
}
1 change: 1 addition & 0 deletions Qsor.Deploy/Qsor.Deploy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibGit2Sharp" Version="0.27.0-preview-0034" />
<PackageReference Include="NuGet.CommandLine" Version="5.4.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.410.0" />
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.4" />
Expand Down

0 comments on commit 30d3351

Please sign in to comment.