forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.cs
89 lines (78 loc) · 2.75 KB
/
Build.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.IO;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.AzurePipelines;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
using Nuke.Common.Tools.DotNet;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Helpers;
[AzurePipelines(
suffix: "test-pr-hotchocolate",
AzurePipelinesImage.UbuntuLatest,
InvokedTargets = new[] { nameof(Sonar) },
PullRequestsAutoCancel = true,
PullRequestsBranchesInclude = new[] { "master" },
AutoGenerate = false)]
[GitHubActions(
"sonar-pr-hotchocolate",
GitHubActionsImage.UbuntuLatest,
On = new[] { GitHubActionsTrigger.PullRequest },
InvokedTargets = new[] { nameof(SonarPr) },
ImportGitHubTokenAs = nameof(GitHubToken),
ImportSecrets = new[] { nameof(SonarToken) },
AutoGenerate = false)]
[GitHubActions(
"tests-pr-hotchocolate",
GitHubActionsImage.UbuntuLatest,
On = new[] { GitHubActionsTrigger.PullRequest },
InvokedTargets = new[] { nameof(Test) },
ImportGitHubTokenAs = nameof(GitHubToken),
AutoGenerate = false)]
[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
partial class Build : NukeBuild
{
public static int Main() => Execute<Build>(x => x.Compile);
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly string Configuration = IsLocalBuild ? Debug : Release;
[CI] readonly AzurePipelines DevOpsPipeLine;
Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
});
Target Restore => _ => _
.Executes(() =>
{
DotNetBuildSonarSolution(AllSolutionFile);
DotNetRestore(c => c.SetProjectFile(AllSolutionFile));
});
Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
if (!InvokedTargets.Contains(Restore))
{
DotNetBuildSonarSolution(AllSolutionFile);
}
DotNetBuild(c => c
.SetProjectFile(AllSolutionFile)
.SetNoRestore(InvokedTargets.Contains(Restore))
.SetConfiguration(Configuration)
.SetAssemblyVersion(GitVersion.AssemblySemVer)
.SetFileVersion(GitVersion.AssemblySemFileVer)
.SetInformationalVersion(GitVersion.InformationalVersion)
.SetVersion(GitVersion.SemVer));
});
Target Reset => _ => _
.Executes(() =>
{
TryDelete(AllSolutionFile);
TryDelete(SonarSolutionFile);
TryDelete(TestSolutionFile);
TryDelete(PackSolutionFile);
DotNetBuildSonarSolution(AllSolutionFile);
DotNetRestore(c => c.SetProjectFile(AllSolutionFile));
});
}