Skip to content

Commit 93d12c4

Browse files
[build] Rework changelog generation
- All changelog files (including headers, details, footers) are extracted to branch `docs-changelog`, which is cloned to `docs/_changelog` - Rework build changelog tasks
1 parent 8bf4623 commit 93d12c4

File tree

11 files changed

+318
-286
lines changed

11 files changed

+318
-286
lines changed

.github/workflows/generate-changelog.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919
with:
2020
ref: master
2121

22-
- name: Download changelog
23-
run: ./build.cmd docs-update --depth 1 --preview
22+
- name: Fetch changelog
23+
run: ./build.cmd docs-fetch --depth 1 --preview
2424
env:
2525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2626

2727
- name: Push changelog
2828
uses: JamesIves/[email protected]
2929
with:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
BRANCH: docs-changelog-details
32-
FOLDER: docs/_changelog/details
31+
BRANCH: docs-changelog
32+
FOLDER: docs/_changelog
3333
GIT_CONFIG_NAME: Andrey Akinshin
3434
GIT_CONFIG_EMAIL: [email protected]
3535
CLEAN: true

.github/workflows/generate-gh-pages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
- name: Build BenchmarkDotNet
2323
run: ./build.cmd build
2424

25-
- name: Download changelog
26-
run: ./build.cmd docs-update --depth 1 --preview
25+
- name: Fetch changelog
26+
run: ./build.cmd docs-fetch --depth 1 --preview
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929

build/BenchmarkDotNet.Build/BuildContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public void GenerateFile(FilePath filePath, StringBuilder content)
157157

158158
public void GenerateFile(FilePath filePath, string content, bool reportNoChanges = false)
159159
{
160+
this.EnsureDirectoryExists(filePath.GetDirectory());
160161
var relativePath = RootDirectory.GetRelativePath(filePath);
161162
if (this.FileExists(filePath))
162163
{

build/BenchmarkDotNet.Build/Meta/Repo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class Repo
1212
public const string HttpsUrlBase = $"https://github.com/{Owner}/{Name}";
1313
public const string HttpsGitUrl = $"{HttpsUrlBase}.git";
1414

15-
public const string ChangelogDetailsBranch = "docs-changelog-details";
15+
public const string ChangelogBranch = "docs-changelog";
1616
public const string DocsStableBranch = "docs-stable";
1717
public const string MasterBranch = "master";
1818

build/BenchmarkDotNet.Build/Program.cs

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public HelpInfo GetHelp()
2828
{
2929
return new HelpInfo
3030
{
31-
Examples = new[]
32-
{
31+
Examples =
32+
[
3333
new Example(Name)
34-
}
34+
]
3535
};
3636
}
3737
}
@@ -48,10 +48,10 @@ public HelpInfo GetHelp()
4848
{
4949
return new HelpInfo
5050
{
51-
Examples = new[]
52-
{
51+
Examples =
52+
[
5353
new Example(Name).WithMsBuildArgument("Configuration", "Debug")
54-
}
54+
]
5555
};
5656
}
5757
}
@@ -68,10 +68,10 @@ public HelpInfo GetHelp()
6868
{
6969
return new HelpInfo
7070
{
71-
Examples = new[]
72-
{
71+
Examples =
72+
[
7373
new Example(Name)
74-
}
74+
]
7575
};
7676
}
7777
}
@@ -88,12 +88,12 @@ public HelpInfo GetHelp()
8888
{
8989
return new HelpInfo
9090
{
91-
Examples = new[]
92-
{
91+
Examples =
92+
[
9393
new Example(Name)
9494
.WithArgument(KnownOptions.Exclusive)
9595
.WithArgument(KnownOptions.Verbosity, "Diagnostic")
96-
}
96+
]
9797
};
9898
}
9999
}
@@ -145,68 +145,68 @@ public HelpInfo GetHelp()
145145
{
146146
return new HelpInfo
147147
{
148-
Examples = new[]
149-
{
148+
Examples =
149+
[
150150
new Example(Name)
151151
.WithMsBuildArgument("VersionPrefix", "0.1.1729")
152152
.WithMsBuildArgument("VersionSuffix", "preview"),
153153
new Example(Name).WithArgument(KnownOptions.Stable)
154-
}
154+
]
155155
};
156156
}
157157
}
158158

