-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
94 lines (78 loc) · 3.53 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
#module "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.Module&prerelease"
#tool "nuget:?package=GitVersion.CommandLine&version=5.0.1"
// #addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.JeevanJames&prerelease&loaddependencies=true"
#addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.Ci.AppVeyor&prerelease"
#addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.Core&prerelease"
#addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.GitVersion&prerelease"
#addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.DotNetCore&prerelease"
#addin "nuget:https://myget.org/f/cake-tasks/?package=Cake.Tasks.JeevanJames&prerelease"
ConfigureTask<DotNetCoreConfig>(cfg =>
{
cfg.Test.Skip = true;
});
public static void DeployPackage(this ICakeContext ctx, string root, string projectName, EnvConfig env)
{
string outputDirectory = System.IO.Path.Combine(env.Directories.BinaryOutput, projectName);
string packagePath = System.IO.Path.Combine(outputDirectory, $"{projectName}.{env.Version.Build}.nupkg");
string nugetFeed = ctx.EnvironmentVariable("MYGET_FEED");
string nugetApiKey = ctx.EnvironmentVariable("MYGET_APIKEY");
ctx.DotNetCorePack($"./{root}/{projectName}/{projectName}.csproj", new DotNetCorePackSettings
{
IncludeSource = true,
IncludeSymbols = true,
Configuration = env.Configuration,
OutputDirectory = outputDirectory,
ArgumentCustomization = arg => arg.Append($"/p:Version={env.Version.Build}"),
});
ctx.Log.Information($"Pushing package {packagePath} to {nugetFeed}");
ctx.DotNetCoreNuGetPush(packagePath, new DotNetCoreNuGetPushSettings
{
ApiKey = nugetApiKey,
Source = nugetFeed,
});
}
Task("DeployIndividualPackages")
.IsDependentOn("_Config")
.Does<TaskConfig>((ctx, cfg) =>
{
EnvConfig env = cfg.Load<EnvConfig>();
if (!env.IsCi)
{
Warning("Not in CI system. Cannot deploy NuGet packages.");
return;
}
ctx.DeployPackage("src", "Cake.Tasks.Module", env);
ctx.DeployPackage("src", "Cake.Tasks.Core", env);
ctx.DeployPackage("plugin", "Cake.Tasks.Ci.AppVeyor", env);
ctx.DeployPackage("plugin", "Cake.Tasks.Ci.Tfs", env);
ctx.DeployPackage("plugin", "Cake.Tasks.DotNetCore", env);
ctx.DeployPackage("plugin", "Cake.Tasks.GitVersion", env);
ctx.DeployPackage("plugin", "Cake.Tasks.JeevanJames", env);
});
Task("DeployRecipePackage")
.IsDependentOn("DeployIndividualPackages")
.Does<TaskConfig>((ctx, cfg) =>
{
EnvConfig env = cfg.Load<EnvConfig>();
if (!env.IsCi)
return;
string nuspecFile = System.IO.Path.Combine(env.Directories.Working, "metapackage", "CakeTasks.nuspec");
string nuspecContent = System.IO.File.ReadAllText(nuspecFile)
.Replace("0.1.0", env.Version.Build);
System.IO.File.WriteAllText(nuspecFile, nuspecContent);
string nugetFeed = EnvironmentVariable("MYGET_FEED");
string nugetApiKey = EnvironmentVariable("MYGET_APIKEY");
string outputDirectory = System.IO.Path.Combine(env.Directories.BinaryOutput, "metapackage");
string packagePath = System.IO.Path.Combine(outputDirectory, $"Cake.Tasks.JeevanJames.{env.Version.Build}.nupkg");
NuGetPack(nuspecFile, new NuGetPackSettings
{
OutputDirectory = outputDirectory,
Version = env.Version.Build,
});
ctx.DotNetCoreNuGetPush(packagePath, new DotNetCoreNuGetPushSettings
{
ApiKey = nugetApiKey,
Source = nugetFeed,
});
});
RunTarget(Argument("target", "Default"));