Skip to content

Commit 8212c55

Browse files
committed
Merge branch 'release/2.2.0'
* release/2.2.0: (51 commits) (build) Update github action dependencies when drafting release notes (maint) Added custom step to generate includes.cake script (maint) Add workflow for creating release notes (GH-755) Update JetBrains.ReSharper.CommandLineTools reference from 2020.3.0 to 2020.3.2 (GH-754) Update NuGet.CommandLine reference from 5.8.0 to 5.8.1 (GH-756) Update ReportGenerator reference from 4.8.0 to 4.8.5 (GH-757) Update dotnet-reportgenerator-globaltool reference from 4.8.0 to 4.8.5 (build) Add missing semi-colon (maint) Check for .Net Framework GitVersion (GH-77) Removed logging (GH-768) Attempt to handle multiple lines from git (GH-768) Add more logging (GH-768) Handle additional branch names (GH-768) Added missing context (GH-768) Lookup branch name from git (GH-769) Update Codecov.Tool reference from 1.12.4 to 1.13.0 (GH-770) Update codecov reference from 1.12.4 to 1.13.0 (GH-768) Use BranchSourceName for Branch Name (build) Switch to released version of GitVersion (GH-768) Switch to using SourceBranch ...
2 parents 94746c1 + 1a47484 commit 8212c55

22 files changed

