-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathparameters.cake
129 lines (106 loc) · 3.8 KB
/
parameters.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
public class BuildParameters
{
public static String ProjectDir = "./src/Cake.SqlServer/";
public static String Solution = "./src/Cake.SqlServer.sln";
public DirectoryPath BuildDir { get; private set; }
public string Target { get; private set; }
public string Configuration { get; private set; }
public bool IsLocalBuild { get; private set; }
public bool IsRunningOnAppVeyor { get; private set; }
public bool IsTagged { get; private set; }
public bool IsPullRequest { get; private set; }
public ReleaseNotes ReleaseNotes { get; private set; }
public bool IsMasterBranch { get; private set; }
public string Version { get; private set; }
public string SemVersion { get; private set; }
public bool SkipTests { get; private set; }
public void Initialize(ICakeContext context)
{
context.Information("Executing GitVersion");
var result = context.GitVersion(new GitVersionSettings{
UpdateAssemblyInfoFilePath = ProjectDir + "properties/AssemblyInfo.cs",
UpdateAssemblyInfo = true,
});
Version = result.MajorMinorPatch ?? "0.0.1";
SemVersion = result.LegacySemVerPadded ?? "0.0.1";
// print gitversion
context.GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});
}
public static BuildParameters GetParameters(ICakeContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
var target = context.Argument("target", "Default");
var configuration = context.Argument("configuration", "Release");
var buildSystem = context.BuildSystem();
var isMaster = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch);
context.Information("IsTagged: {0}", IsBuildTagged(buildSystem));
context.Information("IsMasterBranch: {0}", isMaster);
return new BuildParameters {
Target = target,
Configuration = configuration,
BuildDir = ProjectDir + "bin/" + configuration,
IsLocalBuild = buildSystem.IsLocalBuild,
IsRunningOnAppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor,
IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest,
IsTagged = IsBuildTagged(buildSystem),
IsMasterBranch = isMaster,
ReleaseNotes = context.ParseReleaseNotes("./ReleaseNotes.md"),
SkipTests = StringComparer.OrdinalIgnoreCase.Equals("True", context.Argument("skiptests", "false")),
};
}
private static bool IsBuildTagged(BuildSystem buildSystem)
{
return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name);
}
public string BuildResultDir
{
get
{
return "./build-results/v" + SemVersion + "/";
}
}
public string ResultBinDir
{
get
{
return BuildResultDir + "bin";
}
}
public string ResultNugetPath
{
get
{
return BuildResultDir + "Cake.SqlServer." + Version + ".nupkg";
}
}
public bool ShouldPublishToNugetOrg
{
get
{
return false;
// return !IsLocalBuild && !IsPullRequest && IsTagged && IsMasterBranch;
}
}
public bool ShouldPublishToMyGet
{
get
{
return true;
// return !IsLocalBuild && !IsPullRequest && !IsTagged || IsMasterBranch;
}
}
public string TestResultsFile
{
get
{
return BuildResultDir + "/TestsResults.xml";
}
}
}