-
Notifications
You must be signed in to change notification settings - Fork 43
/
build.cake
110 lines (97 loc) · 3.07 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
#load "cake/functions.cake"
#load "cake/objects.cake"
#addin "Cake.FileHelpers"
// https://download-cdn.getsync.com/stable/linux-x64/resilio-sync_x64.tar.gz
// --target Clean
var target = Argument<string>("target", "Default");
// --packages btsync-common,btsync-core,btsync-gui,btsync-user,btsync
var packageArgs = Argument<string>("packages", "btsync-core,btsync").Split(',');
var availablePackageProfiles = new List<PackageProfile>()
{
new PackageProfile {
Name = "btsync-common",
Arches = "i386 amd64 armel armhf powerpc".Split()
},
new PackageProfile {
Name = "btsync-core",
Arches = "i386 amd64 armel armhf arm64".Split()
},
new PackageProfile {
Name = "btsync-gui",
Arches = "all".Split()
},
new PackageProfile {
Name = "btsync-user",
Arches = "all".Split()
},
new PackageProfile {
Name = "btsync",
Arches = "all".Split()
}
};
var packageProfiles = availablePackageProfiles
.Where(x => packageArgs.Contains(x.Name))
.ToList();
const string syncChangeLog = "http://help.getsync.com/hc/en-us/articles/206216855-Sync-2-x-change-log";
const string historyPath = "btsync-core/debian/history/changelog";
const string changelogFile = "btsync-core/debian/changelog";
Task("Update-Changelog")
.Does(() =>
{
var lastVersion = GetLastVersion(syncChangeLog);
Information(string.Format("Last detected version {0}.", lastVersion.Version));
var currentHistory = FileReadText(historyPath);
if(!currentHistory.Split('\n').Any(x => x.StartsWith(lastVersion.Version)))
{
Information("Updating history file.");
currentHistory = CreateHistoryChangelog(lastVersion) + currentHistory;
FileWriteText(historyPath, currentHistory);
}
else
{
Information("History file is already up-to-date.");
}
var currentChangelog = FileReadText(changelogFile);
if(!currentChangelog.Contains("(" + lastVersion.Version))
{
Information("Updating changelog file.");
currentChangelog = CreateChangelog(lastVersion) + currentChangelog;
FileWriteText(changelogFile, currentChangelog);
}
else
{
Information("Changelog file is already up-to-date.");
}
});
Task("Clean")
.Does(() =>
{
foreach(var package in packageProfiles)
{
Information(string.Format("Cleaning workspace of {0}.", package.Name));
CleanDebianWorkspace(package.Name, package.Arches);
}
});
Task("Build-Src")
.IsDependentOn("Clean")
.Does(() =>
{
foreach(var package in packageProfiles)
{
Information(string.Format("Building source of {0}.", package.Name));
BuildDebianSrc(package.Name);
}
});
Task("Build-Deb")
.IsDependentOn("Build-Src")
.Does(() =>
{
foreach(var package in packageProfiles)
{
Information(string.Format("Building Debian package for {0}.", package.Name));
BuildDebianPackage(package.Name, package.Arches);
}
});
Task("Default")
.IsDependentOn("Update-Changelog");
RunTarget(target);