forked from Xablu/Xablu.ADAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
151 lines (127 loc) · 4.1 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
#tool "nuget:?package=GitVersion.CommandLine"
#tool "nuget:?package=gitlink"
var sln = new FilePath("src/Xablu.Adal.sln");
var outputDir = new DirectoryPath("artifacts");
var nuspecDir = new DirectoryPath("nuspec");
var target = Argument("target", "Default");
var local = BuildSystem.IsLocalBuild;
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;
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var isRepository = StringComparer.OrdinalIgnoreCase.Equals("Xablu/Xablu.Adal", AppVeyor.Environment.Repository.Name);
Task("Clean").Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
CleanDirectories(outputDir.FullPath);
});
GitVersion versionInfo = null;
Task("Version").Does(() => {
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
Information("VI:\t{0}", versionInfo.FullSemVer);
});
Task("UpdateAppVeyorBuildNumber")
.IsDependentOn("Version")
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() =>
{
AppVeyor.UpdateBuildVersion(versionInfo.FullBuildMetaData);
});
Task("Restore").Does(() => {
NuGetRestore(sln);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("UpdateAppVeyorBuildNumber")
.IsDependentOn("Restore")
.Does(() => {
DotNetBuild(sln,
settings => settings.SetConfiguration("Release")
.WithProperty("DebugSymbols", "true")
.WithProperty("DebugType", "Full")
.WithTarget("Build"));
});
Task("GitLink")
.IsDependentOn("Build")
//pdbstr.exe and costura are not xplat currently
.WithCriteria(() => IsRunningOnWindows())
.Does(() =>
{
GitLink(sln.GetDirectory(),
new GitLinkSettings {
RepositoryUrl = "https://github.com/Xablu/Xablu.Adal",
ArgumentCustomization = args => args.Append("-ignore apiclient.sample")
});
});
Task("Package")
.IsDependentOn("GitLink")
.Does(() =>
{
var nugetSettings = new NuGetPackSettings {
Authors = new [] { "Xablu" },
Owners = new [] { "Xablu" },
IconUrl = new Uri("https://raw.githubusercontent.com/Xablu/Xablu.Adal/master/icon_xablu.png"),
ProjectUrl = new Uri("https://github.com/Xablu/Xablu.Adal"),
LicenseUrl = new Uri("https://github.com/Xablu/Xablu.Adal/blob/master/LICENSE"),
Copyright = "Copyright (c) Xablu",
RequireLicenseAcceptance = false,
Version = versionInfo.NuGetVersion,
Symbols = false,
NoPackageAnalysis = true,
OutputDirectory = outputDir,
Verbosity = NuGetVerbosity.Detailed,
BasePath = "./nuspec"
};
EnsureDirectoryExists(outputDir);
var nuspecs = new List<string> {
"Xablu.Adal.nuspec"
};
foreach(var nuspec in nuspecs)
{
NuGetPack(nuspecDir + "/" + nuspec, nugetSettings);
}
});
Task("PublishPackages")
.IsDependentOn("Package")
.WithCriteria(() => !local)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRepository)
.WithCriteria(() => isDevelopBranch || isReleaseBranch)
.Does (() =>
{
if (isReleaseBranch && !isTagged)
{
Information("Packages will not be published as this release has not been tagged.");
return;
}
// Resolve the API key.
var apiKey = EnvironmentVariable("NUGET_APIKEY");
if (string.IsNullOrEmpty(apiKey))
{
throw new Exception("The NUGET_APIKEY environment variable is not defined.");
}
var source = EnvironmentVariable("NUGET_SOURCE");
if (string.IsNullOrEmpty(source))
{
throw new Exception("The NUGET_SOURCE environment variable is not defined.");
}
var nugetFiles = GetFiles(outputDir + "/*.nupkg");
foreach(var nugetFile in nugetFiles)
{
NuGetPush(nugetFile, new NuGetPushSettings {
Source = source,
ApiKey = apiKey
});
}
});
Task("Default")
.IsDependentOn("PublishPackages")
.Does(() => {
});
RunTarget(target);