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
2 changes: 1 addition & 1 deletion build/.run/Artifacts DotnetTool Test.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Artifacts DotnetTool Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsDotnetToolTest --arch=amd64 --dotnet_version=8.0 --docker_distro=alpine.3.22" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsDotnetToolTest --arch=amd64 --dotnet_version=lts-latest --docker_distro=distro-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand Down
2 changes: 1 addition & 1 deletion build/.run/Artifacts MsBuildCore Test.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Artifacts MsBuildCore Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsMsBuildCoreTest --arch=amd64 --dotnet_version=8.0 --docker_distro=alpine.3.22" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsMsBuildCoreTest --arch=amd64 --dotnet_version=lts-latest --docker_distro=distro-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand Down
2 changes: 1 addition & 1 deletion build/.run/Artifacts Native Test.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Artifacts Native Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsNativeTest --arch=amd64 --dotnet_version=8.0 --docker_distro=alpine.3.22" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsNativeTest --arch=amd64 --dotnet_version=lts-latest --docker_distro=distro-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand Down
2 changes: 1 addition & 1 deletion build/.run/Artifacts Prepare.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Artifacts Prepare" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsPrepare --dotnet_version=8.0 --docker_distro=alpine.3.22" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsPrepare --dotnet_version=lts-latest --docker_distro=distro-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand Down
2 changes: 1 addition & 1 deletion build/.run/Artifacts Test.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Artifacts Test" type="DotNetProject" factoryName=".NET Project" folderName="Artifacts">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/artifacts" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsTest --dotnet_version=8.0 --docker_distro=alpine.3.22" />
<option name="PROGRAM_PARAMETERS" value="--target=ArtifactsTest --dotnet_version=lts-latest --docker_distro=distro-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand Down
4 changes: 2 additions & 2 deletions build/.run/Docker Build.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Docker Build" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerBuild --arch=amd64 --arch=arm64 --dotnet_version=8.0 --docker_distro=debian.12 --verbosity=diagnostic" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerBuild --arch=amd64 --arch=arm64 --dotnet_version=lts-latest --docker_distro=debian.12 --verbosity=diagnostic" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand All @@ -20,4 +20,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions build/.run/Docker Manifest.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Docker Manifest" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerManifest --arch=amd64 --arch=arm64 --dotnet_version=8.0 --docker_distro=debian.12" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerManifest --arch=amd64 --arch=arm64 --dotnet_version=lts-latest --docker_distro=debian.12" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand All @@ -20,4 +20,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions build/.run/Docker Publish.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Docker Publish" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerPublish --arch=amd64 --arch=arm64 --dotnet_version=8.0 --docker_distro=debian.12 --verbosity=diagnostic" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerPublish --arch=amd64 --arch=arm64 --dotnet_version=lts-latest --docker_distro=debian.12 --verbosity=diagnostic" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand All @@ -20,4 +20,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions build/.run/Docker Test.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Docker Test" type="DotNetProject" factoryName=".NET Project" folderName="Docker">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/docker" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerTest --arch=amd64 --dotnet_version=8.0 --docker_distro=debian.12" />
<option name="PROGRAM_PARAMETERS" value="--target=DockerTest --arch=amd64 --dotnet_version=lts-latest --docker_distro=debian.12" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand All @@ -20,4 +20,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions build/.run/PublishCoverage.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PublishCoverage" type="DotNetProject" factoryName=".NET Project" folderName="Unit Test">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/build" />
<option name="PROGRAM_PARAMETERS" value="--target=PublishCoverage --dotnet_version=8.0" />
<option name="PROGRAM_PARAMETERS" value="--target=PublishCoverage --dotnet_version=lts-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<envs>
Expand All @@ -21,4 +21,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
6 changes: 3 additions & 3 deletions build/.run/UnitTest (8.0).run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="UnitTest (8.0)" type="DotNetProject" factoryName=".NET Project" folderName="Unit Test">
<configuration default="false" name="UnitTest (Lts Latest)" type="DotNetProject" factoryName=".NET Project" folderName="Unit Test">
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/build" />
<option name="PROGRAM_PARAMETERS" value="--target=UnitTest --dotnet_version=8.0" />
<option name="PROGRAM_PARAMETERS" value="--target=UnitTest --dotnet_version=lts-latest" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
Expand All @@ -17,4 +17,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
8 changes: 2 additions & 6 deletions build/artifacts/BuildContext.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Common.Utilities;
using Common.Context;

namespace Artifacts;

public class BuildContext(ICakeContext context) : BuildContextBase(context)
public class BuildContext(ICakeContext context) : DockerBuildContext(context)
{
public string MsBuildConfiguration { get; } = Constants.DefaultConfiguration;

public bool IsDockerOnLinux { get; set; }

public IEnumerable<DockerImage> Images { get; set; } = new List<DockerImage>();
}
35 changes: 2 additions & 33 deletions build/artifacts/BuildLifetime.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
using Common.Lifetime;
using Common.Utilities;