159159
[TaskName(Name)]
160-
[TaskDescription("Update generated documentation files")]
161-
public class DocsUpdateTask : FrostingTask<BuildContext>, IHelpProvider
160+
[TaskDescription("Fetch changelog files")]
161+
public class DocsFetchTask : FrostingTask<BuildContext>, IHelpProvider
162162
{
163-
private const string Name = "docs-update";
164-
public override void Run(BuildContext context) => context.DocumentationRunner.Update();
163+
private const string Name = "docs-fetch";
164+
public override void Run(BuildContext context) => context.DocumentationRunner.Fetch();
165165

166166
public HelpInfo GetHelp()
167167
{
168168
return new HelpInfo
169169
{
170170
Description = $"This task updates the following files:\n" +
171-
$"* README.md (the number of dependent projects number)\n" +
171+
$"* Clones branch 'docs-changelog' to docs/_changelog\n" +
172172
$"* Last changelog footer (if {KnownOptions.Stable.CommandLineName} is specified)\n" +
173173
$"* All changelog details in docs/_changelog\n" +
174-
$" (This dir is a cloned version of this repo from branch {Repo.ChangelogDetailsBranch})",
175-
Options = new IOption[] { KnownOptions.DocsPreview, KnownOptions.DocsDepth },
176-
EnvironmentVariables = new[] { EnvVar.GitHubToken },
177-
Examples = new[]
178-
{
174+
$" (This dir is a cloned version of this repo from branch {Repo.ChangelogBranch})",
175+
Options = [KnownOptions.DocsPreview, KnownOptions.DocsDepth],
176+
EnvironmentVariables = [EnvVar.GitHubToken],
177+
Examples =
178+
[
179179
new Example(Name)
180180
.WithArgument(KnownOptions.DocsDepth, "3")
181181
.WithArgument(KnownOptions.DocsPreview)
182-
}
182+
]
183183
};
184184
}
185185
}
186186

187187
[TaskName(Name)]
188-
[TaskDescription("Prepare auxiliary documentation files")]
189-
public class DocsPrepareTask : FrostingTask<BuildContext>, IHelpProvider
188+
[TaskDescription("Generate auxiliary documentation files")]
189+
public class DocsGenerateTask : FrostingTask<BuildContext>, IHelpProvider
190190
{
191-
private const string Name = "docs-prepare";
192-
public override void Run(BuildContext context) => context.DocumentationRunner.Prepare();
191+
private const string Name = "docs-generate";
192+
public override void Run(BuildContext context) => context.DocumentationRunner.Generate();
193193

194194
public HelpInfo GetHelp()
195195
{
196196
return new HelpInfo
197197
{
198-
Options = new IOption[] { KnownOptions.DocsPreview },
199-
Examples = new[]
200-
{
198+
Options = [KnownOptions.DocsPreview],
199+
Examples =
200+
[
201201
new Example(Name).WithArgument(KnownOptions.DocsPreview)
202-
}
202+
]
203203
};
204204
}
205205
}
206206

207207
[TaskName(Name)]
208208
[TaskDescription("Build final documentation")]
209-
[IsDependentOn(typeof(DocsPrepareTask))]
209+
[IsDependentOn(typeof(DocsGenerateTask))]
210210
public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
211211
{
212212
private const string Name = "docs-build";
@@ -215,19 +215,20 @@ public class DocsBuildTask : FrostingTask<BuildContext>, IHelpProvider
215215
public HelpInfo GetHelp() => new()
216216
{
217217
Description = "The 'build' task should be run manually to build api docs",
218-
Options = new IOption[] { KnownOptions.DocsPreview },
219-
Examples = new[]
220-
{
218+
Options = [KnownOptions.DocsPreview],
219+
Examples =
220+
[
221221
new Example(Name).WithArgument(KnownOptions.DocsPreview)
222-
}
222+
]
223223
};
224224
}
225225

226226
[TaskName(Name)]
227227
[TaskDescription("Release new version")]
228228
[IsDependentOn(typeof(BuildTask))]
229229
[IsDependentOn(typeof(PackTask))]
230-
[IsDependentOn(typeof(DocsUpdateTask))]
230+
[IsDependentOn(typeof(DocsFetchTask))]
231+
[IsDependentOn(typeof(DocsGenerateTask))]
231232
[IsDependentOn(typeof(DocsBuildTask))]
232233
public class ReleaseTask : FrostingTask<BuildContext>, IHelpProvider
233234
{
@@ -236,17 +237,17 @@ public class ReleaseTask : FrostingTask<BuildContext>, IHelpProvider
236237

237238
public HelpInfo GetHelp() => new()
238239
{
239-
Options = new IOption[] { KnownOptions.NextVersion, KnownOptions.Push },
240-
EnvironmentVariables = new[] { EnvVar.GitHubToken, EnvVar.NuGetToken },
241-
Examples = new[]
242-
{
240+
Options = [KnownOptions.NextVersion, KnownOptions.Push],
241+
EnvironmentVariables = [EnvVar.GitHubToken, EnvVar.NuGetToken],
242+
Examples =
243+
[
243244
new Example(Name)
244245
.WithArgument(KnownOptions.Stable)
245246
.WithArgument(KnownOptions.NextVersion, "0.1.1729")
246247
.WithArgument(KnownOptions.Push),
247248
new Example(Name)
248249
.WithArgument(KnownOptions.Stable)
249250
.WithArgument(KnownOptions.Push)
250-
}
251+
]
251252
};
252253
}

0 commit comments

Comments
 (0)