diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml
new file mode 100644
index 0000000000..6448eea8e8
--- /dev/null
+++ b/.github/workflows/continuous_integration.yml
@@ -0,0 +1,66 @@
+# ------------------------------------------------------------------------------
+#
+#
+# This code was generated.
+#
+# - To turn off auto-generation set:
+#
+# [GitHubActions (AutoGenerate = false)]
+#
+# - To trigger manual generation invoke:
+#
+# nuke --generate-configuration GitHubActions_continuous_integration --host GitHubActions
+#
+#
+# ------------------------------------------------------------------------------
+
+name: continuous_integration
+
+on: [push, pull_request]
+
+jobs:
+ windows-latest:
+ name: windows-latest
+ runs-on: windows-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v3
+ - name: 'Cache: .nuke/temp, ~/.nuget/packages'
+ uses: actions/cache@v3
+ with:
+ path: |
+ .nuke/temp
+ ~/.nuget/packages
+ key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
+ - name: 'Run: RunTests'
+ run: ./build.cmd RunTests
+ ubuntu-latest:
+ name: ubuntu-latest
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v3
+ - name: 'Cache: .nuke/temp, ~/.nuget/packages'
+ uses: actions/cache@v3
+ with:
+ path: |
+ .nuke/temp
+ ~/.nuget/packages
+ key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
+ - name: 'Run: RunTests'
+ run: ./build.cmd RunTests
+ macos-latest:
+ name: macos-latest
+ runs-on: macos-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v3
+ - name: 'Cache: .nuke/temp, ~/.nuget/packages'
+ uses: actions/cache@v3
+ with:
+ path: |
+ .nuke/temp
+ ~/.nuget/packages
+ key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
+ - name: 'Run: RunTests'
+ run: ./build.cmd RunTests
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json
index b11ef725aa..cc673502ba 100644
--- a/.nuke/build.schema.json
+++ b/.nuke/build.schema.json
@@ -63,20 +63,6 @@
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
- "PlatformTargets": {
- "type": "array",
- "description": "The target platform",
- "items": {
- "type": "string",
- "enum": [
- "CLI",
- "Linux",
- "MacOS",
- "Wasm",
- "Windows"
- ]
- }
- },
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
@@ -88,10 +74,6 @@
"type": "string",
"description": "Root directory during build execution"
},
- "RunTests": {
- "type": "boolean",
- "description": "Runs unit tests"
- },
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
@@ -99,14 +81,13 @@
"type": "string",
"enum": [
"BuildGenerators",
- "BuildPlugins",
"Clean",
"GenerateSdkNuGet",
"PreliminaryCheck",
"PublishApp",
"Restore",
- "SetVersion",
- "UnitTests"
+ "RunTests",
+ "SetVersion"
]
}
},
@@ -117,14 +98,13 @@
"type": "string",
"enum": [
"BuildGenerators",
- "BuildPlugins",
"Clean",
"GenerateSdkNuGet",
"PreliminaryCheck",
"PublishApp",
"Restore",
- "SetVersion",
- "UnitTests"
+ "RunTests",
+ "SetVersion"
]
}
},
diff --git a/src/build/Build.cs b/src/build/Build.cs
index ec2b61c86a..58298cfffd 100644
--- a/src/build/Build.cs
+++ b/src/build/Build.cs
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using System.Runtime.InteropServices;
using Nuke.Common;
+using Nuke.Common.CI.GitHubActions;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
@@ -13,13 +13,20 @@
using Nuke.Common.Utilities.Collections;
using Serilog;
using static AppVersionTask;
-using static Nuke.Common.IO.FileSystemTasks;
-using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static RestoreTask;
using Project = Nuke.Common.ProjectModel.Project;
#pragma warning disable IDE1006 // Naming Styles
+[GitHubActions(
+ name: "continuous_integration",
+ GitHubActionsImage.WindowsLatest,
+ GitHubActionsImage.UbuntuLatest,
+ GitHubActionsImage.MacOsLatest,
+ On = [GitHubActionsTrigger.Push, GitHubActionsTrigger.PullRequest],
+ InvokedTargets = [nameof(RunTests)],
+ TimeoutMinutes = 30,
+ AutoGenerate = true)]
class Build : NukeBuild
{
/// Support plugins are available for:
@@ -33,12 +40,6 @@ class Build : NukeBuild
[Parameter("Configuration to build - Default is 'Release'")]
readonly Configuration Configuration = Configuration.Release;
- [Parameter("The target platform")]
- readonly PlatformTarget[]? PlatformTargets;
-
- [Parameter("Runs unit tests")]
- readonly bool RunTests;
-
[Solution]
readonly Solution? WindowsSolution;
@@ -52,30 +53,12 @@ class Build : NukeBuild
.Before(Clean)
.Executes(() =>
{
- if (PlatformTargets == null || PlatformTargets.Length == 0)
- {
- Assert.Fail("Parameter `--platform-targets` is missing. Please check `build.sh --help`.");
- return;
- }
-
- if (PlatformTargets.Contains(PlatformTarget.Windows) && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 0, 0))
+ if (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 0, 0))
{
Assert.Fail("To build Windows app, you need to run on Windows 10 or later.");
return;
}
- if (PlatformTargets.Contains(PlatformTarget.MacOS) && !OperatingSystem.IsMacOS())
- {
- Assert.Fail("To build macOS app, you need to run on macOS Ventura 13.1 or later.");
- return;
- }
-
- if (PlatformTargets.Contains(PlatformTarget.Linux) && !OperatingSystem.IsLinux())
- {
- Assert.Fail("To build Linux app, you need to run on Linux.");
- return;
- }
-
Log.Information("Preliminary checks are successful.");
});
@@ -126,32 +109,12 @@ class Build : NukeBuild
.SetVerbosity(DotNetVerbosity.quiet)));
});
- Target BuildPlugins => _ => _
+ Target RunTests => _ => _
.DependentFor(GenerateSdkNuGet)
.After(Restore)
.After(SetVersion)
.After(BuildGenerators)
.Executes(() =>
- {
- Log.Information($"Building plugins ...");
- Project project = WindowsSolution!.GetAllProjects("DevToys.Tools").Single();
- DotNetBuild(s => s
- .SetProjectFile(project)
- .SetConfiguration(Configuration)
- .SetSelfContained(false)
- .SetPublishTrimmed(false)
- .SetVerbosity(DotNetVerbosity.quiet));
- });
-
-#pragma warning disable IDE0051 // Remove unused private members
- Target UnitTests => _ => _
- .DependentFor(GenerateSdkNuGet)
- .After(Restore)
- .After(SetVersion)
- .After(BuildGenerators)
- .After(BuildPlugins)
- .OnlyWhenDynamic(() => RunTests)
- .Executes(() =>
{
RootDirectory
.GlobFiles("**/*Tests.csproj")
@@ -161,7 +124,6 @@ class Build : NukeBuild
.SetConfiguration(Configuration)
.SetVerbosity(DotNetVerbosity.quiet)));
});
-#pragma warning restore IDE0051 // Remove unused private members
Target GenerateSdkNuGet => _ => _
.Description("Generate the DevToys SDK NuGet package")
@@ -186,25 +148,22 @@ class Build : NukeBuild
.DependsOn(GenerateSdkNuGet)
.Executes(() =>
{
- if (PlatformTargets!.Contains(PlatformTarget.Windows))
+ if (OperatingSystem.IsWindows())
{
PublishWindowsApp();
}
- if (PlatformTargets!.Contains(PlatformTarget.MacOS))
+ if (OperatingSystem.IsMacOS())
{
PublishMacApp();
}
- if (PlatformTargets!.Contains(PlatformTarget.Linux))
+ if (OperatingSystem.IsLinux())
{
PublishLinuxApp();
}
- if (PlatformTargets!.Contains(PlatformTarget.CLI))
- {
- PublishCliApp();
- }
+ PublishCliApp();
});
void PublishWindowsApp()
@@ -309,7 +268,7 @@ IEnumerable GetDotnetParametersForCliApp()
string publishProject = "DevToys.CLI";
Project project;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
project = MacSolution!.GetProject(publishProject);
foreach (string targetFramework in project.GetTargetFrameworks())
@@ -321,7 +280,7 @@ IEnumerable GetDotnetParametersForCliApp()
yield return new DotnetParameters(project.Path, "osx-arm64", targetFramework, portable: true);
}
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ else if (OperatingSystem.IsWindows())
{
project = WindowsSolution!.GetAllProjects(publishProject).Single();
foreach (string targetFramework in project.GetTargetFrameworks())
@@ -336,7 +295,7 @@ IEnumerable GetDotnetParametersForCliApp()
yield return new DotnetParameters(project.Path, "win-x86", targetFramework, portable: true);
}
}
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ else if (OperatingSystem.IsLinux())
{
project = LinuxSolution!.GetAllProjects(publishProject).Single();
foreach (string targetFramework in project.GetTargetFrameworks())
@@ -355,7 +314,7 @@ IEnumerable GetDotnetParametersForWindowsApp()
string publishProject = "DevToys.Windows";
Project project;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (OperatingSystem.IsWindows())
{
project = WindowsSolution!.GetAllProjects(publishProject).Single();
foreach (string targetFramework in project.GetTargetFrameworks())
@@ -380,7 +339,7 @@ IEnumerable GetDotnetParametersForLinuxApp()
string publishProject = "DevToys.Linux";
Project project;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (OperatingSystem.IsLinux())
{
project = LinuxSolution!.GetAllProjects(publishProject).Single();
foreach (string targetFramework in project.GetTargetFrameworks())
@@ -403,7 +362,7 @@ IEnumerable GetDotnetParametersForMacOSApp()
string publishProject = "DevToys.MacOS";
Project project;
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ if (OperatingSystem.IsMacOS())
{
project = MacSolution!.GetAllProjects(publishProject).Single();
foreach (string targetFramework in project.GetTargetFrameworks())
diff --git a/src/build/PlatformTarget.cs b/src/build/PlatformTarget.cs
deleted file mode 100644
index 4b30f8c2dd..0000000000
--- a/src/build/PlatformTarget.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-enum PlatformTarget
-{
- Windows,
- MacOS,
- CLI,
- Wasm,
- Linux // TODO: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/#prerequisites
-}