11using System . Text ;
2- using ModularPipelines . Context ;
3- using ModularPipelines . Modules ;
2+ using Build . Options ;
3+ using Microsoft . Extensions . Options ;
44using ModularPipelines . Attributes ;
5- using ModularPipelines . Git . Extensions ;
6- using ModularPipelines . Git . Options ;
5+ using ModularPipelines . Context ;
76using ModularPipelines . GitHub . Extensions ;
7+ using ModularPipelines . Modules ;
88
99namespace Build . Modules ;
1010
1111[ DependsOn < CreateChangelogModule > ]
12- public sealed class CreateGitHubChangelogModule : Module < string >
12+ public sealed class CreateGitHubChangelogModule ( IOptions < BuildOptions > buildOptions ) : Module < string >
1313{
1414 protected override async Task < string ? > ExecuteAsync ( IPipelineContext context , CancellationToken cancellationToken )
1515 {
@@ -19,24 +19,15 @@ public sealed class CreateGitHubChangelogModule : Module<string>
1919 return changelog . ToString ( ) ;
2020 }
2121
22- private static async Task < StringBuilder > AppendGitHubCompareUrlAsync ( IPipelineContext context , StringBuilder changelog )
22+ private async Task < StringBuilder > AppendGitHubCompareUrlAsync ( IPipelineContext context , StringBuilder changelog )
2323 {
24- var tagCommand = await context . Git ( ) . Commands . Tag ( new GitTagOptions
25- {
26- List = true ,
27- Sort = "v:refname"
28- } ) ;
29-
30- var tags = tagCommand . StandardOutput . Split ( Environment . NewLine ) ;
31- if ( tags . Length < 2 ) return changelog ;
32-
33- var repositoryName = context . GitHub ( ) . RepositoryInfo . Identifier ;
34- var previousTag = tags [ ^ 2 ] ;
35- var latestTag = tags [ ^ 1 ] ;
24+ var repositoryInfo = context . GitHub ( ) . RepositoryInfo ;
25+ var repositoryId = long . Parse ( context . GitHub ( ) . EnvironmentVariables . RepositoryId ! ) ;
26+ var latestRelease = await context . GitHub ( ) . Client . Repository . Release . GetLatest ( repositoryId ) ;
3627
3728 if ( changelog [ ^ 1 ] != '\r ' || changelog [ ^ 1 ] != '\n ' ) changelog . AppendLine ( Environment . NewLine ) ;
3829 changelog . Append ( "Full changelog: " ) ;
39- changelog . Append ( $ "https://github.com/{ repositoryName } /compare/{ previousTag } ...{ latestTag } ") ;
30+ changelog . Append ( $ "https://github.com/{ repositoryInfo . Identifier } /compare/{ latestRelease . TagName } ...{ buildOptions . Value . Version } ") ;
4031
4132 return changelog ;
4233 }
0 commit comments