-
Notifications
You must be signed in to change notification settings - Fork 40
/
version.cake
38 lines (30 loc) · 1.51 KB
/
version.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
#addin nuget:?package=Cake.FileHelpers&version=2.0.0
#load "utility.cake"
using System.Text.RegularExpressions;
// Task TARGET for build
var Target = Argument("target", Argument("t", ""));
Task("StartNewVersion").Does(()=>
{
var newVersion = Argument<string>("NewVersion");
// Replace sdk version.
UpdateSDKVersion("Assets/AppCenter/Plugins/AppCenterSDK/Core/Shared/WrapperSdk.cs", "WrapperSdkVersion", newVersion);
UpdateSDKVersion("Assets/AppCenter/Plugins/AppCenterSDK/Analytics/Shared/Analytics.cs", "AnalyticsSDKVersion", newVersion);
UpdateSDKVersion("Assets/AppCenter/Plugins/AppCenterSDK/Crashes/Shared/Crashes.cs", "CrashesSDKVersion", newVersion);
UpdateSDKVersion("Assets/AppCenter/Plugins/AppCenterSDK/Distribute/Shared/Distribute.cs", "DistributeSDKVersion", newVersion);
// Replace versions in unitypackagespecs.
var specFiles = GetFiles("UnityPackageSpecs/*.unitypackagespec");
foreach (var spec in specFiles)
{
XmlPoke(spec.ToString(), "package/@version", newVersion);
}
// Increment app versions (they will use wrappersdkversion). The platform doesn't matter.
ExecuteUnityMethod("BuildPuppet.SetVersionNumber", "ios");
});
// Changes the Version field in file to the given version
void UpdateSDKVersion(string path, string patternPrefix, string newVersion)
{
var patternString = patternPrefix + " = \"[^\"]+\";";
var newString = patternPrefix + " = \"" + newVersion + "\";";
ReplaceRegexInFiles(path, patternString, newString);
}
RunTarget(Target);