Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Jul 9, 2023
2 parents 7728438 + 54d7762 commit 2221be1
Show file tree
Hide file tree
Showing 57 changed files with 757 additions and 245 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.3.0",
"version": "3.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Any new code should also have reasonable unit test coverage.
you talk about a feature you would like to see (or a bug), and why it should be in Cake.
* If approved through the GitHub discussions, ensure an accompanying GitHub issue is created with
information and a link back to the discussion.
* Once you get a nod from one of the [Cake Team](https://github.com/cake-build?tab=members), you can start on the feature.
* Once you get a nod from one of the [Cake Team](https://github.com/orgs/cake-build/people), you can start on the feature.
* Alternatively, if a feature is on the issues list with the
[Up For Grabs](https://github.com/cake-build/cake/labels/up-for-grabs) label,
it is open for a community member (contributor) to patch. You should comment that you are signing up for it on
Expand Down
20 changes: 20 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
### New in 3.1.0 (Released 2023/07/09)

* 4122 Call multiple tasks from CLI in Frosting.
* 4092 Add support for getting the user's home directory in the Cake Environment.
* 4184 Update Autofac to 7.0.1.
* 4183 Update System.Reflection.Metadata to 7.0.2.
* 4182 Update Basic.Reference.Assemblies.Net60/Net70 to 1.4.2.
* 4181 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.6.0.
* 4170 Update NuGet.* to v6.6.1.
* 4138 Upgrade Spectre.Console to v0.46.0.
* 4109 Add PublishReadyToRun to DotNetRestoreSettings.
* 4107 DotNetPublishSettings is missing a way to set the --os option.
* 4090 Update Microsoft.CodeAnalysis.CSharp.Scripting to v4.4.0.
* 4087 Update Newtonsoft.Json to v13.0.2.
* 4086 Update Autofac to v6.5.0.
* 4085 Update NuGet.* to v6.4.0.
* 1317 CleanDirectory does not clean readonly files.
* 4095 Fix broken link to Cake Team on CONTRIBUTING.md.
* 4128 Inconsistent determination of positional Argument when using context.Arguments versus context.Argument.

### New in 3.0.0 (Released 2022/11/08)

* 4046 Add typed data context CakeTaskBuilder.Finally overload.
Expand Down
107 changes: 42 additions & 65 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Install addins.
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=2.0.0"
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Gitter&version=2.0.0"
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=3.0.0"

// Install .NET Core Global tools.
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.10.3"
#tool "dotnet:https://api.nuget.org/v3/index.json?package=SignClient&version=1.3.155"
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.12.1"
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0"
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.13.0"
#tool "dotnet:https://api.nuget.org/v3/index.json?package=sign&version=0.9.1-beta.23274.1&prerelease"

// Load other scripts.
#load "./build/parameters.cake"
Expand All @@ -30,6 +29,11 @@ Setup<BuildParameters>(context =>
parameters.Version.CakeVersion,
parameters.IsTagged);
if (parameters.ShouldSignPackages && !parameters.CodeSigning.HasCredentials)
{
throw new CakeException("Code signing credentials are missing.");
}
foreach(var assemblyInfo in GetFiles("./src/**/AssemblyInfo.cs"))
{
CreateAssemblyInfo(
Expand All @@ -54,25 +58,6 @@ Teardown<BuildParameters>((context, parameters) =>
{
TwitterSendTweet(parameters.Twitter.ConsumerKey, parameters.Twitter.ConsumerSecret, parameters.Twitter.AccessToken, parameters.Twitter.AccessTokenSecret, message);
}
if(parameters.CanPostToGitter)
{
var gitterMessage = $"@/all {message}";
var postMessageResult = Gitter.Chat.PostMessage(
message: gitterMessage,
messageSettings: new GitterChatMessageSettings { Token = parameters.Gitter.Token, RoomId = parameters.Gitter.RoomId}
);
if (postMessageResult.Ok)
{
Information("Message {0} successfully sent", postMessageResult.TimeStamp);
}
else
{
Error("Failed to send message: {0}", postMessageResult.Error);
}
}
}
}
Expand Down Expand Up @@ -165,52 +150,44 @@ Task("Create-NuGet-Packages")

Task("Sign-Binaries")
.IsDependentOn("Create-NuGet-Packages")
.WithCriteria<BuildParameters>((context, parameters) =>
(parameters.ShouldPublish && !parameters.SkipSigning) ||
StringComparer.OrdinalIgnoreCase.Equals(EnvironmentVariable("SIGNING_TEST"), "True"))
.Does<BuildParameters>((context, parameters) =>
.WithCriteria<BuildParameters>(static (context, parameters) => parameters.ShouldSignPackages)
.Does<BuildParameters>(static (context, parameters) =>
{
// Get the secret.
var secret = EnvironmentVariable("SIGNING_SECRET");
if(string.IsNullOrWhiteSpace(secret)) {
throw new InvalidOperationException("Could not resolve signing secret.");
}
// Get the user.
var user = EnvironmentVariable("SIGNING_USER");
if(string.IsNullOrWhiteSpace(user)) {
throw new InvalidOperationException("Could not resolve signing user.");
}
var settings = File("./signclient.json");
var filter = File("./signclient.filter");
// Get the files to sign.
var files = GetFiles(string.Concat(parameters.Paths.Directories.NuGetRoot, "/", "*.nupkg"));
foreach(var file in files)
{
Information("Signing {0}...", file.FullPath);
var files = context.GetFiles(string.Concat(parameters.Paths.Directories.NuGetRoot, "/", "*.nupkg"));
var commandSettings = new CommandSettings{
ToolExecutableNames = new [] { "sign", "sign.exe" },
ToolName = "sign",
ToolPath = parameters.Paths.SignClientPath.FullPath
};
Parallel.ForEach(
files,
file => {
context.Information("Signing {0}...", file.FullPath);
// Build the argument list.
var arguments = new ProcessArgumentBuilder()
.Append("sign")
.AppendSwitchQuoted("-c", MakeAbsolute(settings.Path).FullPath)
.AppendSwitchQuoted("-i", MakeAbsolute(file).FullPath)
.AppendSwitchQuoted("-f", MakeAbsolute(filter).FullPath)
.AppendSwitchQuotedSecret("-s", secret)
.AppendSwitchQuotedSecret("-r", user)
.AppendSwitchQuoted("-n", "Cake")
.AppendSwitchQuoted("-d", "Cake (C# Make) is a cross platform build automation system.")
.AppendSwitchQuoted("-u", "https://cakebuild.net");
// Sign the binary.
var result = StartProcess(parameters.Paths.SignClientPath.FullPath, new ProcessSettings { Arguments = arguments });
if(result != 0)
{
// We should not recover from this.
throw new InvalidOperationException("Signing failed!");
}
}
.Append("code")
.Append("azure-key-vault")
.AppendQuoted(file.FullPath)
.AppendSwitchQuoted("--file-list", parameters.Paths.SignFilterPath.FullPath)
.AppendSwitchQuoted("--publisher-name", "Cake")
.AppendSwitchQuoted("--description", "Cake (C# Make) is a cross platform build automation system.")
.AppendSwitchQuoted("--description-url", "https://cakebuild.net")
.AppendSwitchQuotedSecret("--azure-key-vault-tenant-id", parameters.CodeSigning.SignTenantId)
.AppendSwitchQuotedSecret("--azure-key-vault-client-id", parameters.CodeSigning.SignClientId)
.AppendSwitchQuotedSecret("--azure-key-vault-client-secret", parameters.CodeSigning.SignClientSecret)
.AppendSwitchQuotedSecret("--azure-key-vault-certificate", parameters.CodeSigning.SignKeyVaultCertificate)
.AppendSwitchQuotedSecret("--azure-key-vault-url", parameters.CodeSigning.SignKeyVaultUrl);
context.Command(
commandSettings,
arguments
);
context.Information("Done signing {0}.", file.FullPath);
});
});

Task("Upload-AppVeyor-Artifacts")
Expand Down
43 changes: 32 additions & 11 deletions build/credentials.cake
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
public record CodeSigningCredentials(
string SignTenantId,
string SignClientId,
string SignClientSecret,
string SignKeyVaultCertificate,
string SignKeyVaultUrl
)
{
public bool HasCredentials
{
get
{
return
!string.IsNullOrEmpty(SignTenantId) &&
!string.IsNullOrEmpty(SignClientId) &&
!string.IsNullOrEmpty(SignClientSecret) &&
!string.IsNullOrEmpty(SignKeyVaultCertificate) &&
!string.IsNullOrEmpty(SignKeyVaultUrl);
}
}

public static CodeSigningCredentials GetCodeSigningCredentials(ICakeContext context)
{
return new CodeSigningCredentials(
SignTenantId: context.EnvironmentVariable("SIGN_TENANT_ID"),
SignClientId: context.EnvironmentVariable("SIGN_CLIENT_ID"),
SignClientSecret: context.EnvironmentVariable("SIGN_CLIENT_SECRET"),
SignKeyVaultCertificate: context.EnvironmentVariable("SIGN_KEYVAULT_CERTIFICATE"),
SignKeyVaultUrl: context.EnvironmentVariable("SIGN_KEYVAULT_URL"));
}
}

public record BuildCredentials(string Token)
{
public static BuildCredentials GetGitHubCredentials(ICakeContext context)
Expand All @@ -23,14 +55,3 @@ public record TwitterCredentials(
context.EnvironmentVariable("TWITTER_ACCESS_TOKEN_SECRET"));
}
}

public record GitterCredentials(string Token, string RoomId)
{
public static GitterCredentials GetGitterCredentials(ICakeContext context)
{
return new GitterCredentials(
context.EnvironmentVariable("GITTER_TOKEN"),
context.EnvironmentVariable("GITTER_ROOM_ID")
);
}
}
22 changes: 12 additions & 10 deletions build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class BuildParameters
public bool SkipSigning { get; }
public BuildCredentials GitHub { get; }
public TwitterCredentials Twitter { get; }
public GitterCredentials Gitter { get; }
public ReleaseNotes ReleaseNotes { get; }
public BuildVersion Version { get; set; }
public BuildPaths Paths { get; }
public BuildPackages Packages { get; }
public bool PublishingError { get; set; }
public DotNetMSBuildSettings MSBuildSettings { get; }
public CodeSigningCredentials CodeSigning { get; }

public bool ShouldPublish
{
Expand All @@ -48,6 +48,8 @@ public class BuildParameters
}
}


public bool ShouldSignPackages { get; }
public bool CanPostToTwitter
{
get
Expand All @@ -59,14 +61,6 @@ public class BuildParameters
}
}

public bool CanPostToGitter
{
get
{
return !string.IsNullOrEmpty(Gitter.Token) && !string.IsNullOrEmpty(Gitter.RoomId);
}
}

public BuildParameters (ISetupContext context)
{
if (context == null)
Expand All @@ -89,7 +83,7 @@ public class BuildParameters
IsTagged = IsBuildTagged(buildSystem);
GitHub = BuildCredentials.GetGitHubCredentials(context);
Twitter = TwitterCredentials.GetTwitterCredentials(context);
Gitter = GitterCredentials.GetGitterCredentials(context);
CodeSigning = CodeSigningCredentials.GetCodeSigningCredentials(context);
ReleaseNotes = context.ParseReleaseNotes("./ReleaseNotes.md");
IsPublishBuild = IsPublishing(context.TargetTask.Name);
IsReleaseBuild = IsReleasing(context.TargetTask.Name);
Expand Down Expand Up @@ -129,6 +123,14 @@ public class BuildParameters
{
MSBuildSettings.WithProperty("TemplateVersion", Version.SemVersion);
}


ShouldSignPackages = (!SkipSigning && ShouldPublish)
||
StringComparer.OrdinalIgnoreCase.Equals(
context.EnvironmentVariable("SIGNING_TEST"),
"True"
);
}

private static bool IsBuildTagged(BuildSystem buildSystem)
Expand Down
16 changes: 13 additions & 3 deletions build/paths.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
public record BuildPaths(
BuildDirectories Directories,
FilePath SignClientPath
FilePath SignClientPath,
FilePath SignFilterPath
)
{
public static BuildPaths GetPaths(
Expand Down Expand Up @@ -38,11 +39,20 @@ public record BuildPaths(
nugetRoot,
integrationTestsBinTool);

var signClientPath = context.Tools.Resolve("SignClient.exe") ?? context.Tools.Resolve("SignClient") ?? throw new Exception("Failed to locate sign tool");
var signClientPath = context.Tools.Resolve("sign.exe")
?? context.Tools.Resolve("sign")
?? (
context.IsRunningOnWindows()
? throw new Exception("Failed to locate sign tool")
: null
);

var signFilterPath = context.MakeAbsolute(context.File("./build/signclient.filter"));

return new BuildPaths(
Directories: buildDirectories,
SignClientPath: signClientPath
SignClientPath: signClientPath,
SignFilterPath: signFilterPath
);
}
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"src"
],
"sdk": {
"version": "7.0.100",
"version": "7.0.305",
"rollForward": "latestFeature"
}
}
13 changes: 0 additions & 13 deletions signclient.json

This file was deleted.

6 changes: 3 additions & 3 deletions src/Cake.Cli/Cake.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="Spectre.Console" Version="0.45.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.45.0" />
<PackageReference Include="Autofac" Version="7.0.1" />
<PackageReference Include="Spectre.Console" Version="0.46.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.46.0" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions src/Cake.Common.Tests/Cake.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="Castle.Core" Version="5.1.0" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="Castle.Core" Version="5.1.1" />
</ItemGroup>
<!-- .NET Framework packages -->
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Cake.Common.Tests/Fixtures/IO/FileSystemFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private static FakeFileSystem CreateFileSystem(ICakeEnvironment environment)
fileSystem.CreateFile("/Temp/HasFiles/A.txt");
fileSystem.CreateFile("/HasReadonly/Readonly.txt", FileAttributes.ReadOnly);
fileSystem.CreateFile("/HasReadonly/Not-Readonly.txt");
fileSystem.CreateFile("/HasReadonly/Hidden.txt").Hide();
return fileSystem;
}
}
Expand Down
Loading

0 comments on commit 2221be1

Please sign in to comment.