forked from SQLStreamStore/SQLStreamStore
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.cake
More file actions
115 lines (104 loc) · 2.9 KB
/
build.cake
File metadata and controls
115 lines (104 loc) · 2.9 KB
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
#addin "nuget:?package=Cake.FileHelpers&version=3.0.0"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var artifactsDir = Directory("./artifacts");
var sourceDir = Directory("./src");
var solution = "./src/SqlStreamStore.sln";
var buildNumber = string.IsNullOrWhiteSpace(EnvironmentVariable("TRAVIS_BUILD_NUMBER")) ? "0" : EnvironmentVariable("TRAVIS_BUILD_NUMBER");
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDir);
});
Task("RestorePackages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solution);
});
Task("Compile")
.IsDependentOn("RestorePackages")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration
};
DotNetCoreBuild(solution, settings);
});
Task("RunTests")
.IsDependentOn("Compile")
.Does(() =>
{
var projects = new string[]
{
"SqlStreamStore.Tests",
"SqlStreamStore.MsSql.Tests",
"SqlStreamStore.MsSql.V3.Tests",
"SqlStreamStore.Postgres.Tests",
};
foreach(var project in projects)
{
var projectDir = $"./src/{project}/";
var projectFile = $"{project}.csproj";
var settings = new DotNetCoreTestSettings
{
Configuration = configuration,
WorkingDirectory = projectDir,
NoBuild = true,
NoRestore = true,
ResultsDirectory = artifactsDir,
Logger = $"trx;LogFileName={project}.xml"
};
DotNetCoreTest(projectFile, settings);
}
});
Task("DotNetPack")
.IsDependentOn("Compile")
.Does(() =>
{
var versionSuffix = "build" + buildNumber.ToString().PadLeft(5, '0');
var projects = new string[]
{
"SqlStreamStore",
"SqlStreamStore.MsSql",
"SqlStreamStore.Postgres"
};
var settings = new DotNetCorePackSettings
{
OutputDirectory = artifactsDir,
NoBuild = true,
Configuration = configuration,
VersionSuffix = versionSuffix,
};
foreach(var project in projects)
{
DotNetCorePack($"./src/{project}", settings);
}
});
Task("PublishPackages")
.IsDependentOn("DotNetPack")
.Does(() =>
{
var apiKey = EnvironmentVariable("MYGET_API_KEY");
if(string.IsNullOrWhiteSpace(apiKey))
{
Information("MyGet API key not available. Packages will not be pushed.");
return;
}
var settings = new DotNetCoreNuGetPushSettings
{
ApiKey = EnvironmentVariable("MYGET_API_KEY"),
Source = "https://www.myget.org/F/sqlstreamstore/api/v3/index.json"
};
var files = GetFiles("artifacts/*.nupkg");
foreach(var file in files)
{
Information(file);
DotNetCoreNuGetPush(file.FullPath, settings);
}
});
Task("Default")
.IsDependentOn("RunTests")
.IsDependentOn("PublishPackages");
RunTarget(target);