Skip to content

Commit 152ad7f

Browse files
Update changelog download strategy in workflows
The download strategies used in "docs-changelog-generate.yaml" and "docs-stable.yaml" workflow files are updated to control the number of versions retrieved for the changelog instead of getting all or latest versions. In "Program.cs", changed the condition to accept the "VersionCount" argument and implemented a loop to fetch 'n' latest versions where 'n' is the given argument value.
1 parent f519a53 commit 152ad7f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.github/workflows/docs-changelog-generate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
ref: master
2020

2121
- name: Download changelog
22-
run: ./build.sh --target DocFX_Changelog_Download --LatestVersions true
22+
run: ./build.sh --target DocFX_Changelog_Download --LatestVersions 1
2323
env:
2424
GITHUB_PRODUCT: ChangelogBuilder
2525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docs-stable.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ jobs:
2121
- name: Build BenchmarkDotNet
2222
run: ./build.bat --target Build
2323

24-
# Temporary disabled because of the API limit
25-
# - name: Download changelog
26-
# run: ./build.bat --target DocFX_Changelog_Download --LatestVersions true --StableVersions true
27-
# env:
28-
# GITHUB_PRODUCT: ChangelogBuilder
29-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Download changelog
25+
run: ./build.bat --target DocFX_Changelog_Download --LatestVersions 1
26+
env:
27+
GITHUB_PRODUCT: ChangelogBuilder
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3029

3130
- name: Build documentation
3231
run: ./build.bat --target DocFX_Build

build/Program.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using System.Linq;
34
using System.Text;
@@ -469,22 +470,23 @@ public class DocFxChangelogDownloadTask : FrostingTask<BuildContext>
469470
{
470471
public override void Run(BuildContext context)
471472
{
472-
if (context.Argument("AllVersions", false))
473+
var count = context.Argument("VersionCount", -1);
474+
var total = DocumentationHelper.BdnAllVersions.Length;
475+
476+
if (count == 0)
473477
{
474478
context.DocfxChangelogDownload(
475479
DocumentationHelper.BdnAllVersions.First(),
476480
DocumentationHelper.BdnFirstCommit);
477481

478-
for (int i = 1; i < DocumentationHelper.BdnAllVersions.Length; i++)
482+
for (int i = 1; i < total; i++)
479483
context.DocfxChangelogDownload(
480484
DocumentationHelper.BdnAllVersions[i],
481485
DocumentationHelper.BdnAllVersions[i - 1]);
482486
}
483-
else if (context.Argument("LatestVersions", false))
487+
else if (count > 0)
484488
{
485-
for (int i = DocumentationHelper.BdnAllVersions.Length - 3;
486-
i < DocumentationHelper.BdnAllVersions.Length;
487-
i++)
489+
for (int i = Math.Max(total - count, 1); i < total; i++)
488490
context.DocfxChangelogDownload(
489491
DocumentationHelper.BdnAllVersions[i],
490492
DocumentationHelper.BdnAllVersions[i - 1]);

0 commit comments

Comments
 (0)