17
17
using Cake . Core . IO ;
18
18
using Cake . FileHelpers ;
19
19
using Cake . Frosting ;
20
+ using Cake . Git ;
20
21
21
22
public static class Program
22
23
{
@@ -103,11 +104,11 @@ public BuildContext(ICakeContext context)
103
104
MsBuildSettingsRestore = new DotNetMSBuildSettings ( ) ;
104
105
MsBuildSettingsBuild = new DotNetMSBuildSettings ( ) ;
105
106
MsBuildSettingsPack = new DotNetMSBuildSettings ( ) ;
106
-
107
+
107
108
if ( IsCiBuild )
108
109
{
109
110
System . Environment . SetEnvironmentVariable ( "BDN_CI_BUILD" , "true" ) ;
110
-
111
+
111
112
MsBuildSettingsBuild . MaxCpuCount = 1 ;
112
113
MsBuildSettingsBuild . WithProperty ( "UseSharedCompilation" , "false" ) ;
113
114
}
@@ -152,8 +153,22 @@ public void RunTests(FilePath projectFile, string alias, string tfm)
152
153
this . DotNetTest ( projectFile . FullPath , settings ) ;
153
154
}
154
155
156
+ public void EnsureChangelogDetailsExist ( bool forceClean = false )
157
+ {
158
+ var path = ChangeLogGenDirectory . Combine ( "details" ) ;
159
+ if ( this . DirectoryExists ( path ) && forceClean )
160
+ this . DeleteDirectory ( path , new DeleteDirectorySettings ( ) { Force = true , Recursive = true } ) ;
161
+
162
+ if ( ! this . DirectoryExists ( path ) )
163
+ {
164
+ var settings = new GitCloneSettings { Checkout = true , BranchName = "docs-changelog-details" } ;
165
+ this . GitClone ( "https://github.com/dotnet/BenchmarkDotNet.git" , path , settings ) ;
166
+ }
167
+ }
168
+
155
169
public void DocfxChangelogDownload ( string version , string versionPrevious , string lastCommit = "" )
156
170
{
171
+ EnsureChangelogDetailsExist ( true ) ;
157
172
this . Information ( "DocfxChangelogDownload: " + version ) ;
158
173
// Required environment variables: GITHUB_PRODUCT, GITHUB_TOKEN
159
174
var path = ChangeLogGenDirectory . Combine ( "details" ) ;
@@ -162,6 +177,7 @@ public void DocfxChangelogDownload(string version, string versionPrevious, strin
162
177
163
178
public void DocfxChangelogGenerate ( string version )
164
179
{
180
+ EnsureChangelogDetailsExist ( ) ;
165
181
this . Information ( "DocfxChangelogGenerate: " + version ) ;
166
182
var header = ChangeLogGenDirectory . Combine ( "header" ) . CombineWithFilePath ( version + ".md" ) ;
167
183
var footer = ChangeLogGenDirectory . Combine ( "footer" ) . CombineWithFilePath ( version + ".md" ) ;
@@ -551,4 +567,4 @@ public override void Run(BuildContext context)
551
567
context . RunDocfx ( context . DocfxJsonFile ) ;
552
568
context . GenerateRedirects ( ) ;
553
569
}
554
- }
570
+ }
0 commit comments