Skip to content

Commit

Permalink
Fix draft release by disabling them in build
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Mar 6, 2022
1 parent 244c33e commit b47888f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
21 changes: 5 additions & 16 deletions src/dotnet-releaser/DevHosting/GitHubDevHosting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,33 +258,22 @@ public async Task CreateOrUpdateRelease(string user, string repo, ReleaseVersion

private async Task<Release> CreateOrUpdateReleaseImpl(string user, string repo, ReleaseVersion version, ChangelogResult? changelog)
{
string versionTagForDraft = version.DraftName;
var tag = version.IsDraft ? versionTagForDraft : version.Tag;
//string versionTagForDraft = version.DraftName;
//var tag = version.IsDraft ? versionTagForDraft : version.Tag;
var tag = version.Tag;

// Always try to update the previous draft
Release? release = null;
try
{
release = await _client.Repository.Release.Get(user, repo, versionTagForDraft);
// If not found, try to see if we have already a release for this tag.
release = await _client.Repository.Release.Get(user, repo, tag);
}
catch (NotFoundException)
{
// ignore
}

if (!version.IsDraft && release is null)
{
try
{
// If not found, try to see if we have already a release for this tag.
release = await _client.Repository.Release.Get(user, repo, version.Tag);
}
catch (NotFoundException)
{
// ignore
}
}

if (release is null)
{
_log.Info(version.IsDraft ? $"Creating draft release {tag}" : $"Creating release with tag {tag}");
Expand Down
29 changes: 16 additions & 13 deletions src/dotnet-releaser/ReleaserApp.Publishing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@ private async Task PublishPackagesAndChangelog(string? nugetApiToken, BuildInfor
}
}
}
else if (buildKind == BuildKind.Build)
{
if (devHosting is not null && !_config.Changelog.DisableDraftForBuild && buildInformation.AllowPublishDraft)
{
_logger.LogStartGroup(_config.EnablePublishPackagesInDraft ? $"Publishing Draft Changelog and App Packages - {releaseVersion}" : $"Publishing Draft Changelog - {releaseVersion}");
groupStarted = true;
foreach (var (packageInfo, buildPackageInformation) in buildInformation.BuildPackages)
{
var appPackagesToPublish = buildPackageInformation.AppPackages;
await devHosting.UpdateChangelogAndUploadPackages(hostingConfiguration.User, hostingConfiguration.Repo, releaseVersion, changelog, appPackagesToPublish, _config.EnablePublishPackagesInDraft);
}
}
}

// Disable publishing draft release for now as we can't list draft release anymore

//else if (buildKind == BuildKind.Build)
//{
// if (devHosting is not null && !_config.Changelog.DisableDraftForBuild && buildInformation.AllowPublishDraft)
// {
// _logger.LogStartGroup(_config.EnablePublishPackagesInDraft ? $"Publishing Draft Changelog and App Packages - {releaseVersion}" : $"Publishing Draft Changelog - {releaseVersion}");
// groupStarted = true;
// foreach (var (packageInfo, buildPackageInformation) in buildInformation.BuildPackages)
// {
// var appPackagesToPublish = buildPackageInformation.AppPackages;
// await devHosting.UpdateChangelogAndUploadPackages(hostingConfiguration.User, hostingConfiguration.Repo, releaseVersion, changelog, appPackagesToPublish, _config.EnablePublishPackagesInDraft);
// }
// }
//}
}
finally
{
Expand Down
5 changes: 4 additions & 1 deletion src/dotnet-releaser/ReleaserApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ private async Task<bool> RunImpl(string configurationFile, BuildKind buildKind,
// Publish all packages NuGet + (deb, zip, rpm, tar...)
// ------------------------------------------------------------------
// Draft if we are just building and not publishing (to allow to update the changelog)
await PublishPackagesAndChangelog(nugetApiToken, buildInformation, hostingConfiguration, devHosting, devHostingExtra, changelog);
if (buildInformation.BuildKind == BuildKind.Publish)
{
await PublishPackagesAndChangelog(nugetApiToken, buildInformation, hostingConfiguration, devHosting, devHostingExtra, changelog);
}

// ------------------------------------------------------------------
// Publish coverage results + (deb, zip, rpm, tar...)
Expand Down

0 comments on commit b47888f

Please sign in to comment.