forked from xamarin/XamarinComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.cake
101 lines (71 loc) · 3.2 KB
/
publish.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
#tool "XamarinComponent"
#addin "nuget:?package=Cake.Json&version=1.0.2.13"
#addin "nuget:?package=Cake.Xamarin&version=1.3.0.15"
#addin "nuget:?package=Cake.ExtendedNuGet&version=1.0.0.24"
#addin "nuget:?package=NuGet.Core&version=2.14.0"
// NOTE: COOKIE_JAR_PATH Environment variable should contain the .xamarin cookie file
var TARGET = Argument ("target", Argument ("t", "build"));
var PREVIEW_ONLY = Argument ("preview", EnvironmentVariable ("PREVIEW_ONLY") ?? "false").Equals ("true");
var NUGET_FORCE_PUSH = Argument ("nuget-force-push", EnvironmentVariable ("NUGET_FORCE_PUSH") ?? "false").Equals ("true");
var NUGET_MAX_ATTEMPTS = 5;
var MYGET_FORCE_PUSH = Argument ("myget-force-push", EnvironmentVariable ("MYGET_FORCE_PUSH") ?? "false").Equals ("true");
var MYGET_MAX_ATTEMPTS = 5;
var COMP_MAX_ATTEMPTS = 3;
var NUGET_API_KEY = Argument ("nuget-api-key", EnvironmentVariable ("NUGET_API_KEY") ?? "");
var NUGET_SOURCE = Argument ("nuget-source", EnvironmentVariable ("NUGET_SOURCE") ?? "");
var NUGET_PUSH_SOURCE = Argument ("nuget-push-source", EnvironmentVariable ("NUGET_PUSH_SOURCE") ?? "");
var MYGET_API_KEY = Argument ("myget-api-key", EnvironmentVariable ("MYGET_API_KEY") ?? "");
var MYGET_SOURCE = Argument ("myget-source", EnvironmentVariable ("MYGET_SOURCE") ?? "");
var MYGET_PUSH_SOURCE = Argument ("myget-push-source", EnvironmentVariable ("MYGET_PUSH_SOURCE") ?? "");
var XAM_ACCT_EMAIL = Argument ("xamarin-account-email", EnvironmentVariable ("XAM_ACCT_EMAIL") ?? "");
var XAM_ACCT_PWD = Argument ("xamarin-account-password", EnvironmentVariable ("XAM_ACCT_PWD") ?? "");
var GLOB_PATTERNS = Argument ("glob-patterns", EnvironmentVariable ("GLOBBER_FILE_PATTERNS"));
Action<string[]> DumpGlobPatterns = (string[] globPatterns) => {
foreach (var gp in globPatterns) {
Information ("Matching: {0}", gp ?? "");
var files = GetFiles (gp);
if (files == null || !files.Any ())
continue;
foreach (var f in files)
Information ("Matched: {0}", f);
Information ("GLOBBER_FILE_PATTERNS={0}", string.Join (",", files));
}
};
Task ("MyGet").Does (() =>
{
var globPatterns = (GLOB_PATTERNS ?? "./output/*.nupkg").Split (new [] { ',', ';', ' ' });
DumpGlobPatterns (globPatterns);
if (PREVIEW_ONLY)
return;
var settings = new PublishNuGetsSettings {
MaxAttempts = MYGET_MAX_ATTEMPTS,
ForcePush = MYGET_FORCE_PUSH
};
PublishNuGets (MYGET_SOURCE, MYGET_PUSH_SOURCE, MYGET_API_KEY, settings, globPatterns);
});
Task ("NuGet").Does (() =>
{
var globPatterns = (GLOB_PATTERNS ?? "./output/*.nupkg").Split (new [] { ',', ';', ' ' });
DumpGlobPatterns (globPatterns);
if (PREVIEW_ONLY)
return;
var settings = new PublishNuGetsSettings {
MaxAttempts = NUGET_MAX_ATTEMPTS,
ForcePush = NUGET_FORCE_PUSH
};
PublishNuGets (NUGET_SOURCE, NUGET_PUSH_SOURCE, NUGET_API_KEY, settings, globPatterns);
});
Task ("Component").Does (() =>
{
var globPatterns = (GLOB_PATTERNS ?? "./output/*.xam").Split (new [] { ',', ';', ' ' });
DumpGlobPatterns (globPatterns);
if (PREVIEW_ONLY)
return;
var settings = new XamarinComponentUploadSettings {
Email = XAM_ACCT_EMAIL,
Password = XAM_ACCT_PWD,
MaxAttempts = COMP_MAX_ATTEMPTS,
};
UploadComponents (settings, globPatterns);
});
RunTarget (TARGET);