-
-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathparameters.cake
154 lines (137 loc) · 5.88 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#load "./paths.cake"
#load "./packages.cake"
#load "./version.cake"
#load "./credentials.cake"
public class BuildParameters
{
public string Target { get; }
public string Configuration { get; }
public bool IsLocalBuild { get; }
public bool IsRunningOnUnix { get; }
public bool IsRunningOnWindows { get; }
public bool IsRunningOnAppVeyor { get; }
public bool IsPullRequest { get; }
public bool IsMainCakeRepo { get; }
public bool IsMainCakeBranch { get; }
public bool IsDevelopCakeBranch { get; }
public bool IsTagged { get; }
public bool IsPublishBuild { get; }
public bool IsReleaseBuild { get; }
public bool SkipGitVersion { get; }
public bool SkipSigning { get; }
public BuildCredentials GitHub { get; }
public TwitterCredentials Twitter { get; }
public ReleaseNotes ReleaseNotes { get; }
public BuildVersion Version { get; set; }
public BuildPaths Paths { get; }
public BuildPackages Packages { get; }
public bool PublishingError { get; set; }
public DotNetMSBuildSettings MSBuildSettings { get; }
public CodeSigningCredentials CodeSigning { get; }
public bool ShouldPublish
{
get
{
return !IsLocalBuild && !IsPullRequest && IsMainCakeRepo
&& IsMainCakeBranch && IsTagged;
}
}
public bool ShouldPublishToMyGet
{
get
{
return false; /* !IsLocalBuild && !IsPullRequest && IsMainCakeRepo
&& (IsTagged || IsDevelopCakeBranch);*/
}
}
public bool ShouldSignPackages { get; }
public bool CanPostToTwitter
{
get
{
return !string.IsNullOrEmpty(Twitter.ConsumerKey) &&
!string.IsNullOrEmpty(Twitter.ConsumerSecret) &&
!string.IsNullOrEmpty(Twitter.AccessToken) &&
!string.IsNullOrEmpty(Twitter.AccessTokenSecret);
}
}
public BuildParameters (ISetupContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
var buildSystem = context.BuildSystem();
Target = context.TargetTask.Name;
Configuration = context.Argument("configuration", "Release");
IsLocalBuild = buildSystem.IsLocalBuild;
IsRunningOnUnix = context.IsRunningOnUnix();
IsRunningOnWindows = context.IsRunningOnWindows();
IsRunningOnAppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor;
IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
IsMainCakeRepo = StringComparer.OrdinalIgnoreCase.Equals("cake-build/cake", buildSystem.AppVeyor.Environment.Repository.Name);
IsMainCakeBranch = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.AppVeyor.Environment.Repository.Branch);
IsDevelopCakeBranch = StringComparer.OrdinalIgnoreCase.Equals("develop", buildSystem.AppVeyor.Environment.Repository.Branch);
IsTagged = IsBuildTagged(buildSystem);
GitHub = BuildCredentials.GetGitHubCredentials(context);
Twitter = TwitterCredentials.GetTwitterCredentials(context);
CodeSigning = CodeSigningCredentials.GetCodeSigningCredentials(context);
ReleaseNotes = context.ParseReleaseNotes("./ReleaseNotes.md");
IsPublishBuild = IsPublishing(context.TargetTask.Name);
IsReleaseBuild = IsReleasing(context.TargetTask.Name);
SkipSigning = StringComparer.OrdinalIgnoreCase.Equals("True", context.Argument("skipsigning", "False"));
SkipGitVersion = StringComparer.OrdinalIgnoreCase.Equals("True", context.EnvironmentVariable("CAKE_SKIP_GITVERSION"));
Version = BuildVersion.Calculate(context, this);
Paths = BuildPaths.GetPaths(context, Configuration, Version.SemVersion);
Packages = BuildPackages.GetPackages(
Paths.Directories.NuGetRoot,
Version.SemVersion,
new [] {
"Cake.Core",
"Cake.Common",
"Cake.Testing",
"Cake.Testing.Xunit",
"Cake.NuGet",
"Cake.Tool",
"Cake.Frosting",
"Cake.Frosting.Template",
"Cake.Cli",
"Cake.DotNetTool.Module"
});
var releaseNotes = string.Join(
System.Environment.NewLine,
ReleaseNotes.Notes.ToArray()
);
MSBuildSettings = new DotNetMSBuildSettings {
Version = Version.SemVersion,
AssemblyVersion = Version.Version,
FileVersion = Version.Version,
PackageReleaseNotes = releaseNotes
};
if (!IsLocalBuild)
{
MSBuildSettings.WithProperty("TemplateVersion", Version.SemVersion);
}
ShouldSignPackages = (!SkipSigning && ShouldPublish)
||
StringComparer.OrdinalIgnoreCase.Equals(
context.EnvironmentVariable("SIGNING_TEST"),
"True"
);
}
private static bool IsBuildTagged(BuildSystem buildSystem)
{
return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name);
}
private static bool IsReleasing(string target)
{
var targets = new [] { "Publish", "Publish-NuGet", "Publish-GitHub-Release" };
return targets.Any(t => StringComparer.OrdinalIgnoreCase.Equals(t, target));
}
private static bool IsPublishing(string target)
{
var targets = new [] { "ReleaseNotes", "Create-Release-Notes" };
return targets.Any(t => StringComparer.OrdinalIgnoreCase.Equals(t, target));
}
}