Skip to content

Commit

Permalink
Merge pull request #1074 from nunit/issue-1072
Browse files Browse the repository at this point in the history
Code to perform a production release on GitHub
  • Loading branch information
CharliePoole committed Jan 3, 2022
2 parents 84f4a2e + b0bca52 commit 32b9434
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
37 changes: 33 additions & 4 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ Task("PublishToMyGet")
.Description("Publish packages to MyGet")
.Does(() =>
{
if (!ShouldPublishToMyGet())
if (!ShouldPublishToMyGet)
Information("Nothing to publish to MyGet from this run.");
else
{
Expand Down Expand Up @@ -516,7 +516,7 @@ Task("PublishToNuGet")
.Description("Publish packages to NuGet")
.Does(() =>
{
if (!ShouldPublishToNuGet())
if (!ShouldPublishToNuGet)
Information("Nothing to publish to NuGet from this run.");
else
{
Expand All @@ -541,7 +541,7 @@ Task("PublishToChocolatey")
.Description("Publish packages to Chocolatey")
.Does(() =>
{
if (!ShouldPublishToChocolatey())
if (!ShouldPublishToChocolatey)
Information("Nothing to publish to Chocolatey from this run.");
else
{
Expand Down Expand Up @@ -611,6 +611,34 @@ Task("CreateDraftRelease")
}
});

//////////////////////////////////////////////////////////////////////
// CREATE A PRODUCTION RELEASE
//////////////////////////////////////////////////////////////////////

Task("CreateProductionRelease")
.Does(() =>
{
if (IsProductionRelease)
{
string token = EnvironmentVariable(GITHUB_ACCESS_TOKEN);
string tagName = ProductVersion;
var assetList = new List<string>();
foreach (var package in AllPackages)
assetList.Add(PACKAGE_DIR + package.PackageName);
string assets = $"\"{string.Join(',', assetList.ToArray())}\"";
Information($"Publishing release {tagName} to GitHub");
GitReleaseManagerAddAssets(token, GITHUB_OWNER, GITHUB_REPO, tagName, assets);
GitReleaseManagerClose(token, GITHUB_OWNER, GITHUB_REPO, tagName);
}
else
{
Information("Skipping CreateProductionRelease because this is not a production release");
}
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -655,7 +683,8 @@ Task("Appveyor")
.Description("Target we run in our AppVeyor CI")
.IsDependentOn("BuildTestAndPackage")
.IsDependentOn("PublishPackages")
.IsDependentOn("CreateDraftRelease");
.IsDependentOn("CreateDraftRelease")
.IsDependentOn("CreateProductionRelease");

Task("Default")
.Description("Builds the engine and console runner")
Expand Down
9 changes: 5 additions & 4 deletions cake/utilities.cake
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ private void CheckPackageExists(FilePath package)
$"Package not found: {package.GetFilename()}.\nCode may have changed since package was last built.");
}

public bool IsPreRelease() => !string.IsNullOrEmpty(PreReleaseLabel);
public bool IsPreRelease => !string.IsNullOrEmpty(PreReleaseLabel);

public bool ShouldPublishToMyGet() => IsPreRelease() && LABELS_WE_PUBLISH_ON_MYGET.Contains(PreReleaseLabel);
public bool ShouldPublishToNuGet() => !IsPreRelease() || LABELS_WE_PUBLISH_ON_NUGET.Contains(PreReleaseLabel);
public bool ShouldPublishToChocolatey() => !IsPreRelease() || LABELS_WE_PUBLISH_ON_CHOCOLATEY.Contains(PreReleaseLabel);
public bool ShouldPublishToMyGet => IsPreRelease && LABELS_WE_PUBLISH_ON_MYGET.Contains(PreReleaseLabel);
public bool ShouldPublishToNuGet => !IsPreRelease || LABELS_WE_PUBLISH_ON_NUGET.Contains(PreReleaseLabel);
public bool ShouldPublishToChocolatey => !IsPreRelease || LABELS_WE_PUBLISH_ON_CHOCOLATEY.Contains(PreReleaseLabel);
public bool IsProductionRelease => !IsPreRelease || LABELS_WE_RELEASE_ON_GITHUB.Contains(PreReleaseLabel);
2 changes: 1 addition & 1 deletion src/NUnitConsole/ConsoleVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

[assembly: AssemblyProduct("NUnit Console Runner")]
[assembly: AssemblyVersion("3.14.0")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00038-issue-1070")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00040-issue-1072")]
2 changes: 1 addition & 1 deletion src/NUnitEngine/EngineApiVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

[assembly: AssemblyProduct("NUnit Engine API")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00038-issue-1070")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00040-issue-1072")]
[assembly: AssemblyFileVersion("3.13.0")]
2 changes: 1 addition & 1 deletion src/NUnitEngine/EngineVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

[assembly: AssemblyProduct("NUnit Engine")]
[assembly: AssemblyVersion("3.14.0")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00038-issue-1070")]
[assembly: AssemblyInformationalVersion("3.14.0-ci00040-issue-1072")]

0 comments on commit 32b9434

Please sign in to comment.