forked from fluentribbon/Fluent.Ribbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
204 lines (174 loc) · 6.28 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
//////////////////////////////////////////////////////////////////////
#tool paket:?package=GitVersion.CommandLine
#tool paket:?package=NUnit.ConsoleRunner
#addin paket:?package=Cake.Figlet
#addin paket:?package=Cake.Paket
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
if (string.IsNullOrWhiteSpace(target))
{
target = "Default";
}
var configuration = Argument("configuration", "Release");
if (string.IsNullOrWhiteSpace(configuration))
{
configuration = "Release";
}
var verbosity = Argument("verbosity", Verbosity.Normal);
if (string.IsNullOrWhiteSpace(configuration))
{
verbosity = Verbosity.Normal;
}
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Set build version
GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.BuildServer });
GitVersion gitVersion;
var local = BuildSystem.IsLocalBuild;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var isDevelopBranch = StringComparer.OrdinalIgnoreCase.Equals("develop", AppVeyor.Environment.Repository.Branch);
var isReleaseBranch = StringComparer.OrdinalIgnoreCase.Equals("master", AppVeyor.Environment.Repository.Branch);
var isTagged = AppVeyor.Environment.Repository.Tag.IsTag;
// Define directories.
var buildDir = Directory("./bin");
var publishDir = Directory("./Publish");
var solutionFile = File("./Fluent.Ribbon.sln");
var username = "";
var token = "";
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Setup(context =>
{
gitVersion = GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.Json });
Information("Informational Version : {0}", gitVersion.InformationalVersion);
Information("SemVer Version : {0}", gitVersion.SemVer);
Information("AssemblySemVer Version : {0}", gitVersion.AssemblySemVer);
Information("MajorMinorPatch Version: {0}", gitVersion.MajorMinorPatch);
Information("NuGet Version : {0}", gitVersion.NuGetVersion);
Information("IsLocalBuild : {0}", local);
Information(Figlet("Fluent.Ribbon"));
});
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("Restore")
//.IsDependentOn("Clean")
.Does(() =>
{
MSBuild(solutionFile, settings =>
settings
.SetConfiguration(configuration)
.WithTarget("restore")
);
});
Task("Update-SolutionInfo")
.Does(() =>
{
var solutionInfo = "./Shared/GlobalAssemblyInfo.cs";
GitVersion(new GitVersionSettings { UpdateAssemblyInfo = true, UpdateAssemblyInfoFilePath = solutionInfo});
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(solutionFile, settings =>
settings
.SetMaxCpuCount(0)
.SetConfiguration(configuration)
// .SetVerbosity(verbosity)
.SetVerbosity(Verbosity.Minimal)
);
}
});
Task("EnsurePublishDirectory")
.Does(() =>
{
EnsureDirectoryExists(publishDir);
});
Task("Pack")
.IsDependentOn("EnsurePublishDirectory")
.Does(() =>
{
PaketPack(publishDir, new PaketPackSettings { Version = isReleaseBranch ? gitVersion.MajorMinorPatch : gitVersion.NuGetVersion, BuildConfig = configuration });
});
Task("Zip")
.IsDependentOn("EnsurePublishDirectory")
.Does(() =>
{
Zip(buildDir.ToString() + "/Fluent.Ribbon/" + configuration, publishDir.ToString() + "/Fluent.Ribbon-v" + gitVersion.NuGetVersion + ".zip");
Zip(buildDir.ToString() + "/Fluent.Ribbon.Showcase/" + configuration, publishDir.ToString() + "/Fluent.Ribbon.Showcase-v" + gitVersion.NuGetVersion + ".zip");
});
Task("Tests")
.Does(() =>
{
NUnit3(
buildDir.ToString() + "/Fluent.Ribbon.Tests/**/" + configuration + "/**/*.Tests.dll",
new NUnit3Settings { ToolPath = "./packages/cake/NUnit.ConsoleRunner/tools/nunit3-console.exe" }
);
});
Task("GetCredentials")
.Does(() =>
{
// username = EnvironmentVariable("GITHUB_USERNAME_FLUENT_RIBBON");
// if (string.IsNullOrEmpty(username))
// {
// throw new Exception("The GITHUB_USERNAME_FLUENT_RIBBON environment variable is not defined.");
// }
// token = EnvironmentVariable("GITHUB_TOKEN_FLUENT_RIBBON");
// if (string.IsNullOrEmpty(token))
// {
// throw new Exception("The GITHUB_TOKEN_FLUENT_RIBBON environment variable is not defined.");
// }
});
Task("CreateReleaseNotes")
.WithCriteria(() => !isTagged)
.IsDependentOn("EnsurePublishDirectory")
.IsDependentOn("GetCredentials")
.Does(() =>
{
// GitReleaseManagerCreate(username, token, "fluentribbon", "Fluent.Ribbon", new GitReleaseManagerCreateSettings {
// Milestone = gitVersion.MajorMinorPatch,
// Name = "Fluent.Ribbon" + gitVersion.SemVer,
// Prerelease = false,
// TargetCommitish = "master",
// WorkingDirectory = "./"
// });
});
Task("ExportReleaseNotes")
.IsDependentOn("EnsurePublishDirectory")
.IsDependentOn("GetCredentials")
.Does(() =>
{
// GitReleaseManagerExport(username, token, "fluentribbon", "Fluent.Ribbon", publishDir.ToString() + "/releasenotes.md", new GitReleaseManagerExportSettings {
// // TagName = gitVersion.SemVer,
// TagName = "v6.1.0",
// TargetDirectory = publishDir,
// LogFilePath = publishDir.ToString() + "/grm.log"
// });
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build");
Task("appveyor")
.IsDependentOn("Update-SolutionInfo")
.IsDependentOn("Build")
.IsDependentOn("Tests")
.IsDependentOn("Pack")
.IsDependentOn("Zip");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);