Skip to content

Commit

Permalink
chore: comment on resolved issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Dec 4, 2024
1 parent e99a82a commit 5401ee2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build/Build.GitFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ partial class Build
[Parameter] readonly bool Major;

string MajorMinorPatchVersion => Major ? $"{GitVersion.Major + 1}.0.0" : GitVersion.MajorMinorPatch;
string MilestoneTitle => $"v{MajorMinorPatchVersion}";

Target Milestone => _ => _
.Unlisted()
.OnlyWhenStatic(() => GitRepository.IsOnReleaseBranch() || GitRepository.IsOnHotfixBranch())
.Executes(async () =>
{
var milestoneTitle = $"v{MajorMinorPatchVersion}";
var milestone = await GitRepository.GetGitHubMilestone(milestoneTitle);
var milestone = await GitRepository.GetGitHubMilestone(MilestoneTitle);
if (milestone == null)
return;

Expand Down
9 changes: 8 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities;
using Nuke.Components;
Expand Down Expand Up @@ -178,7 +179,13 @@ void DeletePackage(string id, string version)
.Inherit<ICreateGitHubRelease>()
.TriggeredBy<IPublish>()
.ProceedAfterFailure()
.OnlyWhenStatic(() => GitRepository.IsOnMasterBranch());
.OnlyWhenStatic(() => GitRepository.IsOnMasterBranch())
.Executes(async () =>
{
var issues = await GitRepository.GetGitHubMilestoneIssues(MilestoneTitle);
foreach (var issue in issues)
await GitHubActions.Instance.CreateComment(issue.Number, $"Released in {MilestoneTitle}! 🎉");
});

Target Install => _ => _
.DependsOn<IPack>()
Expand Down
10 changes: 10 additions & 0 deletions source/Nuke.Common/Tools/GitHub/GitHubTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ public static async Task<Milestone> GetGitHubMilestone(this GitRepository reposi
return milestones.FirstOrDefault(x => x.Title == name);
}

public static async Task<IReadOnlyList<Issue>> GetGitHubMilestoneIssues(this GitRepository repository, string name)
{
Assert.True(repository.IsGitHubRepository());
var milestone = await repository.GetGitHubMilestone(name).NotNull();
return await GitHubClient.Issue.GetAllForRepository(
repository.GetGitHubOwner(),
repository.GetGitHubName(),
new RepositoryIssueRequest { State = ItemStateFilter.All, Milestone = milestone.Number.ToString() });
}

public static async Task TryCreateGitHubMilestone(this GitRepository repository, string title)
{
try
Expand Down

0 comments on commit 5401ee2

Please sign in to comment.