-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.cake
56 lines (47 loc) · 1.45 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
#tool "nuget:?package=NuGet.CommandLine&version=6.12.1"
#addin "nuget:?package=Cake.MinVer&version=3.0.0"
#addin "nuget:?package=Cake.Args&version=3.0.0"
var target = ArgumentOrDefault<string>("target") ?? "pack";
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));
Task("clean")
.Does(() =>
{
CleanDirectories("./artifact/**");
});
Task("pack")
.IsDependentOn("clean")
.Does(() =>
{
NuGetPack("./src/nuspec/Unofficial.Microsoft.Solver.Foundation.Express.nuspec", new NuGetPackSettings
{
Version = buildVersion.PackageVersion,
OutputDirectory = "./artifact/nuget",
});
});
Task("push")
.IsDependentOn("pack")
.Does(context =>
{
var url = context.EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}
var nugetPushSettings = new DotNetNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};
foreach (var nugetPackageFile in GetFiles("./artifact/nuget/*.nupkg"))
{
DotNetNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});
RunTarget(target);