Assist Release Note Creation (#2164)

Finds hash of the last tag and then uses the commit summary to assist in
release note creation
This commit is contained in:
flightlevel 2017-11-19 17:19:49 +11:00 committed by GitHub
parent 76b088b5ec
commit 3929ff2662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 3 deletions

View File

@ -4,7 +4,6 @@ pull_requests:
skip_tags: true skip_tags: true
image: Visual Studio 2017 image: Visual Studio 2017
configuration: Release configuration: Release
shallow_clone: true
assembly_info: assembly_info:
patch: true patch: true
file: '**\AssemblyInfo.*' file: '**\AssemblyInfo.*'
@ -22,9 +21,12 @@ dotnet_csproj:
build_script: build_script:
- ps: .\build.ps1 - ps: .\build.ps1
test: off test: off
before_deploy:
- ps: ${env:release_description} = ( Get-Content -LiteralPath BuildOutput/ReleaseNotes.txt -Encoding UTF8 ) -join "`n";
deploy: deploy:
- provider: GitHub - provider: GitHub
tag: v$(appveyor_build_version) tag: v$(appveyor_build_version)
description: $(release_description)
auth_token: auth_token:
secure: hOg+16YTIbq4kO9u4D1YVOTbWDqgCX6mAQYMbnmBBSw2CiUsZh7OKbupoUb3FtWa secure: hOg+16YTIbq4kO9u4D1YVOTbWDqgCX6mAQYMbnmBBSw2CiUsZh7OKbupoUb3FtWa
draft: true draft: true

View File

@ -1,4 +1,6 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0 #tool nuget:?package=NUnit.ConsoleRunner
#addin nuget:?package=Cake.FileHelpers
#addin nuget:?package=Cake.Git
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// ARGUMENTS // ARGUMENTS
@ -172,6 +174,56 @@ Task("Appveyor-Push-Artifacts")
} }
}); });
Task("Potential-Release-Notes")
.IsDependentOn("Appveyor-Push-Artifacts")
.Does(() =>
{
string tagHashLastGitHubTag = GitDescribe(".", false, GitDescribeStrategy.Tags, 100);
Information($"Tag and Hash of last release is: {tagHashLastGitHubTag}");
if (tagHashLastGitHubTag.Length > 40)
{
string lastReleaseHash = tagHashLastGitHubTag.Substring(tagHashLastGitHubTag.Length - 40);
Information($"Hash of first commit since last release is: {lastReleaseHash}" + Environment.NewLine);
List<GitCommit> relevantCommits = new List<GitCommit>();
var commitCollection = GitLog("./", 50);
bool foundHash = false;
foreach(GitCommit commit in commitCollection)
{
relevantCommits.Add(commit);
if (lastReleaseHash == commit.Sha)
{
foundHash = true;
break;
}
}
if (foundHash)
{
List<string> notesList = new List<string>();
foreach(GitCommit commit in relevantCommits.AsEnumerable().Reverse().ToList())
{
notesList.Add($"{commit.MessageShort} (Thank you @{commit.Author.Name})");
}
string buildNote = String.Join(Environment.NewLine, notesList);
Information(buildNote);
FileAppendLines(workingDir + "\\BuildOutput\\ReleaseNotes.txt", notesList.ToArray());
}
else
{
Information($"Unable to create potential release notes as the hash ({lastReleaseHash}) of the first commit since the last release wasn't found in the last 50 commits");
}
}
});
private void RunCygwinCommand(string utility, string utilityArguments) private void RunCygwinCommand(string utility, string utilityArguments)
{ {
var cygwinDir = @"C:\cygwin\bin\"; var cygwinDir = @"C:\cygwin\bin\";
@ -222,7 +274,7 @@ private string RelativeWinPathToCygPath(string relativePath)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
Task("Default") Task("Default")
.IsDependentOn("Appveyor-Push-Artifacts") .IsDependentOn("Potential-Release-Notes")
.Does(() => .Does(() =>
{ {
Information("Default Task Completed"); Information("Default Task Completed");