|
|
@ -1,6 +1,10 @@ |
|
|
|
using Nuke.Common.CI.GitHubActions; |
|
|
|
using Nuke.Common.CI.GitHubActions.Configuration; |
|
|
|
using Nuke.Common.Execution; |
|
|
|
using Nuke.Common.Utilities; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
[GitHubActions("CI", |
|
|
|
[CustomGitHubActions("CI", |
|
|
|
GitHubActionsImage.WindowsLatest, |
|
|
|
GitHubActionsImage.UbuntuLatest, |
|
|
|
OnPushBranches = ["main", "master", "release*", "poi/*"], |
|
|
@ -9,7 +13,7 @@ using Nuke.Common.CI.GitHubActions; |
|
|
|
CacheKeyFiles = [], |
|
|
|
PublishCondition = "runner.os == 'Windows'" |
|
|
|
)] |
|
|
|
[GitHubActions("PR", |
|
|
|
[CustomGitHubActions("PR", |
|
|
|
GitHubActionsImage.WindowsLatest, |
|
|
|
GitHubActionsImage.UbuntuLatest, |
|
|
|
On = [GitHubActionsTrigger.PullRequest], |
|
|
@ -21,3 +25,52 @@ using Nuke.Common.CI.GitHubActions; |
|
|
|
)] |
|
|
|
partial class Build; |
|
|
|
|
|
|
|
class CustomGitHubActionsAttribute : GitHubActionsAttribute |
|
|
|
{ |
|
|
|
public CustomGitHubActionsAttribute(string name, GitHubActionsImage image, params GitHubActionsImage[] images) : base(name, image, images) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyCollection<ExecutableTarget> relevantTargets) |
|
|
|
{ |
|
|
|
var job = base.GetJobs(image, relevantTargets); |
|
|
|
|
|
|
|
var newSteps = new List<GitHubActionsStep>(job.Steps); |
|
|
|
|
|
|
|
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(["8.0", "9.0"])); |
|
|
|
|
|
|
|
job.Steps = newSteps.ToArray(); |
|
|
|
return job; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class GitHubActionsSetupDotNetStep : GitHubActionsStep |
|
|
|
{ |
|
|
|
public GitHubActionsSetupDotNetStep(string[] versions) |
|
|
|
{ |
|
|
|
Versions = versions; |
|
|
|
} |
|
|
|
|
|
|
|
string[] Versions { get; } |
|
|
|
|
|
|
|
public override void Write(CustomFileWriter writer) |
|
|
|
{ |
|
|
|
writer.WriteLine("- uses: actions/setup-dotnet@v4"); |
|
|
|
|
|
|
|
using (writer.Indent()) |
|
|
|
{ |
|
|
|
writer.WriteLine("with:"); |
|
|
|
using (writer.Indent()) |
|
|
|
{ |
|
|
|
writer.WriteLine("dotnet-version: |"); |
|
|
|
using (writer.Indent()) |
|
|
|
{ |
|
|
|
foreach (var version in Versions) |
|
|
|
{ |
|
|
|
writer.WriteLine(version); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |