Skip to content

Commit

Permalink
Merge branch 'release/0.13.0'
Browse files Browse the repository at this point in the history
* release/0.13.0:
  (#61) Add override for OpenCover
  (#62) ToLower() to argument
  (maint) Formatting
  (#62) Don't run any unit tests when argument set
  (maint) Correct spelling of NuGet
  (maint) Renamed CanUseGitReleaseManager property
  (#61) Renamed ShouldPublishGitHub
  (#61) Add new criteria to tasks
  (#61) Alphabetical all the things!
  (maint) Renamed all DotNetCore tasks
  (maint) Remove Upload-Artifacts-Task
  • Loading branch information
gep13 committed May 9, 2022
2 parents ff59a53 + 1ac87f7 commit 267332c
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 219 deletions.
52 changes: 18 additions & 34 deletions Chocolatey.Cake.Recipe/Content/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Setup<BuildData>(context =>
context.Log.Verbosity = Verbosity.Diagnostic;
}

RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitVersionGlobalTool : ToolSettings.GitVersionTool, () => {
RequireTool(BuildParameters.IsDotNetBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitVersionGlobalTool : ToolSettings.GitVersionTool, () => {
BuildParameters.SetBuildVersion(
BuildVersion.CalculatingSemanticVersion(
context: Context,
Expand Down Expand Up @@ -74,7 +74,7 @@ BuildParameters.Tasks.RestoreTask = Task("Restore")
});
});

BuildParameters.Tasks.DotNetCoreRestoreTask = Task("DotNetCoreRestore")
BuildParameters.Tasks.DotNetRestoreTask = Task("DotNetRestore")
.IsDependentOn("Clean")
.Does(() =>
{
Expand Down Expand Up @@ -156,9 +156,9 @@ BuildParameters.Tasks.BuildTask = Task("Build")
CopyBuildOutput();
}));

BuildParameters.Tasks.DotNetCoreBuildTask = Task("DotNetCoreBuild")
BuildParameters.Tasks.DotNetBuildTask = Task("DotNetBuild")
.IsDependentOn("Clean")
.IsDependentOn("DotNetCoreRestore")
.IsDependentOn("DotNetRestore")
.Does(() => {
Information("Building {0}", BuildParameters.SolutionFilePath);

Expand Down Expand Up @@ -226,7 +226,7 @@ public void CopyBuildOutput()
Information("AssemblyName: {0}", parsedProject.AssemblyName);
Information("IsLibrary: {0}", parsedProject.IsLibrary());

if (BuildParameters.IsDotNetCoreBuild)
if (BuildParameters.IsDotNetBuild)
{
Information("IsGlobalTool: {0}", parsedProject.IsGlobalTool());
}
Expand Down Expand Up @@ -304,7 +304,7 @@ public void CopyBuildOutput()

foreach (var targetFramework in parsedProject.NetCore.TargetFrameworks)
{
Information("Running DotNetCorePublish for {0}...", project.Path.FullPath);
Information("Running dotnet publish for {0}...", project.Path.FullPath);

DotNetCorePublish(project.Path.FullPath, new DotNetCorePublishSettings {
OutputDirectory = outputFolder.Combine(targetFramework),
Expand Down Expand Up @@ -366,7 +366,7 @@ public void CopyBuildOutput()

foreach (var targetFramework in parsedProject.NetCore.TargetFrameworks)
{
Information("Running DotNetCorePublish for {0}...", project.Path.FullPath);
Information("Running dotnet publish for {0}...", project.Path.FullPath);

DotNetCorePublish(project.Path.FullPath, new DotNetCorePublishSettings {
OutputDirectory = outputFolder.Combine(targetFramework),
Expand Down Expand Up @@ -421,23 +421,7 @@ BuildParameters.Tasks.DefaultTask = Task("Default")
.IsDependentOn("Package");


BuildParameters.Tasks.UploadArtifactsTask = Task("Upload-Artifacts")
.IsDependentOn("Package")
.WithCriteria(() => !BuildParameters.IsLocalBuild || BuildParameters.ForceContinuousIntegration, "Skipping because this is a local build, and force isn't being applied")
.WithCriteria(() => DirectoryExists(BuildParameters.Paths.Directories.NuGetPackages) || DirectoryExists(BuildParameters.Paths.Directories.ChocolateyPackages), "Skipping because no packages to upload")
.Does(() =>
{
// Concatenating FilePathCollections should make sure we get unique FilePaths
foreach (var package in GetFiles(BuildParameters.Paths.Directories.Packages + "/*") +
GetFiles(BuildParameters.Paths.Directories.NuGetPackages + "/*") +
GetFiles(BuildParameters.Paths.Directories.ChocolateyPackages + "/*"))
{
BuildParameters.BuildProvider.UploadArtifact(package);
}
});

BuildParameters.Tasks.ContinuousIntegrationTask = Task("CI")
.IsDependentOn("Upload-Artifacts")
.IsDependentOn("Publish-PreRelease-Packages")
.IsDependentOn("Publish-Release-Packages")
.IsDependentOn("Publish-GitHub-Release")
Expand Down Expand Up @@ -478,25 +462,25 @@ public class Builder

public void Run()
{
BuildParameters.IsDotNetCoreBuild = false;
BuildParameters.IsDotNetBuild = false;

SetupTasks(BuildParameters.IsDotNetCoreBuild);
SetupTasks(BuildParameters.IsDotNetBuild);

_action(BuildParameters.Target);
}

public void RunDotNetCore()
public void RunDotNet()
{
BuildParameters.IsDotNetCoreBuild = true;
BuildParameters.IsDotNetBuild = true;

SetupTasks(BuildParameters.IsDotNetCoreBuild);
SetupTasks(BuildParameters.IsDotNetBuild);

_action(BuildParameters.Target);
}

private static void SetupTasks(bool isDotNetCoreBuild)
private static void SetupTasks(bool isDotNetBuild)
{
var prefix = isDotNetCoreBuild ? "DotNetCore" : "";
var prefix = isDotNetBuild ? "DotNet" : "";

BuildParameters.Tasks.PackageTask.IsDependentOn("Test");
BuildParameters.Tasks.PackageTask.IsDependentOn("Analyze");
Expand All @@ -521,9 +505,9 @@ public class Builder
BuildParameters.Tasks.ConfigurationBuilderTask.IsDependentOn(prefix + "Build");
BuildParameters.Tasks.TestTask.IsDependentOn(prefix + "Build");

if (!isDotNetCoreBuild)
if (!isDotNetBuild)
{
if (BuildParameters.TransifexEnabled)
if (BuildParameters.ShouldRunTransifex)
{
BuildParameters.Tasks.BuildTask.IsDependentOn("Transifex-Pull-Translations");
}
Expand All @@ -541,9 +525,9 @@ public class Builder
}
else
{
if (BuildParameters.TransifexEnabled)
if (BuildParameters.ShouldRunTransifex)
{
BuildParameters.Tasks.DotNetCoreBuildTask.IsDependentOn("Transifex-Pull-Translations");
BuildParameters.Tasks.DotNetBuildTask.IsDependentOn("Transifex-Pull-Translations");
}

BuildParameters.Tasks.PackageTask.IsDependentOn(prefix + "Pack");
Expand Down
18 changes: 9 additions & 9 deletions Chocolatey.Cake.Recipe/Content/gitreleasemanager.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
///////////////////////////////////////////////////////////////////////////////

BuildParameters.Tasks.CreateReleaseNotesTask = Task("Create-Release-Notes")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
.Does(() => RequireTool(BuildParameters.IsDotNetBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanRunGitReleaseManager)
{
var settings = new GitReleaseManagerCreateSettings
{
Expand Down Expand Up @@ -33,8 +33,8 @@ BuildParameters.Tasks.ExportReleaseNotesTask = Task("Export-Release-Notes")
.WithCriteria(() => !BuildParameters.IsPullRequest || BuildParameters.PrepareLocalRelease, "Skipping because this is pull request, and is not preparing local release")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix || BuildParameters.PrepareLocalRelease, "Skipping because this is not a releasable branch, and is not preparing local release")
.WithCriteria(() => BuildParameters.IsTagged || BuildParameters.PrepareLocalRelease, "Skipping because this is not a tagged build, and is not preparing local release")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
.Does(() => RequireTool(BuildParameters.IsDotNetBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanRunGitReleaseManager)
{
if (BuildParameters.ShouldDownloadMilestoneReleaseNotes)
{
Expand Down Expand Up @@ -64,9 +64,9 @@ BuildParameters.Tasks.PublishGitHubReleaseTask = Task("Publish-GitHub-Release")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because this is pull request")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master || BuildParameters.BranchType == BranchType.Release || BuildParameters.BranchType == BranchType.HotFix, "Skipping because this is not a releasable branch")
.WithCriteria(() => BuildParameters.IsTagged, "Skipping because this is not a tagged build")
.WithCriteria(() => BuildParameters.ShouldPublishGitHub, "Skipping because this publishing GitHub Release is disabled via parameters (perhaps the default value?")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
.WithCriteria(() => BuildParameters.ShouldRunGitReleaseManager, "Skipping because this publishing running GitReleaseManager is disabled via parameters (perhaps the default value?")
.Does(() => RequireTool(BuildParameters.IsDotNetBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanRunGitReleaseManager)
{
// Concatenating FilePathCollections should make sure we get unique FilePaths
foreach (var package in GetFiles(BuildParameters.Paths.Directories.Packages + "/*") +
Expand All @@ -92,8 +92,8 @@ BuildParameters.Tasks.PublishGitHubReleaseTask = Task("Publish-GitHub-Release")
});

BuildParameters.Tasks.CreateDefaultLabelsTask = Task("Create-Default-Labels")
.Does(() => RequireTool(BuildParameters.IsDotNetCoreBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanUseGitReleaseManager)
.Does(() => RequireTool(BuildParameters.IsDotNetBuild || BuildParameters.PreferDotNetGlobalToolUsage ? ToolSettings.GitReleaseManagerGlobalTool : ToolSettings.GitReleaseManagerTool, () => {
if (BuildParameters.CanRunGitReleaseManager)
{
GitReleaseManagerLabel(BuildParameters.GitHub.Token, BuildParameters.RepositoryOwner, BuildParameters.RepositoryName);
}
Expand Down
17 changes: 17 additions & 0 deletions Chocolatey.Cake.Recipe/Content/gitversion.cake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ public class BuildVersion

string cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();

if (!BuildParameters.ShouldRunGitVersion)
{
context.Information("Running GitVersion is not enabled, so returning default values...");

return new BuildVersion
{
MajorMinorPatch = "0.1.0",
SemVersion = "0.1.0-alpha.0",
Milestone = "0.1.0",
CakeVersion = cakeVersion,
FileVersion = "0.1.0.0",
PackageVersion = "0.1.0-alpha-20220317-13",
InformationalVersion = "0.1.0-alpha.0+Branch.develop.Sha.528f9bf572a52f0660cbe3f4d109599eab1e9866",
FullSemVersion = "0.1.0-alpha.0",
};
}

try
{
context.Information("Testing to see if valid git repository...");
Expand Down
3 changes: 2 additions & 1 deletion Chocolatey.Cake.Recipe/Content/ilmerge.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
BuildParameters.Tasks.ILMergeTask = Task("Run-ILMerge")
.IsDependeeOf("Copy-Nuspec-Folders")
.WithCriteria(() => BuildParameters.ShouldRunILMerge, "Skipping because ILMerge is not enabled")
.WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on Windows")
.Does(() => RequireTool(ToolSettings.ILMergeTool, () =>
{
Expand All @@ -16,7 +17,7 @@ BuildParameters.Tasks.ILMergeTask = Task("Run-ILMerge")

Information("Running ILMerge...");
ILMerge(ilMergeConfig.Output, ilMergeConfig.PrimaryAssemblyName, ilMergeConfig.AssemblyPaths, settings);

if (FileExists(ilMergeConfig.LogFile))
{
BuildParameters.BuildProvider.UploadArtifact(ilMergeConfig.LogFile);
Expand Down
14 changes: 8 additions & 6 deletions Chocolatey.Cake.Recipe/Content/packages.cake
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ BuildParameters.Tasks.CreateNuGetPackagesTask = Task("Create-NuGet-Packages")
}
});

BuildParameters.Tasks.DotNetCorePackTask = Task("DotNetCorePack")
.IsDependentOn("DotNetCoreBuild")
.WithCriteria(() => BuildParameters.ShouldRunDotNetCorePack, "Skipping because packaging through .NET Core is disabled")
BuildParameters.Tasks.DotNetPackTask = Task("DotNetPack")
.IsDependentOn("DotNetBuild")
.WithCriteria(() => BuildParameters.ShouldRunDotNetPack, "Skipping because packaging through .NET Core is disabled")
.Does(() =>
{
var projects = GetFiles(BuildParameters.SourceDirectoryPath + "/**/*.csproj")
Expand All @@ -119,7 +119,7 @@ BuildParameters.Tasks.DotNetCorePackTask = Task("DotNetCorePack")
.WithProperty("FileVersion", BuildParameters.Version.FileVersion)
.WithProperty("AssemblyInformationalVersion", BuildParameters.Version.InformationalVersion);

if (BuildParameters.ShouldBuildNugetSourcePackage)
if (BuildParameters.ShouldBuildNuGetSourcePackage)
{
msBuildSettings.WithProperty("SymbolPackageFormat", "snupkg");
}
Expand All @@ -130,8 +130,8 @@ BuildParameters.Tasks.DotNetCorePackTask = Task("DotNetCorePack")
Configuration = BuildParameters.Configuration,
OutputDirectory = BuildParameters.Paths.Directories.NuGetPackages,
MSBuildSettings = msBuildSettings,
IncludeSource = BuildParameters.ShouldBuildNugetSourcePackage,
IncludeSymbols = BuildParameters.ShouldBuildNugetSourcePackage,
IncludeSource = BuildParameters.ShouldBuildNuGetSourcePackage,
IncludeSymbols = BuildParameters.ShouldBuildNuGetSourcePackage,
};

foreach (var project in projects)
Expand All @@ -141,6 +141,7 @@ BuildParameters.Tasks.DotNetCorePackTask = Task("DotNetCorePack")
});

BuildParameters.Tasks.PublishPreReleasePackagesTask = Task("Publish-PreRelease-Packages")
.WithCriteria(() => BuildParameters.ShouldPublishPreReleasePackages, "Skipping because publishing of pre-release packages is not enabled")
.WithCriteria(() => !BuildParameters.IsLocalBuild || BuildParameters.ForceContinuousIntegration, "Skipping because this is a local build, and force isn't being applied")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because current build is from a Pull Request")
.WithCriteria(() => !BuildParameters.IsTagged, "Skipping because current commit is tagged")
Expand All @@ -162,6 +163,7 @@ BuildParameters.Tasks.PublishPreReleasePackagesTask = Task("Publish-PreRelease-P
});

BuildParameters.Tasks.PublishReleasePackagesTask = Task("Publish-Release-Packages")
.WithCriteria(() => BuildParameters.ShouldPublishReleasePackages, "Skipping because publishing of release packages is not enabled")
.WithCriteria(() => !BuildParameters.IsLocalBuild || BuildParameters.ForceContinuousIntegration, "Skipping because this is a local build, and force isn't being applied")
.WithCriteria(() => !BuildParameters.IsPullRequest, "Skipping because current build is from a Pull Request")
.WithCriteria(() => BuildParameters.IsTagged, "Skipping because current commit is not tagged")
Expand Down
Loading

0 comments on commit 267332c

Please sign in to comment.