forked from reactiveui/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
143 lines (117 loc) · 4.78 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
#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0
#tool "dotnet:?package=Wyam.Tool&version=2.2.9"
#addin "nuget:?package=Cake.Git&version=0.21.0"
#addin "nuget:?package=Octokit&version=0.48.0"
using Octokit;
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var dependenciesDir = Directory("./dependencies");
var outputPath = MakeAbsolute(Directory("./output"));
var reactiveUiSourceDir = dependenciesDir + Directory("reactiveui");
var dynamicDataSrcDir = dependenciesDir + Directory("dynamicdata");
var sextantSrcDir = dependenciesDir + Directory("sextant");
var akavacheSrcDir = dependenciesDir + Directory("akavache");
//////////////////////////////////////////////////////////////////////
// SETUP
//////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
// Executed BEFORE the first task.
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
if(DirectoryExists(dependenciesDir))
{
CleanDirectory(dependenciesDir);
DeleteDirectory(dependenciesDir, new DeleteDirectorySettings { Recursive = true, Force = true });
}
CreateDirectory(dependenciesDir);
});
Task("GetSource")
.IsDependentOn("Clean")
.Does(() =>
{
GetSource("Akavache");
GetSource("DynamicData");
GetSource("ReactiveUI");
GetSource("Sextant");
GetSource("splat");
});
Task("Build")
.IsDependentOn("GetArtifacts")
.Does(() =>
{
StartProcess(Context.Tools.Resolve("Wyam*"), new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("build")
.AppendSwitch("--recipe", "Docs")
.AppendSwitch("--theme", "Samson")
.Append("-l")
});
Zip("./output", "output.zip", "./output/**/*");
});
Task("Preview")
.IsDependentOn("GetArtifacts")
.Does(() =>
{
StartProcess(Context.Tools.Resolve("Wyam*"), new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("build")
.AppendSwitch("--recipe", "Docs")
.AppendSwitch("--theme", "Samson")
.Append("-l")
.Append("--preview")
.Append("--watch")
});
});
// Assumes Wyam source is local and at ../../WyamIO/Wyam
Task("Debug")
.Does(() =>
{
var wyamFolder = MakeAbsolute(Directory("../../wyamio/Wyam")).ToString();
var wyamExecutable = wyamFolder + "/src/clients/Wyam/bin/Debug/netcoreapp2.1/Wyam.dll";
var wyamIntegrationFolder = wyamFolder + "/tests/integration/Wyam.Examples.Tests";
var wyamIntegrationBinFolder = wyamIntegrationFolder + "/bin/Debug/netcoreapp2.1";
var wyamProject = wyamIntegrationFolder + "/Wyam.Examples.Tests.csproj";
Information($"Building project {wyamProject}");
DotNetCoreBuild(wyamProject);
Information($"Running WYAM at {wyamExecutable}");
DotNetCoreExecute(wyamExecutable,
$"-a \"{wyamIntegrationBinFolder}/**/*.dll\" -r \"docs -i\" -t \"{wyamFolder}/themes/Docs/Samson\" -p");
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build");
Task("GetArtifacts")
.IsDependentOn("GetSource");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
if (!StringComparer.OrdinalIgnoreCase.Equals(target, "Deploy"))
{
RunTarget(target);
}
void GetSource(string name)
{
string branch = "main";
Information($"Downloading {name} from the {branch} branch");
FilePath zip = DownloadFile($"https://codeload.github.com/reactiveui/{name}/zip/{branch}");
Information($"Downloaded {name}");
Unzip(zip, dependenciesDir);
// Need to rename the container directory in the zip file to something consistent
var containerDir = GetDirectories(dependenciesDir.Path.FullPath + "/*").First(x => x.GetDirectoryName().StartsWith(name));
var srcDirectory = dependenciesDir + Directory(name.ToLower());
MoveDirectory(containerDir, srcDirectory);
}