forked from IdentityServer/IdentityServer4.Templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
137 lines (114 loc) · 3.65 KB
/
build.cake
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
var target = Argument("target", "Default");
var configuration = Argument<string>("configuration", "Release");
var sign = Argument<bool>("sign", false);
///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////
var buildArtifacts = Directory("./artifacts/packages");
var packageVersion = "4.0.1";
///////////////////////////////////////////////////////////////////////////////
// Clean
///////////////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories(new DirectoryPath[]
{
buildArtifacts,
Directory("./feed/content/UI")
});
});
///////////////////////////////////////////////////////////////////////////////
// Build
///////////////////////////////////////////////////////////////////////////////
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
};
var projects = GetFiles("./src/**/*.csproj");
foreach(var project in projects)
{
DotNetCoreBuild(project.GetDirectory().FullPath, settings);
}
});
///////////////////////////////////////////////////////////////////////////////
// Copy
///////////////////////////////////////////////////////////////////////////////
Task("Copy")
.IsDependentOn("Clean")
.Does(() =>
{
CreateDirectory("./feed/content");
// copy the singel csproj templates
var files = GetFiles("./src/**/*.*");
CopyFiles(files, "./feed/content", true);
// copy the UI files
files = GetFiles("./ui/**/*.*");
CopyFiles(files, "./feed/content/ui", true);
});
///////////////////////////////////////////////////////////////////////////////
// Pack
///////////////////////////////////////////////////////////////////////////////
Task("Pack")
.IsDependentOn("Clean")
.IsDependentOn("Copy")
.Does(() =>
{
var settings = new NuGetPackSettings
{
Version = packageVersion,
OutputDirectory = buildArtifacts
};
if (AppVeyor.IsRunningOnAppVeyor)
{
settings.Version = packageVersion + "-b" + AppVeyor.Environment.Build.Number.ToString().PadLeft(4,'0');
}
NuGetPack("./feed/IdentityServer4.Templates.nuspec", settings);
if (sign)
{
var packages = GetFiles("./artifacts/**/*.nupkg");
foreach(var package in packages)
{
SignFile(package.FullPath);
}
}
});
private void SignFile(string fileName)
{
var signClientConfig = EnvironmentVariable("SignClientConfig") ?? "";
var signClientSecret = EnvironmentVariable("SignClientSecret") ?? "";
if (signClientConfig == "")
{
throw new Exception("SignClientConfig environment variable is missing. Aborting.");
}
if (signClientSecret == "")
{
throw new Exception("SignClientSecret environment variable is missing. Aborting.");
}
Information(" Signing " + fileName);
var success = StartProcess("dotnet", new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("SignClient")
.Append("sign")
.Append($"-c {signClientConfig}")
.Append($"-i {fileName}")
.Append("-r [email protected]")
.Append($"-s {signClientSecret}")
.Append(@"-n 'IdentityServer4'")
});
if (success == 0)
{
Information(" success.");
}
else
{
throw new Exception("Error signing " + fileName);
}
}
Task("Default")
.IsDependentOn("Pack");
RunTarget(target);