Skip to content

Commit

Permalink
(build) Updated Cake.Frosting to version 0.34.1 (#1978)
Browse files Browse the repository at this point in the history
* (build) Updated Cake.Frosting to version 0.34.1

* Update GritVersion from 3.6.2 to 5.0.0
  • Loading branch information
devlead authored and shiftkey committed Aug 1, 2019
1 parent 8fcb731 commit 01d5c87
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 34 deletions.
6 changes: 4 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
mode: ContinuousDeployment
branches:
master:
mode: ContinuousDeployment
increment: Minor
tag: beta
dotnetcore:
develop:
mode: ContinuousDeployment
increment: Minor
tag: alpha
source-branches: ['dotnetcore']
ignore:
sha: []
sha: []
2 changes: 1 addition & 1 deletion build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="0.31.0" />
<PackageReference Include="Cake.Frosting" Version="0.34.1" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions build/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class Context : FrostingContext

public Project[] Projects { get; set; }

public FilePath GitVersionToolPath { get; set; }

public DotNetCoreTestSettings GetTestSettings()
{
var settings = new DotNetCoreTestSettings
Expand Down
4 changes: 3 additions & 1 deletion build/Lifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ public override void Setup(Context context)
else
{
context.Information("Installing tools...");
ToolInstaller.Install(context, "GitVersion.CommandLine", "3.6.2");
ToolInstaller.Install(context, "Octokit.CodeFormatter", "1.0.0-preview");
}


context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.0.0", "dotnet-gitversion");

// Calculate semantic version.
context.Version = BuildVersion.Calculate(context);
context.Version.Prefix = context.Argument<string>("version", context.Version.Prefix);
Expand Down
5 changes: 0 additions & 5 deletions build/Utilities/BuildVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public string GetSemanticVersion()
public static BuildVersion Calculate(Context context)
{
context.Information("Calculating semantic version...");
if (context.CoreOnly)
{
context.Information("Skipping GitVersion query for local build");
return new BuildVersion("0.0.0", "dev");
}

if (!context.IsLocalBuild)
{
Expand Down
28 changes: 6 additions & 22 deletions build/Utilities/GitVersionRunner.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.Tools.GitVersion;
using Cake.Core;
using Cake.Common.Tools.GitVersion;

public static class GitVersionRunner
{
public static GitVersion Run(ICakeContext context, GitVersionOutput outputType)
public static GitVersion Run(Context context, GitVersionOutput outputType)
{
if (context.IsRunningOnWindows())
return context.GitVersion(new GitVersionSettings
{
return context.GitVersion(new GitVersionSettings
{
OutputType = outputType
});
}
else
{
// On non windows platform, point the GitVersion task at our wrapper script that uses mono to run GitVersion.exe
context.Information("Overriding GitVersion ToolPath to /bin/sh ./tools/gitversion_wrapper.sh");
return context.GitVersion(new GitVersionSettings
{
OutputType = outputType,
ToolPath = "/bin/sh",
ArgumentCustomization = args => args.Prepend("./tools/gitversion_wrapper.sh")
});
}
OutputType = outputType,
ToolPath = context.GitVersionToolPath
});
}
}
64 changes: 62 additions & 2 deletions build/Utilities/ToolInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,76 @@
using Cake.Common.Tools.NuGet;
using Cake.Common.IO;
using Cake.Common.Tools.DotNetCore;
using Cake.Common.Tools.DotNetCore.Tool;
using Cake.Common.Tools.NuGet;
using Cake.Common.Tools.NuGet.Install;
using Cake.Core;
using Cake.Core.IO;

public static class ToolInstaller
{
private static DirectoryPath ToolsPath { get; } = "./tools";
public static void Install(ICakeContext context, string package, string version)
{
context.NuGetInstall(package, new NuGetInstallSettings
{
Version = version,
ExcludeVersion = true,
OutputDirectory = "./tools"
OutputDirectory = ToolsPath
});
}

public static FilePath DotNetCoreToolInstall(
this ICakeContext context,
string package,
string version,
string toolName)
{
context.EnsureDirectoryExists(ToolsPath);

var toolsPath = context.MakeAbsolute(ToolsPath);

var toolInstallPath = toolsPath
.Combine(".store")
.Combine(package.ToLowerInvariant())
.Combine(version.ToLowerInvariant());

var toolPath = toolsPath.CombineWithFilePath(
string.Concat(
toolName,
context.Environment.Platform.IsUnix()
? string.Empty
: ".exe"
)
);

if (!context.DirectoryExists(toolInstallPath) && context.FileExists(toolPath))
{
context.DotNetCoreTool("tool", new DotNetCoreToolSettings
{
ArgumentCustomization = args => args
.Append("uninstall")
.AppendSwitchQuoted("--tool-path", toolsPath.FullPath)
.AppendQuoted(package)
});
}

if (!context.FileExists(toolPath))
{
context.DotNetCoreTool("tool", new DotNetCoreToolSettings
{
ArgumentCustomization = args => args
.Append("install")
.AppendSwitchQuoted("--version", version)
.AppendSwitchQuoted("--tool-path", toolsPath.FullPath)
.AppendQuoted(package)
});
}

if (!context.FileExists(toolPath))
{
throw new System.Exception($"Failed to install .NET Core tool {package} ({version}).");
}

return toolPath;
}
}
1 change: 0 additions & 1 deletion tools/gitversion_wrapper.sh

This file was deleted.

0 comments on commit 01d5c87

Please sign in to comment.