namespace Artifacts;

public class BuildLifetime : BuildLifetimeBase<BuildContext>
public class BuildLifetime : DockerBuildLifetime<BuildContext>
{
public override void Setup(BuildContext context, ISetupContext info)
{
base.Setup(context, info);

context.IsDockerOnLinux = context.DockerCustomCommand("info --format '{{.OSType}}'").First().Replace("'", string.Empty) == "linux";

var dockerRegistry = context.Argument(Arguments.DockerRegistry, DockerRegistry.DockerHub);
var dotnetVersion = context.Argument(Arguments.DotnetVersion, string.Empty).ToLower();
var dockerDistro = context.Argument(Arguments.DockerDistro, string.Empty).ToLower();

var versions = string.IsNullOrWhiteSpace(dotnetVersion) ? Constants.DotnetVersions : [dotnetVersion];
var distros = string.IsNullOrWhiteSpace(dockerDistro) ? Constants.DockerDistros : [dockerDistro];

var architectures = context.HasArgument(Arguments.Architecture) ? context.Arguments<Architecture>(Arguments.Architecture) : Constants.ArchToBuild;
var platformArch = context.IsRunningOnAmd64() ? Architecture.Amd64 : Architecture.Arm64;

var registry = dockerRegistry == DockerRegistry.DockerHub ? Constants.DockerHubRegistry : Constants.GitHubContainerRegistry;
context.Images = from version in versions
from distro in distros
from arch in architectures
select new DockerImage(distro, version, arch, registry, true);

context.StartGroup("Build Setup");

LogBuildInformation(context);

context.Information($"IsDockerOnLinux: {context.IsDockerOnLinux}");
context.Information($"Building for Version: {dotnetVersion}, Distro: {dockerDistro}, Architecture: {platformArch}");

context.EndGroup();
}
protected override bool UseBaseImage => true;
}
4 changes: 2 additions & 2 deletions build/build/Tasks/BuildPrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Run(BuildContext context)
Verbosity = DotNetVerbosity.Minimal,
Configuration = Constants.DefaultConfiguration,
OutputDirectory = Paths.Tools.Combine("gitversion"),
Framework = $"net{Constants.VersionLatest}",
Framework = $"net{Constants.DotnetLtsLatest}",
NoRestore = true,
});

