This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
193 lines (163 loc) · 6.12 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
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.4.0"
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
#addin "nuget:?package=Cake.Incubator&version=4.0.2"
using Cake.Incubator.LoggingExtensions;
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = Directory("./src/DotNetCasClient.Redis/bin/" + configuration);
var artifactDir = Directory("./artifacts");
// Define project metadata properties.
var projectOwners = "Apereo Foundation";
var projectName = "Apereo .NET CAS Client Redis backed Proxy/Service Ticket Managers";
var projectDescription = "Redis backed Proxy/Service Ticket Managers for the Apereo .NET CAS Client.";
var copyright = string.Format("Copyright (c) 2007-{0} Apereo. All rights reserved.", DateTime.Now.Year);
// Get/set version information.
var versionInfo = GitVersion();
var buildNumber = AppVeyor.Environment.Build.Number.ToString();
var buildNumberPadded = AppVeyor.Environment.Build.Number.ToString("00000");
var isAppveyorBuild = BuildSystem.IsRunningOnAppVeyor;
var assemblyVersion = string.Concat(new string[]{
versionInfo.Major.ToString(),
".",
versionInfo.Minor.ToString(),
".0.0"
});
var assemblyFileVersion = string.Concat(new string[]{
versionInfo.MajorMinorPatch,
".",
buildNumber
});
var assemblyInformationalVersion = versionInfo.InformationalVersion;
// Set NuGet version.
var nugetPackageVersion = "";
if (isAppveyorBuild)
{
// AppVeyor build.
var tag = AppVeyor.Environment.Repository.Tag;
if (tag.IsTag)
{
// Tag build. Used for stable and pre-release NuGet packages.
nugetPackageVersion = versionInfo.NuGetVersion;
}
else
{
// Regular commit build.
nugetPackageVersion = versionInfo.MajorMinorPatch + "-ci-" + buildNumberPadded;
if (AppVeyor.Environment.PullRequest.IsPullRequest)
{
nugetPackageVersion += "-pr-" + AppVeyor.Environment.PullRequest.Number;
}
}
AppVeyor.UpdateBuildVersion(nugetPackageVersion);
}
else
{
// Local developer machine build.
nugetPackageVersion = versionInfo.MajorMinorPatch + "-local-" + versionInfo.CommitsSinceVersionSource.Value.ToString().PadLeft(5, '0');
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(artifactDir);
});
Task("Version")
.IsDependentOn("Clean")
.Does(() =>
{
Information("Is AppVeyor Build: {0}", isAppveyorBuild);
if (isAppveyorBuild)
{
var tag = AppVeyor.Environment.Repository.Tag;
Information("Is AppVeyor Tag Build: {0}", tag.IsTag);
if (tag.IsTag)
{
Information("Tag Name: {0}", tag.Name);
}
}
Information("Assembly Version: {0}", assemblyVersion);
Information("Assembly File Version: {0}", assemblyFileVersion);
Information("Assembly Informational Version: {0}", assemblyInformationalVersion);
Information("Build Number: {0}", buildNumber);
Information("NuGet Version: {0}", nugetPackageVersion);
Information("VCS Revision: {0}", versionInfo.Sha);
Information("VCS Branch Name: {0}", versionInfo.BranchName);
Information("GitVersion Info:\r\n{0}", versionInfo.Dump());
var file = "./src/DotNetCasClient.Redis/Properties/AutoGeneratedAssemblyInfo.cs";
CreateAssemblyInfo(file, new AssemblyInfoSettings{
Product = projectName,
Title = projectName,
Description = projectDescription,
Company = projectOwners,
Version = assemblyVersion,
FileVersion = assemblyFileVersion,
InformationalVersion = assemblyInformationalVersion,
Copyright = copyright
});
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Version")
.Does(() =>
{
NuGetRestore("./dotnet-cas-client-redis.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./dotnet-cas-client-redis.sln", settings =>
settings.SetConfiguration(configuration));
}
else
{
// Use XBuild
XBuild("./dotnet-cas-client-redis.sln", settings =>
settings.SetConfiguration(configuration));
}
});
Task("Pack")
.IsDependentOn("Build")
.Does(() =>
{
// Parse release notes.
var latestReleaseNote = ParseReleaseNotes("./ReleaseNotes.md");
var releaseNotes = new StringBuilder();
releaseNotes.AppendFormat("Version: {0}", latestReleaseNote.Version);
foreach(var note in latestReleaseNote.Notes)
{
releaseNotes.AppendFormat("\t{0}", note);
}
// Configure NuGet Pack settings.
var nuGetPackSettings = new NuGetPackSettings {
Version = nugetPackageVersion,
Title = projectName,
Owners = new []{projectOwners},
Copyright = copyright,
Description = projectDescription,
ReleaseNotes = new []{releaseNotes.ToString()},
OutputDirectory = artifactDir
};
NuGetPack("./src/DotNetCasClient.Redis/DotNetCasClient.Redis.nuspec", nuGetPackSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);