Lines changed: 274 additions & 72 deletions
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Draft Release Notes
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
draft-stable:
8+
env:
9+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout the requested branch
14+
uses: actions/checkout@v2.3.4
15+
- name: Fetch all tags and branches
16+
run: git fetch --prune --unshallow
17+
- name: Cache Tools
18+
uses: actions/cache@v2.1.4
19+
with:
20+
path: tools
21+
key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }}
22+
- name: Set up git version
23+
if: ${{ !contains(github.ref, '/hotfix/') && !contains(github.ref, '/release/') }}
24+
uses: gittools/actions/gitversion/setup@v0.9.9
25+
with:
26+
versionSpec: "5.x"
27+
- name: Run git version
28+
if: ${{ !contains(github.ref, '/hotfix/') && !contains(github.ref, '/release/') }}
29+
id: gitversion
30+
uses: gittools/actions/gitversion/execute@v0.9.9
31+
- name: Create release branch ${{ github.event.inputs.version }}
32+
if: ${{ steps.gitversion.outputs.majorMinorPatch }}
33+
run: git switch -c release/${{ steps.gitversion.outputs.majorMinorPatch }}
34+
- name: Push new branch
35+
if: ${{ steps.gitversion.outputs.majorMinorPatch }}
36+
uses: ad-m/github-push-action@v0.6.0
37+
with:
38+
branch: "release/${{ steps.gitversion.outputs.majorMinorPatch }}"
39+
github_token: ${{ secrets.GH_TOKEN }}
40+
- name: Creating includes.cake file
41+
run: |
42+
Get-ChildItem "./Cake.Recipe/Content/*.cake" -Exclude "version.cake" | % {
43+
"#load `"local:?path=$($_.FullName -replace '\\','/')`""
44+
} | Out-File "./includes.cake"
45+
shell: pwsh
46+
- name: Drafting Release Notes
47+
uses: cake-build/cake-action@v1
48+
with:
49+
script-path: recipe.cake
50+
target: releasenotes
51+
verbosity: Diagnostic
52+
cake-version: 0.38.5
53+
cake-bootstrap: true

Cake.Recipe/Content/azurepipelines.cake

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public class AzurePipelinesTagInfo : ITagInfo
88
{
99
const string refTags = "refs/tags/";
1010
// at the moment, there is no ability to know is it tag or not
11-
IsTag = azurePipelines.Environment.Repository.SourceBranchName.StartsWith(refTags);
11+
IsTag = azurePipelines.Environment.Repository.SourceBranch.StartsWith(refTags);
1212
Name = IsTag
13-
? azurePipelines.Environment.Repository.SourceBranchName.Substring(refTags.Length)
13+
? azurePipelines.Environment.Repository.SourceBranch.Substring(refTags.Length)
1414
: string.Empty;
1515
}
1616

@@ -21,10 +21,79 @@ public class AzurePipelinesTagInfo : ITagInfo
2121

2222
public class AzurePipelinesRepositoryInfo : IRepositoryInfo
2323
{
24-
public AzurePipelinesRepositoryInfo(IAzurePipelinesProvider azurePipelines)
24+
public AzurePipelinesRepositoryInfo(IAzurePipelinesProvider azurePipelines, ICakeContext context)
2525
{
26-
Branch = azurePipelines.Environment.Repository.SourceBranchName;
2726
Name = azurePipelines.Environment.Repository.RepoName;
27+
28+
// This trimming is not perfect, as it will remove part of a
29+
// branch name if the branch name itself contains a '/'
30+
var tempName = azurePipelines.Environment.Repository.SourceBranch;
31+
const string headPrefix = "refs/heads/";
32+
const string tagPrefix = "refs/tags/";
33+
34+
if (!string.IsNullOrEmpty(tempName))
35+
{
36+
if (tempName.StartsWith(headPrefix))
37+
{
38+
tempName = tempName.Substring(headPrefix.Length);
39+
}
40+
else if (tempName.StartsWith(tagPrefix))
41+
{
42+
var gitTool = context.Tools.Resolve("git");
43+
if (gitTool == null)
44+
{
45+
gitTool = context.Tools.Resolve("git.exe");
46+
}
47+
48+
if (gitTool != null)
49+
{
50+
IEnumerable<string> redirectedStandardOutput;
51+
IEnumerable<string> redirectedError;
52+
53+
var exitCode = context.StartProcess(
54+
gitTool,
55+
new ProcessSettings {
56+
Arguments = "branch -r --contains " + tempName,
57+
RedirectStandardOutput = true,
58+
RedirectStandardError = true,
59+
},
60+
out redirectedStandardOutput,
61+
out redirectedError
62+
);
63+
64+
if (exitCode == 0)
65+
{
66+
var lines = redirectedStandardOutput.ToList();
67+
if (lines.Count == 1)
68+
{
69+
tempName = lines[0].TrimStart(new []{ ' ', '*' }).Replace("origin/", string.Empty);
70+
}
71+
else if(lines.Count > 1)
72+
{
73+
foreach(var line in lines)
74+
{
75+
var trimmedLine = line.TrimStart(new []{ ' ', '*' }).Replace("origin/", string.Empty);
76+
77+
// This is a crude check to make sure that we are not looking at a ref
78+
// to a SHA of the current commit. If it is, we don't want to return that
79+
if (trimmedLine.Length != 40)
80+
{
81+
tempName = trimmedLine;
82+
break;
83+
}
84+
}
85+
}
86+
}
87+
}
88+
}
89+
else if (tempName.IndexOf('/') >= 0)
90+
{
91+
tempName = tempName.Substring(tempName.LastIndexOf('/') + 1);
92+
}
93+
}
94+
95+
Branch = tempName;
96+
2897
Tag = new AzurePipelinesTagInfo(azurePipelines);
2998
}
3099

@@ -57,11 +126,11 @@ public class AzurePipelinesBuildInfo : IBuildInfo
57126

58127
public class AzurePipelinesBuildProvider : IBuildProvider
59128
{
60-
public AzurePipelinesBuildProvider(IAzurePipelinesProvider azurePipelines, ICakeEnvironment environment)
129+
public AzurePipelinesBuildProvider(IAzurePipelinesProvider azurePipelines, ICakeEnvironment environment, ICakeContext context)
61130
{
62131
Build = new AzurePipelinesBuildInfo(azurePipelines);
63132
PullRequest = new AzurePipelinesPullRequestInfo(azurePipelines, environment);
64-
Repository = new AzurePipelinesRepositoryInfo(azurePipelines);
133+
Repository = new AzurePipelinesRepositoryInfo(azurePipelines, context);
65134

66135
_azurePipelines = azurePipelines;
67136
}
@@ -80,6 +149,7 @@ public class AzurePipelinesBuildProvider : IBuildProvider
80149
"BUILD_BUILDID",
81150
"BUILD_BUILDNUMBER",
82151
"BUILD_REPOSITORY_NAME",
152+
"BUILD_SOURCEBRANCH",
83153
"BUILD_SOURCEBRANCHNAME",
84154
"BUILD_SOURCEVERSION",
85155
"SYSTEM_PULLREQUEST_PULLREQUESTNUMBER",

Cake.Recipe/Content/buildProvider.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static IBuildProvider GetBuildProvider(ICakeContext context, BuildSystem
7575
if (buildSystem.IsRunningOnAzurePipelines || buildSystem.IsRunningOnAzurePipelinesHosted)
7676
{
7777
context.Information("Using Azure DevOps Pipelines Provider...");
78-
return new AzurePipelinesBuildProvider(buildSystem.AzurePipelines, context.Environment);
78+
return new AzurePipelinesBuildProvider(buildSystem.AzurePipelines, context.Environment, context);
7979
}
8080

8181
if (buildSystem.IsRunningOnTeamCity)

Cake.Recipe/Content/credentials.cake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,18 @@ public class WyamCredentials
145145

146146
public static GitHubCredentials GetGitHubCredentials(ICakeContext context)
147147
{
148-
return new GitHubCredentials(context.EnvironmentVariable(Environment.GithubTokenVariable));
148+
string token = null;
149+
// if "GithubTokenVariable" is not set, fallback to the gh-cli defaults of GH_TOKEN, GITHUB_TOKEN
150+
var variableNames = new[]{ Environment.GithubTokenVariable, "GH_TOKEN", "GITHUB_TOKEN" };
151+
foreach (var name in variableNames)
152+
{
153+
token = context.EnvironmentVariable(name);
154+
if(!string.IsNullOrEmpty(token))
155+
{
156+
break;
157+
}
158+
}
159+
return new GitHubCredentials(token);
149160
}
150161

151162
public static EmailCredentials GetEmailCredentials(ICakeContext context)

Cake.Recipe/Content/environment.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static class Environment
4747
string wyamDeployRemoteVariable = null,
4848
string wyamDeployBranchVariable = null)
4949
{
50-
GithubTokenVariable = githubTokenVariable ?? "GITHUB_TOKEN";
50+
GithubTokenVariable = githubTokenVariable ?? "GITHUB_PAT";
5151
GitterTokenVariable = gitterTokenVariable ?? "GITTER_TOKEN";
5252
GitterRoomIdVariable = gitterRoomIdVariable ?? "GITTER_ROOM_ID";
5353
SlackTokenVariable = slackTokenVariable ?? "SLACK_TOKEN";

Cake.Recipe/Content/github-actions.cake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,47 @@ public class GitHubActionRepositoryInfo : IRepositoryInfo
3030
// branch name if the branch name itself contains a '/'
3131
var tempName = context.BuildSystem().GitHubActions.Environment.Workflow.Ref;
3232
const string headPrefix = "refs/heads/";
33+
const string tagPrefix = "refs/tags/";
3334
if (!string.IsNullOrEmpty(tempName))
3435
{
3536
if (tempName.StartsWith(headPrefix))
3637
{
3738
tempName = tempName.Substring(headPrefix.Length);
3839
}
40+
else if (tempName.StartsWith(tagPrefix))
41+
{
42+
var gitTool = context.Tools.Resolve("git");
43+
if (gitTool == null)
44+
{
45+
gitTool = context.Tools.Resolve("git.exe");
46+
}
47+
48+
if (gitTool != null)
49+
{
50+
IEnumerable<string> redirectedStandardOutput;
51+
IEnumerable<string> redirectedError;
52+
53+
var exitCode = context.StartProcess(
54+
gitTool,
55+
new ProcessSettings {
56+
Arguments = "branch -r --contains " + tempName,
57+
RedirectStandardOutput = true,
58+
RedirectStandardError = true,
59+
},
60+
out redirectedStandardOutput,
61+
out redirectedError
62+
);
63+
64+
if (exitCode == 0)
65+
{
66+
var lines = redirectedStandardOutput.ToList();
67+
if (lines.Count != 0)
68+
{
69+
tempName = lines[0].TrimStart(new []{ ' ', '*' }).Replace("origin/", string.Empty);
70+
}
71+
}
72+
}
73+
}
3974
else if (tempName.IndexOf('/') >= 0)
4075
{
4176
tempName = tempName.Substring(tempName.LastIndexOf('/') + 1);

Cake.Recipe/Content/gitversion.cake

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,37 @@ public class BuildVersion
5454
{
5555
BuildParameters.Platform.PatchGitLib2ConfigFiles("**/GitVersion*/**/LibGit2Sharp.dll.config");
5656

57+
var gitVersionTool = context.Tools.Resolve("dotnet-gitversion");
58+
if (gitVersionTool == null)
59+
{
60+
gitVersionTool = context.Tools.Resolve("dotnet-gitversion.exe");
61+
}
62+
if (gitVersionTool == null)
63+
{
64+
gitVersionTool = context.Tools.Resolve("GitVersion.exe");
65+
}
66+
67+
if(gitVersionTool != null)
68+
{
69+
context.Information("Confirming what version of GitVersion is being used...");
70+
71+
IEnumerable<string> redirectedStandardOutput;
72+
IEnumerable<string> redirectedError;
73+
var exitCode = context.StartProcess(
74+
gitVersionTool,
75+
new ProcessSettings {
76+
Arguments = "/Version",
77+
RedirectStandardOutput = true,
78+
RedirectStandardError = true
79+
},
80+
out redirectedStandardOutput,
81+
out redirectedError
82+
);
83+
84+
context.Information("Exit code: {0}", exitCode);
85+
context.Information("GitVersion: {0}", string.Join("\r\n", redirectedStandardOutput));
86+
}
87+
5788
context.Information("Calculating Semantic Version...");
5889
if (!BuildParameters.IsLocalBuild || BuildParameters.IsPublishBuild || BuildParameters.IsReleaseBuild || BuildParameters.PrepareLocalRelease)
5990
{
@@ -63,13 +94,15 @@ public class BuildVersion
6394
UpdateAssemblyInfoFilePath = BuildParameters.Paths.Files.SolutionInfoFilePath,
6495
UpdateAssemblyInfo = true,
6596
OutputType = GitVersionOutput.BuildServer,
66-
NoFetch = true
97+
NoFetch = true,
98+
ToolPath = gitVersionTool
6799
});
68100
} else {
69101
context.GitVersion(new GitVersionSettings{
70102
UpdateAssemblyInfoFilePath = BuildParameters.Paths.Files.SolutionInfoFilePath,
71103
UpdateAssemblyInfo = true,
72-
OutputType = GitVersionOutput.BuildServer
104+
OutputType = GitVersionOutput.BuildServer,
105+
ToolPath = gitVersionTool
73106
});
74107
}
75108

@@ -86,11 +119,13 @@ public class BuildVersion
86119
{
87120
assertedVersions = context.GitVersion(new GitVersionSettings{
88121
OutputType = GitVersionOutput.Json,
89-
NoFetch = true
122+
NoFetch = true,
123+
ToolPath = gitVersionTool
90124
});
91125
} else {
92126
assertedVersions = context.GitVersion(new GitVersionSettings{
93127
OutputType = GitVersionOutput.Json,
128+
ToolPath = gitVersionTool
94129
});
95130
}
96131

Cake.Recipe/Content/localbuild.cake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public class LocalBuildRepositoryInfo : IRepositoryInfo
6363
var rootPath = context.GitFindRootFromPath(context.MakeAbsolute(context.Environment.WorkingDirectory));
6464

6565
var gitTool = context.Tools.Resolve("git");
66-
66+
if (gitTool == null)
67+
{
68+
gitTool = context.Tools.Resolve("git.exe");
69+
}
70+
6771
if (gitTool == null)
6872
{
6973
context.Warning("Unable to find git, setting default values for repository properties...");

Cake.Recipe/Content/parameters.cake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,11 @@ public static class BuildParameters
555555
{
556556
BranchType = BranchType.Unknown;
557557
var gitTool = context.Tools.Resolve("git");
558-
558+
if (gitTool == null)
559+
{
560+
gitTool = context.Tools.Resolve("git.exe");
561+
}
562+
559563
if (gitTool != null)
560564
{
561565
IEnumerable<string> redirectedStandardOutput;

Cake.Recipe/Content/toolsettings.cake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ public static class ToolSettings
4040
public static string KuduSyncGlobalTool { get; private set; }
4141

4242
public static void SetToolPreprocessorDirectives(
43-
string codecovTool = "#tool nuget:?package=codecov&version=1.12.3",
43+
string codecovTool = "#tool nuget:?package=codecov&version=1.13.0",
4444
// This is specifically pinned to 0.7.0 as later versions of same package publish .Net Global Tool, rather than full framework version
4545
string coverallsTool = "#tool nuget:?package=coveralls.net&version=0.7.0",
4646
string gitReleaseManagerTool = "#tool nuget:?package=GitReleaseManager&version=0.11.0",
4747
// This is specifically pinned to 5.0.1 as later versions break compatibility with Unix.
4848
string gitVersionTool = "#tool nuget:?package=GitVersion.CommandLine&version=5.0.1",
49-
string reSharperTools = "#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2020.2.4",
49+
string reSharperTools = "#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2020.3.2",
5050
string kuduSyncTool = "#tool nuget:?package=KuduSync.NET&version=1.5.3",
5151
string wyamTool = "#tool nuget:?package=Wyam&version=2.2.9",
5252
string xunitTool = "#tool nuget:?package=xunit.runner.console&version=2.4.1",
53-
string nunitTool = "#tool nuget:?package=NUnit.ConsoleRunner&version=3.11.1",
54-
string nugetTool = "#tool nuget:?package=NuGet.CommandLine&version=5.7.0",
53+
string nunitTool = "#tool nuget:?package=NUnit.ConsoleRunner&version=3.12.0",
54+
string nugetTool = "#tool nuget:?package=NuGet.CommandLine&version=5.8.1",
5555
string openCoverTool = "#tool nuget:?package=OpenCover&version=4.7.922",
56-
string reportGeneratorTool = "#tool nuget:?package=ReportGenerator&version=4.7.1",
56+
string reportGeneratorTool = "#tool nuget:?package=ReportGenerator&version=4.8.5",
5757
string reportUnitTool = "#tool nuget:?package=ReportUnit&version=1.2.1",
58-
string codecovGlobalTool = "#tool dotnet:?package=Codecov.Tool&version=1.12.3",
58+
string codecovGlobalTool = "#tool dotnet:?package=Codecov.Tool&version=1.13.0",
5959
string coverallsGlobalTool = "#tool dotnet:?package=coveralls.net&version=1.0.0",
6060
string gitReleaseManagerGlobalTool = "#tool dotnet:?package=GitReleaseManager.Tool&version=0.11.0",
61-
string gitVersionGlobalTool = "#tool dotnet:?package=GitVersion.Tool&version=5.5.1",
62-
string reportGeneratorGlobalTool = "#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=4.7.1",
61+
string gitVersionGlobalTool = "#tool dotnet:https://www.myget.org/F/gep13/api/v3/index.json?package=GitVersion.Tool&version=5.6.6",
62+
string reportGeneratorGlobalTool = "#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=4.8.5",
6363
string wyamGlobalTool = "#tool dotnet:?package=Wyam.Tool&version=2.2.9",
6464
// This is using an unofficial build of kudusync so that we can have a .Net Global tool version. This was generated from this PR: https://github.com/projectkudu/KuduSync.NET/pull/27
6565
string kuduSyncGlobalTool = "#tool dotnet:https://www.myget.org/F/cake-contrib/api/v3/index.json?package=KuduSync.Tool&version=1.5.4-g3916ad7218"

0 commit comments

Comments
 (0)