mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-17 06:33:21 +08:00
#1150: added simple way to get release notes using cake and git
This commit is contained in:
parent
b280b1c530
commit
1a280ddd7f
3
Makefile
3
Makefile
@ -17,4 +17,7 @@ run_benchmarks:
|
|||||||
|
|
||||||
run_unit_tests:
|
run_unit_tests:
|
||||||
./build.sh --target=RunUnitTests
|
./build.sh --target=RunUnitTests
|
||||||
|
|
||||||
|
release_notes:
|
||||||
|
./build.sh --target=ReleaseNotes
|
||||||
|
|
@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
GitVersion.yml = GitVersion.yml
|
GitVersion.yml = GitVersion.yml
|
||||||
LICENSE.md = LICENSE.md
|
LICENSE.md = LICENSE.md
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
ReleaseNotes.md = ReleaseNotes.md
|
releasenotes.md = releasenotes.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-36DA-4491-B73A-7590A26E420B}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-36DA-4491-B73A-7590A26E420B}"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
No issues closed since last release
|
|
94
build.cake
94
build.cake
@ -1,5 +1,4 @@
|
|||||||
#tool "nuget:?package=GitVersion.CommandLine&version=5.0.1"
|
#tool "nuget:?package=GitVersion.CommandLine&version=5.0.1"
|
||||||
#tool "nuget:?package=GitReleaseNotes"
|
|
||||||
#addin nuget:?package=Cake.Json
|
#addin nuget:?package=Cake.Json
|
||||||
#addin nuget:?package=Newtonsoft.Json
|
#addin nuget:?package=Newtonsoft.Json
|
||||||
#addin nuget:?package=System.Net.Http
|
#addin nuget:?package=System.Net.Http
|
||||||
@ -63,6 +62,9 @@ Task("Default")
|
|||||||
Task("Build")
|
Task("Build")
|
||||||
.IsDependentOn("RunTests");
|
.IsDependentOn("RunTests");
|
||||||
|
|
||||||
|
Task("ReleaseNotes")
|
||||||
|
.IsDependentOn("CreateReleaseNotes");
|
||||||
|
|
||||||
Task("RunTests")
|
Task("RunTests")
|
||||||
.IsDependentOn("RunUnitTests")
|
.IsDependentOn("RunUnitTests")
|
||||||
.IsDependentOn("RunAcceptanceTests")
|
.IsDependentOn("RunAcceptanceTests")
|
||||||
@ -96,8 +98,62 @@ Task("Clean")
|
|||||||
}
|
}
|
||||||
CreateDirectory(artifactsDir);
|
CreateDirectory(artifactsDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Task("CreateReleaseNotes")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
Information("Generating release notes at " + releaseNotesFile);
|
||||||
|
|
||||||
|
IEnumerable<string> lastReleaseTag;
|
||||||
|
|
||||||
|
var lastReleaseTagExitCode = StartProcess(
|
||||||
|
"git",
|
||||||
|
new ProcessSettings {
|
||||||
|
Arguments = "describe --tags --abbrev=0",
|
||||||
|
RedirectStandardOutput = true
|
||||||
|
},
|
||||||
|
out lastReleaseTag
|
||||||
|
);
|
||||||
|
|
||||||
|
if (lastReleaseTagExitCode != 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to get latest release tag");
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastRelease = lastReleaseTag.First();
|
||||||
|
|
||||||
|
Information("Last release tag is " + lastRelease);
|
||||||
|
|
||||||
|
IEnumerable<string> releaseNotes;
|
||||||
|
|
||||||
|
var releaseNotesExitCode = StartProcess(
|
||||||
|
"git",
|
||||||
|
new ProcessSettings {
|
||||||
|
Arguments = $"log --pretty=format:\"%h - %an - %s\" {lastRelease}..HEAD",
|
||||||
|
RedirectStandardOutput = true
|
||||||
|
},
|
||||||
|
out releaseNotes
|
||||||
|
);
|
||||||
|
|
||||||
|
if (releaseNotesExitCode != 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to generate release notes");
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureDirectoryExists(packagesDir);
|
||||||
|
|
||||||
|
System.IO.File.WriteAllLines(releaseNotesFile, releaseNotes);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(releaseNotesFile)))
|
||||||
|
{
|
||||||
|
System.IO.File.WriteAllText(releaseNotesFile, "No commits since last release");
|
||||||
|
}
|
||||||
|
|
||||||
|
Information("Release notes are\r\n" + System.IO.File.ReadAllText(releaseNotesFile));
|
||||||
|
});
|
||||||
|
|
||||||
Task("Version")
|
Task("Version")
|
||||||
|
.IsDependentOn("CreateReleaseNotes")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
versioning = GetNuGetVersionForCommit();
|
versioning = GetNuGetVersionForCommit();
|
||||||
@ -210,17 +266,13 @@ Task("CreateArtifacts")
|
|||||||
|
|
||||||
CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
|
CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
|
||||||
|
|
||||||
// todo fix this for docker build
|
|
||||||
//GenerateReleaseNotes(releaseNotesFile);
|
|
||||||
|
|
||||||
var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
|
var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
|
||||||
|
|
||||||
foreach(var projectFile in projectFiles)
|
foreach(var projectFile in projectFiles)
|
||||||
{
|
{
|
||||||
System.IO.File.AppendAllLines(artifactsFile, new[]{
|
System.IO.File.AppendAllLines(artifactsFile, new[]{
|
||||||
projectFile.GetFilename().FullPath,
|
projectFile.GetFilename().FullPath,
|
||||||
// todo fix this for docker build
|
"releaseNotes:releasenotes.md"
|
||||||
//"releaseNotes:releasenotes.md"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,32 +391,6 @@ private void PersistVersion(string committedVersion, string newVersion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generates release notes based on issues closed in GitHub since the last release
|
|
||||||
private void GenerateReleaseNotes(ConvertableFilePath file)
|
|
||||||
{
|
|
||||||
if(!IsRunningOnWindows())
|
|
||||||
{
|
|
||||||
Warning("We are not running on Windows so we cannot generate release notes.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Information("Generating release notes at " + file);
|
|
||||||
|
|
||||||
var releaseNotesExitCode = StartProcess(
|
|
||||||
@"tools/GitReleaseNotes/tools/gitreleasenotes.exe",
|
|
||||||
new ProcessSettings { Arguments = ". /o " + file });
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(file)))
|
|
||||||
{
|
|
||||||
System.IO.File.WriteAllText(file, "No issues closed since last release");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (releaseNotesExitCode != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Failed to generate release notes");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
|
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
|
||||||
private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
|
private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
|
||||||
{
|
{
|
||||||
@ -392,7 +418,7 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi
|
|||||||
|
|
||||||
private void CreateGitHubRelease()
|
private void CreateGitHubRelease()
|
||||||
{
|
{
|
||||||
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"todo: notes coming\", \"draft\": true, \"prerelease\": true }}";
|
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"{System.IO.File.ReadAllText(releaseNotesFile)}\", \"draft\": true, \"prerelease\": true }}";
|
||||||
var content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
var content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
using(var client = new System.Net.Http.HttpClient())
|
using(var client = new System.Net.Http.HttpClient())
|
||||||
@ -442,7 +468,7 @@ private void UploadFileToGitHubRelease(FilePath file)
|
|||||||
|
|
||||||
private void CompleteGitHubRelease()
|
private void CompleteGitHubRelease()
|
||||||
{
|
{
|
||||||
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"todo: notes coming\", \"draft\": false, \"prerelease\": false }}";
|
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"{System.IO.File.ReadAllText(releaseNotesFile)}\", \"draft\": false, \"prerelease\": false }}";
|
||||||
var request = new System.Net.Http.HttpRequestMessage(new System.Net.Http.HttpMethod("Patch"), $"https://api.github.com/repos/ThreeMammals/Ocelot/releases/{releaseId}");
|
var request = new System.Net.Http.HttpRequestMessage(new System.Net.Http.HttpMethod("Patch"), $"https://api.github.com/repos/ThreeMammals/Ocelot/releases/{releaseId}");
|
||||||
request.Content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
request.Content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
0
releasenotes.md
Normal file
0
releasenotes.md
Normal file
Loading…
x
Reference in New Issue
Block a user