forked from GitTools/GitVersion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
165 lines (141 loc) · 4.94 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
// Install modules
#module nuget:?package=Cake.DotNetTool.Module&version=0.3.1
// Install addins.
#addin "nuget:?package=Cake.Codecov&version=0.7.0"
#addin "nuget:?package=Cake.Compression&version=0.2.4"
#addin "nuget:?package=Cake.Coverlet&version=2.3.4"
#addin "nuget:?package=Cake.Docker&version=0.10.1"
#addin "nuget:?package=Cake.Gem&version=0.8.1"
#addin "nuget:?package=Cake.Gitter&version=0.11.1"
#addin "nuget:?package=Cake.Incubator&version=5.1.0"
#addin "nuget:?package=Cake.Json&version=4.0.0"
#addin "nuget:?package=Cake.Npm&version=0.17.0"
#addin "nuget:?package=Cake.Tfx&version=0.9.1"
#addin "nuget:?package=Newtonsoft.Json&version=12.0.2"
#addin "nuget:?package=SharpZipLib&version=1.2.0"
#addin "nuget:?package=xunit.assert&version=2.4.1"
// Install tools.
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0"
#tool "nuget:?package=nuget.commandline&version=5.2.0"
// Install .NET Core Global tools.
#tool "dotnet:?package=Codecov.Tool&version=1.7.2"
#tool "dotnet:?package=GitReleaseManager.Tool&version=0.8.0"
// Load other scripts.
#load "./build/utils/parameters.cake"
#load "./build/utils/utils.cake"
#load "./build/pack.cake"
#load "./build/artifacts-test.cake"
#load "./build/docker.cake"
#load "./build/publish.cake"
using Xunit;
using System.Diagnostics;
//////////////////////////////////////////////////////////////////////
// PARAMETERS
//////////////////////////////////////////////////////////////////////
bool publishingError = false;
bool singleStageRun = true;
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup<BuildParameters>(context =>
{
EnsureDirectoryExists("artifacts");
var parameters = BuildParameters.GetParameters(context);
var gitVersion = GetVersion(parameters);
parameters.Initialize(context, gitVersion);
// Increase verbosity?
if (parameters.IsMainBranch && (context.Log.Verbosity != Verbosity.Diagnostic)) {
Information("Increasing verbosity to diagnostic.");
context.Log.Verbosity = Verbosity.Diagnostic;
}
Information("Building version {0} of GitVersion ({1}, {2})",
parameters.Version.SemVersion,
parameters.Configuration,
parameters.Target);
Information("Repository info : IsMainRepo {0}, IsMainBranch {1}, IsTagged: {2}, IsPullRequest: {3}",
parameters.IsMainRepo,
parameters.IsMainBranch,
parameters.IsTagged,
parameters.IsPullRequest);
return parameters;
});
Teardown<BuildParameters>((context, parameters) =>
{
try
{
Information("Starting Teardown...");
Information("Repository info : IsMainRepo {0}, IsMainBranch {1}, IsTagged: {2}, IsPullRequest: {3}",
parameters.IsMainRepo,
parameters.IsMainBranch,
parameters.IsTagged,
parameters.IsPullRequest);
Information("Finished running tasks.");
}
catch (Exception exception)
{
Error(exception.Dump());
}
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Pack")
.IsDependentOn("Pack-Vsix")
.IsDependentOn("Pack-Gem")
.IsDependentOn("Pack-Nuget")
.IsDependentOn("Pack-Chocolatey")
.IsDependentOn("Zip-Files")
.Does<BuildParameters>((parameters) =>
{
Information("The build artifacts: \n");
foreach(var artifact in parameters.Artifacts.All)
{
if (FileExists(artifact.ArtifactPath)) { Information("Artifact: {0}", artifact.ArtifactPath); }
}
foreach(var package in parameters.Packages.All)
{
if (FileExists(package.PackagePath)) { Information("Artifact: {0}", package.PackagePath); }
}
})
.ReportError(exception =>
{
Error(exception.Dump());
});
Task("Publish")
.IsDependentOn("Publish-AppVeyor")
.IsDependentOn("Publish-AzurePipeline")
.IsDependentOn("Publish-Coverage")
.IsDependentOn("Publish-NuGet")
.IsDependentOn("Publish-Chocolatey")
.IsDependentOn("Publish-Vsix")
.IsDependentOn("Publish-Gem")
.Finally(() =>
{
if (publishingError)
{
throw new Exception("An error occurred during the publishing of GitVersion. All publishing tasks have been attempted.");
}
});
Task("Publish-DockerHub")
.IsDependentOn("Docker-Publish")
.Finally(() =>
{
if (publishingError)
{
throw new Exception("An error occurred during the publishing of GitVersion. All publishing tasks have been attempted.");
}
});
Task("Release")
.IsDependentOn("Release-Notes")
.Finally(() =>
{
});
Task("Default")
.IsDependentOn("Publish")
.IsDependentOn("Publish-DockerHub")
.IsDependentOn("Release");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
RunTarget(target);