Expand All @@ -35,7 +35,7 @@ public override void Run(BuildContext context)
Verbosity = DotNetVerbosity.Minimal,
Configuration = Constants.DefaultConfiguration,
OutputDirectory = Paths.Tools.Combine("schema"),
Framework = $"net{Constants.VersionLatest}",
Framework = $"net{Constants.DotnetLtsLatest}",
NoRestore = true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion build/build/Tasks/Package/PackagePrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static DirectoryPath PackPrepareNative(BuildContext context, string runt

var settings = new DotNetPublishSettings
{
Framework = $"net{Constants.VersionLatest}",
Framework = $"net{Constants.DotnetLtsLatest}",
Runtime = runtime,
NoRestore = false,
Configuration = context.MsBuildConfiguration,
Expand Down
4 changes: 4 additions & 0 deletions build/build/Tasks/Test/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public override void Run(BuildContext context)
var frameworks = Constants.DotnetVersions;
if (!string.IsNullOrWhiteSpace(dotnetVersion))
{
if (string.Equals(dotnetVersion, "lts-latest", StringComparison.OrdinalIgnoreCase))
{
dotnetVersion = Constants.DotnetLtsLatest;
}
if (!frameworks.Contains(dotnetVersion, StringComparer.OrdinalIgnoreCase))
{
throw new Exception($"Dotnet Target {dotnetVersion} is not supported at the moment");
Expand Down
13 changes: 13 additions & 0 deletions build/common/Context/DockerBuildContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Common.Utilities;

namespace Common.Context;

public class DockerBuildContext(ICakeContext context) : BuildContextBase(context)
{
public bool IsDockerOnLinux { get; set; }

public IEnumerable<DockerImage> Images { get; set; } = new List<DockerImage>();
public DockerRegistry DockerRegistry { get; set; }
public ICollection<Architecture> Architectures { get; set; } = new List<Architecture>();
}

2 changes: 1 addition & 1 deletion build/common/Lifetime/BuildLifetimeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Setup(T context, ISetupContext info)
}

var gitVersionPath = context.GetGitVersionDotnetToolLocation();
if (gitVersionPath is null || context.FileExists(gitVersionPath) is false)
if (gitVersionPath is null || !context.FileExists(gitVersionPath))
{
throw new FileNotFoundException("Failed to locate the Release build of gitversion.dll in ./tools/gitversion. Try running \"./build.ps1 -Stage build -Target BuildPrepare\"");
}
Expand Down
54 changes: 54 additions & 0 deletions build/common/Lifetime/DockerBuildLifetime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Common.Context;
using Common.Utilities;

namespace Common.Lifetime;

public abstract class DockerBuildLifetime<TContext> : BuildLifetimeBase<TContext>
where TContext : DockerBuildContext
{
protected virtual bool UseBaseImage => false;

public override void Setup(TContext context, ISetupContext info)
{
base.Setup(context, info);

context.IsDockerOnLinux = context.DockerCustomCommand("info --format '{{.OSType}}'").First().Replace("'", string.Empty) == "linux";

var dockerRegistry = context.Argument(Arguments.DockerRegistry, DockerRegistry.DockerHub);
var dotnetVersion = context.Argument(Arguments.DotnetVersion, string.Empty).ToLower();
var dockerDistro = context.Argument(Arguments.DockerDistro, string.Empty).ToLower();

var versions = string.IsNullOrWhiteSpace(dotnetVersion)
? Constants.DotnetVersions
: string.Equals(dotnetVersion, "lts-latest", StringComparison.OrdinalIgnoreCase)
? [Constants.DotnetLtsLatest]
: [dotnetVersion];

var distros = string.IsNullOrWhiteSpace(dockerDistro)
? Constants.DockerDistros
: string.Equals(dockerDistro, "distro-latest", StringComparison.OrdinalIgnoreCase)
? [Constants.AlpineLatest]
: [dockerDistro];

var architectures = context.HasArgument(Arguments.Architecture) ? context.Arguments<Architecture>(Arguments.Architecture) : Constants.ArchToBuild;
var platformArch = context.IsRunningOnAmd64() ? Architecture.Amd64 : Architecture.Arm64;

var registry = dockerRegistry == DockerRegistry.DockerHub ? Constants.DockerHubRegistry : Constants.GitHubContainerRegistry;

context.DockerRegistry = dockerRegistry;
context.Architectures = architectures;
context.Images = from version in versions
from distro in distros
from arch in architectures
select new DockerImage(distro, version, arch, registry, UseBaseImage);

context.StartGroup("Build Setup");

LogBuildInformation(context);

context.Information($"IsDockerOnLinux: {context.IsDockerOnLinux}");
context.Information($"Building for Version: {dotnetVersion}, Distro: {dockerDistro}, Architecture: {platformArch}");
context.EndGroup();
}
}

4 changes: 2 additions & 2 deletions build/common/Utilities/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public static class Constants
public const string RepoOwner = "GitTools";
public const string Repository = "GitVersion";

public const string VersionLatest = "8.0";
public static readonly string[] DotnetVersions = [VersionLatest, "9.0"];
public const string DotnetLtsLatest = "8.0";
public static readonly string[] DotnetVersions = [DotnetLtsLatest, "9.0"];

public const string DefaultBranch = "main";
public const string DefaultConfiguration = "Release";
Expand Down
2 changes: 1 addition & 1 deletion build/common/Utilities/ContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static string GetRepositoryName(this ICakeContext context)
private static void EndGroup(this IAzurePipelinesCommands _, ICakeContext context) => context.Information("##[endgroup]");

public static FilePath? GetGitVersionToolLocation(this ICakeContext context) =>
context.GetFiles($"src/GitVersion.App/bin/{Constants.DefaultConfiguration}/net{Constants.VersionLatest}/gitversion.dll").SingleOrDefault();
context.GetFiles($"src/GitVersion.App/bin/{Constants.DefaultConfiguration}/net{Constants.DotnetLtsLatest}/gitversion.dll").SingleOrDefault();
public static FilePath? GetGitVersionDotnetToolLocation(this ICakeContext context) =>
context.MakeAbsolute(Paths.Tools.Combine("gitversion").CombineWithFilePath("gitversion.dll"));

Expand Down
2 changes: 1 addition & 1 deletion build/common/Utilities/DockerContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private static IEnumerable<string> GetDockerTags(this BuildContextBase context,
$"{name}:{context.Version.SemVersion}-{distro}-{targetFramework}",
};

if (distro == Constants.DockerDistroLatest && targetFramework == Constants.VersionLatest)
if (distro == Constants.DockerDistroLatest && targetFramework == Constants.DotnetLtsLatest)
{
tags.Add($"{name}:{context.Version.SemVersion}");

Expand Down
9 changes: 2 additions & 7 deletions build/docker/BuildContext.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using Common.Utilities;
using Common.Context;
using Docker.Utilities;

namespace Docker;

public class BuildContext(ICakeContext context) : BuildContextBase(context)
public class BuildContext(ICakeContext context) : DockerBuildContext(context)
{
public Credentials? Credentials { get; set; }
public bool IsDockerOnLinux { get; set; }

public IEnumerable<DockerImage> Images { get; set; } = new List<DockerImage>();
public DockerRegistry DockerRegistry { get; set; }
public ICollection<Architecture> Architectures { get; set; } = new List<Architecture>();
}
Loading