This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.cake
147 lines (113 loc) · 4.48 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
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
#tool nuget:?package=XamarinComponent
#addin nuget:?package=Cake.Xamarin
#addin nuget:?package=Cake.FileHelpers
var COMPONENT_VERSION = "5.2.0.0";
var NUGET_VERSION = "5.2.0";
var ANDROID_URL = "https://download.hockeyapp.net/sdk/android/HockeySDK-Android-5.2.0.zip";
var IOS_URL = "https://download.hockeyapp.net/sdk/ios/HockeySDK-iOS-5.1.2.zip";
var SAMPLES = new [] {
"./samples/HockeyAppSampleAndroid.sln",
"./samples/HockeyAppSampleiOS.sln",
"./samples/HockeyAppSampleiOSCrashOnly.sln",
"./samples/HockeyAppSampleForms.sln",
};
var TARGET = Argument ("target", Argument ("t", "all"));
Task ("libs")
.IsDependentOn ("externals")
.Does (() =>
{
NuGetRestore ("./HockeySDK.sln");
MSBuild ("./HockeySDK.sln", c => c.Configuration = "Release");
});
Task ("samples")
.IsDependentOn ("libs")
.Does (() =>
{
foreach (var s in SAMPLES) {
NuGetRestore (s);
MSBuild (s, c => c.Configuration = "Release");
}
});
Task("bindings-android").IsDependentOn("externals-android");
Task("bindings-ios").IsDependentOn("externals-ios");
Task ("externals-android")
.WithCriteria (!FileExists ("./externals/android/hockeyapp.android.zip"))
.Does (() =>
{
if (!DirectoryExists ("./externals/android"))
CreateDirectory ("./externals/android");
DownloadFile (ANDROID_URL, "./externals/android/hockeyapp.android.zip");
Unzip ("./externals/android/hockeyapp.android.zip", "./externals/android/");
var aar = GetFiles ("./externals/android/**/*.aar").FirstOrDefault ();
CopyFile (aar, "./externals/android/HockeySDK.aar");
var docs = GetDirectories ("./externals/android/HockeySDK-Android-*/docs").FirstOrDefault ();
CopyDirectory (docs, "./externals/android/docs");
});
Task ("externals-ios")
.ReportError(exception =>
{
Console.WriteLine(exception.ToString());
if(!(exception is Cake.Core.CakeException)) throw exception;
})
.WithCriteria (!FileExists ("./externals/ios/hockeyapp.ios.zip"))
.Does (() =>
{
if (!DirectoryExists ("./externals/ios"))
CreateDirectory ("./externals/ios");
DownloadFile (IOS_URL, "./externals/ios/hockeyapp.ios.zip");
Unzip ("./externals/ios/hockeyapp.ios.zip", "./externals/ios/");
CopyFile ("./externals/ios/HockeySDK-iOS/HockeySDKAllFeatures/HockeySDK.embeddedframework/HockeySDK.framework/HockeySDK", "./externals/ios/libHockeySDK.a");
CopyFile ("./externals/ios/HockeySDK-iOS/HockeySDKCrashOnly/HockeySDK.framework/HockeySDK", "./externals/ios/libHockeySDKCrashOnly.a");
CopyFile ("./externals/ios/HockeySDK-iOS/HockeySDKFeedbackOnly/HockeySDK.embeddedframework/HockeySDK.framework/HockeySDK", "./externals/ios/libHockeySDKFeedbackOnly.a");
CopyDirectory ("./externals/ios/HockeySDK-iOS/HockeySDKAllFeatures/HockeySDK.embeddedframework/HockeySDKResources.bundle", "./externals/ios/HockeySDKResources.bundle");
});
// Create a common externals task depending on platform specific ones
Task ("externals").IsDependentOn ("externals-ios").IsDependentOn ("externals-android");
// Create default nuget with all features.
Task ("nuget")
.IsDependentOn ("libs")
.Does (() =>
{
// NuGet on mac trims out the first ./ so adding it twice works around
var basePath = IsRunningOnUnix () ? (System.IO.Directory.GetCurrentDirectory().ToString() + @"/.") : "./";
NuGetPack ("./HockeySDK.nuspec", new NuGetPackSettings {
Version = NUGET_VERSION,
BasePath = basePath,
Verbosity = NuGetVerbosity.Detailed
});
NuGetPack("./HockeySDKFeedbackOnly.nuspec", new NuGetPackSettings {
Version = NUGET_VERSION,
BasePath = basePath,
Verbosity = NuGetVerbosity.Detailed
});
if (!DirectoryExists ("./output"))
CreateDirectory ("./output");
CopyFiles ("./HockeySDK*.nupkg", "./output");
});
Task ("components")
.IsDependentOn ("samples")
.Does (() =>
{
var yamls = GetFiles ("./**/component.template.yaml");
foreach (var yaml in yamls) {
var contents = FileReadText (yaml).Replace ("$version$", COMPONENT_VERSION);
var fixedFile = yaml.GetDirectory ().CombineWithFilePath ("component.yaml");
FileWriteText (fixedFile, contents);
PackageComponent (fixedFile.GetDirectory (), new XamarinComponentSettings ());
}
if (!DirectoryExists ("./output"))
CreateDirectory ("./output");
CopyFiles ("./component/**/*.xam", "./output");
});
Task ("all").IsDependentOn ("nuget").IsDependentOn ("components");
Task ("clean").Does (() =>
{
if (DirectoryExists ("./externals"))
CleanDirectory ("./externals");
if (DirectoryExists ("./output"))
CleanDirectory ("./output");
DeleteFiles("./*.nupkg");
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
});
RunTarget (TARGET);