File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
src/ModularPipelines.Build Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ using ModularPipelines . Attributes ;
2+ using ModularPipelines . Context ;
3+ using ModularPipelines . Git . Attributes ;
4+ using ModularPipelines . Git . Extensions ;
5+ using ModularPipelines . Git . Options ;
6+ using ModularPipelines . Models ;
7+ using ModularPipelines . Modules ;
8+
9+ namespace ModularPipelines . Build . Modules ;
10+
11+ [ RunOnlyOnBranch ( "main" ) ]
12+ [ RunOnLinuxOnly ]
13+ [ DependsOn < NugetVersionGeneratorModule > ]
14+ public class PushVersionTagModule : Module < CommandResult >
15+ {
16+ protected override async Task < bool > ShouldIgnoreFailures ( IPipelineContext context , Exception exception )
17+ {
18+ var versionInformation = await GetModule < NugetVersionGeneratorModule > ( ) ;
19+
20+ return exception . Message . Contains ( $ "tag 'v{ versionInformation . Value ! } ' already exists") ;
21+ }
22+
23+ protected override async Task < CommandResult ? > ExecuteAsync ( IPipelineContext context , CancellationToken cancellationToken )
24+ {
25+ var versionInformation = await GetModule < NugetVersionGeneratorModule > ( ) ;
26+
27+ await context . Git ( ) . Commands . Tag ( new GitTagOptions
28+ {
29+ Arguments = [ $ "v{ versionInformation . Value ! } "] ,
30+ } , cancellationToken ) ;
31+
32+ return await context . Git ( ) . Commands . Push ( new GitPushOptions
33+ {
34+ Tags = true ,
35+ } , cancellationToken ) ;
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ await PipelineHostBuilder.Create()
4747 . AddModule < DependabotCommitsModule > ( )
4848 . AddModule < PrintEnvironmentVariablesModule > ( )
4949 . AddModule < PrintGitInformationModule > ( )
50+ . AddModule < PushVersionTagModule > ( )
5051 . AddPipelineModuleHooks < MyModuleHooks > ( ) ;
5152
5253 collection . AddSingleton < IGitHubClient > ( sp =>
You can’t perform that action at this time.
0 commit comments