Skip to content

Commit d9956de

Browse files
committed
(GH-17) Added open to close milestone
- In addition to publishing and closing milestone, my work flow needs the option to simply close the milestone, as the publish will be done manually, which then triggers the final build
1 parent 95ee219 commit d9956de

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="CloseSubOptions.cs" company="gep13">
3+
// Copyright (c) gep13. All rights reserved.
4+
// </copyright>
5+
//-----------------------------------------------------------------------
6+
7+
namespace GitHubReleaseManager.Cli
8+
{
9+
public class CloseSubOptions : CommonSubOptions
10+
{
11+
}
12+
}

Source/GitHubReleaseManager.Cli/GitHubReleaseManager.Cli.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
</ItemGroup>
7676
<ItemGroup>
7777
<Compile Include="AssemblyInfo.cs" />
78+
<Compile Include="CloseSubOptions.cs" />
7879
<Compile Include="CommonSubOptions.cs" />
7980
<Compile Include="CreateSubOptions.cs" />
8081
<Compile Include="InitSubOptions.cs" />

Source/GitHubReleaseManager.Cli/Options.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class Options
1414
[VerbOption("create", HelpText = "Creates a draft release notes from a milestone.")]
1515
public CreateSubOptions CreateVerb { get; set; }
1616

17+
[VerbOption("close", HelpText = "Closes the milestone.")]
18+
public CloseSubOptions CloseVerb { get; set; }
19+
1720
[VerbOption("publish", HelpText = "Publishes the release notes and closes the milestone.")]
1821
public PublishSubOptions PublishVerb { get; set; }
1922

Source/GitHubReleaseManager.Cli/Program.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ private static int Main(string[] args)
3939
result = CreateReleaseAsync((CreateSubOptions)subOptions).Result;
4040
}
4141

42+
if (verb == "close")
43+
{
44+
result = CloseMilestoneAsync((CloseSubOptions)subOptions).Result;
45+
}
46+
4247
if (verb == "publish")
4348
{
44-
result = PublishReleaseAsync((PublishSubOptions)subOptions).Result;
49+
result = CloseAndPublishReleaseAsync((PublishSubOptions)subOptions).Result;
4550
}
4651

4752
if (verb == "init")
@@ -81,7 +86,25 @@ private static async Task<int> CreateReleaseAsync(CreateSubOptions options)
8186
}
8287
}
8388

84-
private static async Task<int> PublishReleaseAsync(PublishSubOptions options)
89+
private static async Task<int> CloseMilestoneAsync(CloseSubOptions options)
90+
{
91+
try
92+
{
93+
var github = options.CreateGitHubClient();
94+
95+
await CloseMilestone(github, options.RepositoryOwner, options.RepositoryName, options.Milestone);
96+
97+
return 0;
98+
}
99+
catch (Exception ex)
100+
{
101+
Console.WriteLine(ex);
102+
103+
return 1;
104+
}
105+
}
106+
107+
private static async Task<int> CloseAndPublishReleaseAsync(PublishSubOptions options)
85108
{
86109
try
87110
{

0 commit comments

Comments
 (0)