Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .config/dotnet-tools.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
NUGET_APIKEY: ${{steps.login.outputs.NUGET_API_KEY}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
cake-version: tool-manifest
file-path: cake.cs
target: GitHub-Actions
28 changes: 0 additions & 28 deletions build/helpers.cake

This file was deleted.

39 changes: 39 additions & 0 deletions build/helpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*****************************
* Helpers
*****************************/

public partial class Program
{
static void Main_SetupExtensions()
{
if (BuildSystem.GitHubActions.IsRunningOnGitHubActions)
{
TaskSetup(context => BuildSystem.GitHubActions.Commands.StartGroup(context.Task.Name));
TaskTeardown(context => BuildSystem.GitHubActions.Commands.EndGroup());
}
}
}


public static partial class CakeTaskBuilderExtensions
{
private static ExtensionHelper extensionHelper = new (Task, () => RunTarget(Argument("target", "Default")));

public static CakeTaskBuilder Then(this CakeTaskBuilder cakeTaskBuilder, string name)
=> extensionHelper
.TaskCreate(name)
.IsDependentOn(cakeTaskBuilder);


public static CakeReport Run(this CakeTaskBuilder cakeTaskBuilder)
=> extensionHelper.Run();

public static CakeTaskBuilder Default(this CakeTaskBuilder cakeTaskBuilder)
{
extensionHelper
.TaskCreate("Default")
.IsDependentOn(cakeTaskBuilder);
return cakeTaskBuilder;
}

}
10 changes: 5 additions & 5 deletions build/records.cake → build/records.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Func<BuildData, DotNetMSBuildSettings, DotNetMSBuildSettings> MSBuildSettingsCus
public DirectoryPath NuGetOutputPath { get; } = OutputPath.Combine("nuget");
public DirectoryPath BinaryOutputPath { get; } = OutputPath.Combine("bin");

public string GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GITHUB_TOKEN");
public string? GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string? GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GITHUB_TOKEN");

public bool ShouldPushGitHubPackages() => (IsMainBranch || IsDevelopmentBranch) &&
!string.IsNullOrWhiteSpace(GitHubNuGetSource)
&& !string.IsNullOrWhiteSpace(GitHubNuGetApiKey);

public string NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
public string NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
public string? NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
public string? NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
public bool ShouldPushNuGetPackages() => IsMainBranch &&
!string.IsNullOrWhiteSpace(NuGetSource) &&
!string.IsNullOrWhiteSpace(NuGetApiKey);
Expand All @@ -37,4 +37,4 @@ public bool ShouldPushNuGetPackages() => IsMainBranch &&
public DotNetMSBuildSettings MSBuildSettings => msBuildSettings ??= MSBuildSettingsCustomization(this, new DotNetMSBuildSettings());
}

private record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);
internal record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);
59 changes: 26 additions & 33 deletions build.cake → cake.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// Install .NET Core Global tools.
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.1"

#load "build/records.cake"
#load "build/helpers.cake"
#:sdk Cake.Sdk@6.0.0
#:property IncludeAdditionalFiles=./build/*.cs

/*****************************
* Setup
*****************************/
Setup(
static context => {
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.1");
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=DPI&version=2025.12.17.349");

var assertedVersions = context.GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json
});

var gh = context.GitHubActions();
var buildDate = DateTime.UtcNow;
var runNumber = gh.IsRunningOnGitHubActions
? gh.Environment.Workflow.RunNumber
var runNumber = GitHubActions.IsRunningOnGitHubActions
? GitHubActions.Environment.Workflow.RunNumber
: (short)((buildDate - buildDate.Date).TotalSeconds/3);
var version = FormattableString
.Invariant($"{buildDate:yyyy.M.d}.{runNumber}");
Expand Down Expand Up @@ -63,7 +61,7 @@
.WithProperty("PackageProjectUrl", "https://github.com/devlead/Devlead.Console.Template")
.WithProperty("RepositoryUrl", "https://github.com/devlead/Devlead.Console.Template.git")
.WithProperty("RepositoryType", "git")
.WithProperty("ContinuousIntegrationBuild", gh.IsRunningOnGitHubActions ? "true" : "false")
.WithProperty("ContinuousIntegrationBuild", GitHubActions.IsRunningOnGitHubActions ? "true" : "false")
.WithProperty("EmbedUntrackedSources", "true")
.WithProperty("PackageOutputPath", data.NuGetOutputPath.FullPath)
.WithProperty("BaseOutputPath", data.BinaryOutputPath.FullPath + "/")
Expand Down Expand Up @@ -144,26 +142,22 @@
.DeferOnError()
.Then("DPI")
.Does<BuildData>(
static (context, data) => context.DotNetTool(
"tool",
new DotNetToolSettings {
ArgumentCustomization = args => args
.Append("run")
.Append("dpi")
.Append("nuget")
.Append("--silent")
.AppendSwitchQuoted("--output", "table")
.Append(
(
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_SharedKey"))
&&
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_WorkspaceId"))
)
? "report"
: "analyze"
)
.AppendSwitchQuoted("--buildversion", data.Version)
}
static (context, data) => Command(
["dpi", "dpi.exe"],
new ProcessArgumentBuilder()
.Append("nuget")
.Append("--silent")
.AppendSwitchQuoted("--output", "table")
.Append(
(
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_SharedKey"))
&&
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_WorkspaceId"))
)
? "report"
: "analyze"
)
.AppendSwitchQuoted("--buildversion", data.Version)
)
)
.Then("Pack")
Expand All @@ -180,10 +174,9 @@
.Then("Upload-Artifacts")
.WithCriteria(BuildSystem.IsRunningOnGitHubActions, nameof(BuildSystem.IsRunningOnGitHubActions))
.Does<BuildData>(
static (context, data) => context
.GitHubActions()
.Commands
.UploadArtifact(data.ArtifactsPath, "artifacts")
static (context, data) => GitHubActions
.Commands
.UploadArtifact(data.ArtifactsPath, "artifacts")
)
.Then("Push-GitHub-Packages")
.WithCriteria<BuildData>( (context, data) => data.ShouldPushGitHubPackages())
Expand Down