forked from AgileArchitect/MSBuild.SonarQube.Runner.Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
87 lines (69 loc) · 3.36 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
#addin "Cake.Git"
var target = Argument("target", "Default");
var package = "MSBuild.SonarQube.Runner.Tool";
var local = BuildSystem.IsLocalBuild;
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var buildNumber = AppVeyor.Environment.Build.Number;
var branchName = isRunningOnAppVeyor ? EnvironmentVariable("APPVEYOR_REPO_BRANCH") : GitBranchCurrent(DirectoryPath.FromString(".")).FriendlyName;
var isMasterBranch = System.String.Equals("master", branchName, System.StringComparison.OrdinalIgnoreCase);
///////////////////////////////////////////////////////////////////////////////
// VERSION
///////////////////////////////////////////////////////////////////////////////
var version = "3.0.0";
var toolVersion = "3.0.0.629";
var semVersion = local ? version : (version + string.Concat("+", buildNumber));
Task("Pack")
.Does(() => {
CreateDirectory("nuget");
CleanDirectory("nuget");
var nuGetPackSettings = new NuGetPackSettings {
Id = package,
Version = version,
Title = package,
Authors = new[] {"Tom Staijen"},
Owners = new[] {"Tom Staijen", "cake-contrib"},
Description = "Nuget tool package for MSBUild.SonarQube.Runner",
Summary = "Contains the runner with version " + toolVersion,
ProjectUrl = new Uri("https://github.com/AgileArchitect/MSBuild.SonarQube.Runner.Tool"),
LicenseUrl = new Uri("https://github.com/AgileArchitect/MSBuild.SonarQube.Runner.Tool/blob/master/LICENCE"),
RequireLicenseAcceptance= false,
Symbols = false,
NoPackageAnalysis = true,
Files = new []
{
new NuSpecContent {Source = string.Format(@"**", package), Target = "tools"}
},
BasePath = "./runner",
OutputDirectory = "./nuget"
};
NuGetPack(nuGetPackSettings);
});
Task("Publish")
.IsDependentOn("Pack")
.WithCriteria(() => isRunningOnAppVeyor)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isMasterBranch)
.Does(() => {
var apiKey = EnvironmentVariable("NUGET_API_KEY");
if(string.IsNullOrEmpty(apiKey))
throw new InvalidOperationException("Could not resolve Nuget API key.");
var p = "./nuget/" + package + "." + version + ".nupkg";
// Push the package.
NuGetPush(p, new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package",
ApiKey = apiKey
});
});
Task("Update-AppVeyor-Build-Number")
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() =>
{
AppVeyor.UpdateBuildVersion(semVersion);
});
Task("AppVeyor")
.IsDependentOn("Update-AppVeyor-Build-Number")
.IsDependentOn("Publish");
Task("Default")
.IsDependentOn("Pack");
RunTarget(target);