Skip to content

Commit

Permalink
feat(components): make ICreateGitHubRelease to fallback to existing r…
Browse files Browse the repository at this point in the history
…elease for distributed asset uploads
  • Loading branch information
matkoch committed Aug 10, 2023
1 parent 280c091 commit 42409f9
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions source/Nuke.Components/ICreateGitHubRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,34 @@ public interface ICreateGitHubRelease : IHazGitRepository, IHazChangelog
Target CreateGitHubRelease => _ => _
.Executes(async () =>
{
GitHubTasks.GitHubClient.Credentials ??= new Credentials(GitHubToken.NotNull());
async Task<Release> GetOrCreateRelease()
{
try
{
return await GitHubTasks.GitHubClient.Repository.Release.Create(
GitRepository.GetGitHubOwner(),
GitRepository.GetGitHubName(),
new NewRelease(Name)
{
Name = Name,
Prerelease = Prerelease,
Draft = Draft,
Body = ChangelogTasks.ExtractChangelogSectionNotes(ChangelogFile).JoinNewLine()
});
var release = await GitHubTasks.GitHubClient.Repository.Release.Create(
GitRepository.GetGitHubOwner(),
GitRepository.GetGitHubName(),
new NewRelease(Name)
}
catch
{
Name = Name,
Prerelease = Prerelease,
Draft = Draft,
Body = ChangelogTasks.ExtractChangelogSectionNotes(ChangelogFile).JoinNewLine()
});
return await GitHubTasks.GitHubClient.Repository.Release.Get(
GitRepository.GetGitHubOwner(),
GitRepository.GetGitHubName(),
Name);
}
}
GitHubTasks.GitHubClient.Credentials ??= new Credentials(GitHubToken.NotNull());
var release = await GetOrCreateRelease();
var uploadTasks = AssetFiles.Select(async x =>
{
Expand Down

0 comments on commit 42409f9

Please sign in to comment.