-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
108 lines (86 loc) · 2.82 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
#tool "nuget:?package=NuGet.CommandLine&version=4.9.2"
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
#addin "nuget:?package=Cake.FileHelpers&version=3.3.0"
#load "./build/types.cake"
var target = Argument("Target", "Full");
Setup<BuildState>(_ =>
{
var state = new BuildState
{
Paths = new BuildPaths
{
SolutionFile = MakeAbsolute(File("./Nybus.Templates.sln")),
NuSpecFile = MakeAbsolute(File("./Nybus.Templates.nuspec"))
}
};
CleanDirectory(state.Paths.OutputFolder);
return state;
});
Task("Version")
.Does<BuildState>(state =>
{
var version = GitVersion();
var packageVersion = version.SemVer;
var buildVersion = $"{version.FullSemVer}+{DateTimeOffset.UtcNow:yyyyMMddHHmmss}";
state.Version = new VersionInfo
{
PackageVersion = packageVersion,
BuildVersion = buildVersion
};
Information($"Package version: {state.Version.PackageVersion}");
Information($"Build version: {state.Version.BuildVersion}");
if (BuildSystem.IsRunningOnAppVeyor)
{
AppVeyor.UpdateBuildVersion(state.Version.BuildVersion);
}
});
Task("UpdateTemplatesToLatestVersion")
.Does(() =>
{
var packages = NuGetList("Nybus.Abstractions");
var latestVersion = packages.FirstOrDefault().Version;
Information($"Latest version for Nybus.Abstractions: {latestVersion}");
var files = ReplaceRegexInFiles("./content/**/*.csproj",
@"<PackageReference Include=""(Nybus[\w\.]*)"" Version="".+"" />",
$@"<PackageReference Include=""$1"" Version=""{latestVersion}"" />");
Information($"Updated {files.Count()} files");
foreach (var file in files)
{
Information($"\tUpdated {file.FullPath}");
}
});
Task("Pack")
.IsDependentOn("Version")
.Does<BuildState>(state =>
{
var settings = new NuGetPackSettings
{
Version = state.Version.PackageVersion,
OutputDirectory = state.Paths.OutputFolder
};
NuGetPack(state.Paths.NuSpecFile, settings);
});
Task("UploadPackagesToAppVeyor")
.IsDependentOn("Pack")
.WithCriteria(BuildSystem.IsRunningOnAppVeyor)
.Does<BuildState>(state =>
{
Information("Uploading packages");
var files = GetFiles($"{state.Paths.OutputFolder}/*.nukpg");
foreach (var file in files)
{
Information($"\tUploading {file.GetFilename()}");
AppVeyor.UploadArtifact(file, new AppVeyorUploadArtifactsSettings {
ArtifactType = AppVeyorUploadArtifactType.NuGetPackage,
DeploymentName = "NuGet"
});
}
});
Task("Push")
.IsDependentOn("UploadPackagesToAppVeyor");
Task("Full")
.IsDependentOn("Version")
.IsDependentOn("UpdateTemplatesToLatestVersion")
.IsDependentOn("Pack")
.IsDependentOn("Push");
RunTarget(target);