Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split package publish and changelog publish #60

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions src/dotnet-releaser/ReleaserApp.Publishing.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using DotNetReleaser.Changelog;
using DotNetReleaser.Configuration;

namespace DotNetReleaser;

public partial class ReleaserApp
{
private async Task PublishPackagesAndChangelog(string? nugetApiToken, BuildInformation buildInformation, GitHubDevHostingConfiguration hostingConfiguration,
IDevHosting? devHosting, IDevHosting? devHostingExtra, ChangelogResult? changelog, bool forceUpload)
private async Task PublishPackages(string? nugetApiToken, BuildInformation buildInformation, GitHubDevHostingConfiguration hostingConfiguration,
IDevHosting? devHosting, IDevHosting? devHostingExtra)
{
bool groupStarted = false;
try
Expand All @@ -32,9 +33,6 @@ private async Task PublishPackagesAndChangelog(string? nugetApiToken, BuildInfor
{
var appPackagesToPublish = buildPackageInformation.AppPackages;

// In the case of a build, we still want to upload a draft release notes
await devHosting.UpdateChangelogAndUploadPackages(hostingConfiguration.User, hostingConfiguration.Repo, releaseVersion, changelog, appPackagesToPublish, _config.EnablePublishPackagesInDraft, forceUpload);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in that case, it doesn't upload anymore the packages here no? That would require to split devHosting.UpdateChangelogAndUploadPackages


if (!HasErrors && _config.Brew.Publish)
{
// Log an error if we don't have an extra access for homebrew
Expand All @@ -50,7 +48,7 @@ private async Task PublishPackagesAndChangelog(string? nugetApiToken, BuildInfor
await devHostingExtra.UploadHomebrewFormula(hostingConfiguration.User, _config.Brew.Home, packageInfo, brewFormula);
}
}

if (!HasErrors && _config.Scoop.Publish)
{
// Log an error if we don't have an extra access for homebrew
Expand All @@ -77,4 +75,38 @@ private async Task PublishPackagesAndChangelog(string? nugetApiToken, BuildInfor
}
}
}

private async Task PublishChangelog(BuildInformation buildInformation, GitHubDevHostingConfiguration hostingConfiguration,
IDevHosting? devHosting, ChangelogResult? changelog, bool forceUpload)
{
bool groupStarted = false;
try
{
var buildKind = buildInformation.BuildKind;
var branchName = buildInformation.GitInformation?.BranchName;
var releaseVersion = new ReleaseVersion(buildInformation.Version, IsDraft: buildKind == BuildKind.Build, $"{hostingConfiguration.VersionPrefix}{buildInformation.Version}", branchName is not null ? $"draft-{branchName}" : "draft");

_logger.LogStartGroup($"Publishing Changelog - {releaseVersion}");
groupStarted = true;

if (!HasErrors && devHosting is not null && buildKind == BuildKind.Publish)
{
List<AppPackageInfo> appPackagesToPublish = new List<AppPackageInfo>();
foreach (var (packageInfo, buildPackageInformation) in buildInformation.BuildPackages)
{
appPackagesToPublish.AddRange(buildPackageInformation.AppPackages);
}

// In the case of a build, we still want to upload a draft release notes
await devHosting.UpdateChangelogAndUploadPackages(hostingConfiguration.User, hostingConfiguration.Repo, releaseVersion, changelog, appPackagesToPublish, _config.EnablePublishPackagesInDraft, forceUpload);
}
}
finally
{
if (groupStarted)
{
_logger.LogEndGroup();
}
}
}
}
10 changes: 9 additions & 1 deletion src/dotnet-releaser/ReleaserApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,18 @@ private async Task<bool> RunImpl(string configurationFile, BuildKind buildKind,
// ------------------------------------------------------------------
// Publish all packages NuGet + (deb, zip, rpm, tar...)
// ------------------------------------------------------------------
if (buildInformation.BuildKind == BuildKind.Publish || buildInformation.PublishNuGet)
{
await PublishPackages(nugetApiToken, buildInformation, hostingConfiguration, devHosting, devHostingExtra);
}

// ------------------------------------------------------------------
// Publish changelog
// ------------------------------------------------------------------
// Draft if we are just building and not publishing (to allow to update the changelog)
if (buildInformation.BuildKind == BuildKind.Publish || buildInformation.PublishNuGet)
{
await PublishPackagesAndChangelog(nugetApiToken, buildInformation, hostingConfiguration, devHosting, devHostingExtra, changelog, forceUpload);
await PublishChangelog(buildInformation, hostingConfiguration, devHosting, changelog, forceUpload);
}

// ------------------------------------------------------------------
Expand Down
Loading