-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
124 lines (91 loc) · 3.63 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
#addin nuget:https://www.nuget.org/api/v2/?package=Cake.Docker
#addin nuget:https://www.nuget.org/api/v2/?package=Cake.FileHelpers
#addin nuget:https://www.nuget.org/api/v2/?package=Cake.Docker
#addin nuget:https://www.nuget.org/api/v2/?package=Cake.AssemblyInfoReflector
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Full-Build");
var configuration = Argument("configuration", "Release");
var dockerPushCurrentVersion = HasArgument("dockerPushCurrentVersion");
var dockerPushAdditionalTag = Argument<string>("dockerPushAdditionalTag", null);
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var outputDir = Directory("Output/");
var artifactsDir = outputDir + Directory("Artifacts/");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDir);
});
Task("Restore-NuGet-Packages")
.Does(() =>
{
DotNetCoreRestore("NAME.Registry.UI.sln");
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var dotNetBuildConfig = new DotNetCoreBuildSettings() {
Configuration = configuration
};
DotNetCoreBuild("NAME.Registry.UI.sln", dotNetBuildConfig);
});
Task("Publish-Website")
.IsDependentOn("Clean")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var registryUiLocation = artifactsDir + Directory("NAME.Registry.UI/");
var settings = new DotNetCorePublishSettings {
Configuration = configuration,
OutputDirectory = registryUiLocation
};
DotNetCorePublish("./src/NAME.Registry.UI", settings);
Zip("./Output/Artifacts", "./Output/Artifacts/NAME.Registry.UI.zip", "./Output/Artifacts/**/*");
});
Task("Docker-Build-AND-Push")
.Does(() =>
{
var registryUiLocation = artifactsDir + Directory("NAME.Registry.UI/");
var reflectedAssemblyInfo = ReflectAssemblyInfo(registryUiLocation + File("NAME.Registry.UI.dll"));
var currentVersion = reflectedAssemblyInfo.AssemblyFileVersion;
var dockerImage = "nosinovacao/name-registry-ui";
var tags = new List<string>();
if (dockerPushCurrentVersion)
tags.Add(dockerImage + ":" + currentVersion);
if (!string.IsNullOrWhiteSpace(dockerPushAdditionalTag))
tags.Add(dockerImage + ":" + dockerPushAdditionalTag);
var buildSettings = new DockerBuildSettings() {
Tag = tags.ToArray()
};
DockerBuild(buildSettings, registryUiLocation);
foreach(var tag in tags) {
DockerPush(tag);
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Build-AND-Test")
.IsDependentOn("Build");
Task("AppVeyor")
.IsDependentOn("Build");
Task("TravisCI")
.IsDependentOn("Build")
.IsDependentOn("Publish-Website");
Task("Full-Build")
.IsDependentOn("Build-AND-Test");
Task("Default")
.IsDependentOn("Build-AND-Test");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);