-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBuild.cs
More file actions
102 lines (89 loc) · 3 KB
/
Build.cs
File metadata and controls
102 lines (89 loc) · 3 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Linq;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
[GithubActionsExtended(
"Build & Test",
GitHubActionsImage.UbuntuLatest,
OnPushBranches = ["main"],
OnPullRequestBranches = ["main"],
InvokedTargets = [nameof(Test)])]
[GithubActionsExtended(
"Manual Nuget Push",
GitHubActionsImage.UbuntuLatest,
On = [GitHubActionsTrigger.WorkflowDispatch],
InvokedTargets = [nameof(NugetPush)],
ImportSecrets = [nameof(NugetApiKey)])]
class Build : NukeBuild
{
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
/// - JetBrains Rider https://nuke.build/rider
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
public static int Main () => Execute<Build>(x => x.Compile);
[Solution(GenerateProjects = true)] readonly Solution Solution;
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
ArtifactsDirectory.CreateOrCleanDirectory();
});
Target Restore => _ => _
.DependsOn(Clean)
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution));
});
Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetConfiguration("Release")
.EnableNoRestore());
});
Target Test => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetTest(_ => _
.SetProjectFile(Solution.Auth0Net_DependencyInjection_Tests));
});
Target NugetPack => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetPack(_ => _
.SetProject(Solution.Auth0Net_DependencyInjection)
.SetConfiguration("Release")
.EnableContinuousIntegrationBuild()
.SetOutputDirectory(ArtifactsDirectory));
});
[Parameter("Nuget Api Key")] [Secret] readonly string NugetApiKey;
Target NugetPush => _ => _
.DependsOn(NugetPack)
.Requires(() => !string.IsNullOrEmpty(NugetApiKey))
.Executes(() =>
{
DotNetNuGetPush(_ => _
.SetSource("https://api.nuget.org/v3/index.json")
.SetTargetPath(ArtifactsDirectory / "*.nupkg")
.EnableSkipDuplicate()
.EnableNoSymbols()
.SetApiKey(NugetApiKey));
});
}