diff --git a/Xamarin.Recipe/Content/addins.cake b/Xamarin.Recipe/Content/addins.cake new file mode 100644 index 0000000..8a0f57b --- /dev/null +++ b/Xamarin.Recipe/Content/addins.cake @@ -0,0 +1,9 @@ +/////////////////////////////////////////////////////////////////////////////// +// ADDINS +/////////////////////////////////////////////////////////////////////////////// + +#addin nuget:?package=Cake.AndroidAppManifest&version=1.1.0 +#addin nuget:?package=Cake.AppCenter&version=1.1.0 +#addin nuget:?package=Cake.Fastlane&version=0.4.1 +#addin nuget:?package=Cake.Figlet&version=1.0.0 +#addin nuget:?package=Cake.Plist&version=0.4.0 \ No newline at end of file diff --git a/Xamarin.Recipe/Content/android.cake b/Xamarin.Recipe/Content/android.cake index 0e49de9..7b6dd0b 100644 --- a/Xamarin.Recipe/Content/android.cake +++ b/Xamarin.Recipe/Content/android.cake @@ -1,5 +1,3 @@ -#addin nuget:?package=Cake.AndroidAppManifest&version=1.1.0 - BuildParameters.Tasks.AndroidArchiveTask = Task("Android-Archive") .IsDependentOn("Android-Build") .IsDependentOn("Copy-Apk"); diff --git a/Xamarin.Recipe/Content/appcenter.cake b/Xamarin.Recipe/Content/appcenter.cake index c6e32d9..364102d 100644 --- a/Xamarin.Recipe/Content/appcenter.cake +++ b/Xamarin.Recipe/Content/appcenter.cake @@ -1,5 +1,3 @@ -#addin nuget:?package=Cake.AppCenter&version=1.1.0 - BuildParameters.Tasks.AppCenterTask = Task("AppCenter") .WithCriteria(() => BuildParameters.ShouldDeployAppCenter); diff --git a/Xamarin.Recipe/Content/azuredevops.cake b/Xamarin.Recipe/Content/azuredevops.cake index 26d693c..9584f75 100644 --- a/Xamarin.Recipe/Content/azuredevops.cake +++ b/Xamarin.Recipe/Content/azuredevops.cake @@ -74,7 +74,7 @@ BuildParameters.Tasks.PublishAzureDevOpsTestResultsTask = Task("Publish-AzureDev Configuration = BuildParameters.Configuration, TestRunTitle = "Unit Tests", TestRunner = TFTestRunnerType.XUnit, - TestResultsFiles = new string[] { BuildParameters.Paths.Files.TestResultsFilePath.ToString() } + TestResultsFiles = new [] { BuildParameters.Paths.Files.TestResultsFilePath } }; BuildSystem.TFBuild.Commands.PublishTestResults(testResultsData); @@ -83,6 +83,7 @@ BuildParameters.Tasks.PublishAzureDevOpsTestResultsTask = Task("Publish-AzureDev BuildParameters.Tasks.PublishAzureDevOpsCodeCoverageTask = Task("Publish-AzureDevOps-Code-Coverage") .WithCriteria(() => BuildParameters.IsRunningOnAzureDevOps) + .WithCriteria(() => ToolSettings.AzureDevOpsPublishCodeCoverageData != null) .IsDependentOn("Publish-AzureDevOps-Test-Results") .Does(() => { diff --git a/Xamarin.Recipe/Content/build.cake b/Xamarin.Recipe/Content/build.cake index ddc9763..cb0dd2a 100644 --- a/Xamarin.Recipe/Content/build.cake +++ b/Xamarin.Recipe/Content/build.cake @@ -7,7 +7,9 @@ /////////////////////////////////////////////////////////////////////////////// Setup(context => -{ +{ + Information(Figlet(BuildParameters.Title)); + // Executed BEFORE the first task. Information("Running tasks..."); diff --git a/Xamarin.Recipe/Content/fastlane.cake b/Xamarin.Recipe/Content/fastlane.cake index c22ee13..60a3f16 100644 --- a/Xamarin.Recipe/Content/fastlane.cake +++ b/Xamarin.Recipe/Content/fastlane.cake @@ -1,5 +1,3 @@ -#addin nuget:?package=Cake.Fastlane&version=0.4.1 - BuildParameters.Tasks.FastlaneTask = Task("Fastlane"); BuildParameters.Tasks.FastlaneDeliverTask = diff --git a/Xamarin.Recipe/Content/ios.cake b/Xamarin.Recipe/Content/ios.cake index 50d6979..43acf6f 100644 --- a/Xamarin.Recipe/Content/ios.cake +++ b/Xamarin.Recipe/Content/ios.cake @@ -1,5 +1,3 @@ -#addin nuget:?package=Cake.Plist&version=0.4.0 - BuildParameters.Tasks.iOSArchiveTask = Task("iOS-Archive") .WithCriteria(() => BuildParameters.IsRunningOnUnix) .IsDependentOn("iPhone-Build") diff --git a/Xamarin.Recipe/Content/parameters.cake b/Xamarin.Recipe/Content/parameters.cake index c950258..e5ec26a 100644 --- a/Xamarin.Recipe/Content/parameters.cake +++ b/Xamarin.Recipe/Content/parameters.cake @@ -21,19 +21,20 @@ public static class BuildParameters public static bool IsTagged { get; private set; } public static bool IsPublishBuild { get; private set; } public static bool IsReleaseBuild { get; private set; } - public static bool ShouldRunGitVersion { get; private set; } - public static string AppCenterApiKey { get; private set; } public static bool IsDotNetCoreBuild { get; set; } public static bool IsiOSBuild { get; set; } public static bool IsAndroidBuild { get; set; } public static bool IsNuGetBuild { get; set; } public static bool TransifexEnabled { get; set; } public static bool PrepareLocalRelease { get; set; } + + public static bool ShouldRunGitVersion { get; private set; } public static bool ShouldDeployAppCenter { get; private set; } public static bool ShouldRunFastlaneDeliver { get; private set; } public static bool ShouldRunFastlaneMatch { get; private set; } public static bool ShouldCopyImages { get; private set; } public static bool ShouldRunxUnit { get; private set; } + public static BuildVersion Version { get; private set; } public static BuildPaths Paths { get; private set; } public static BuildTasks Tasks { get; set; } @@ -45,6 +46,7 @@ public static class BuildParameters public static FilePath AndroidManifest { get; private set; } public static FilePath IOSProjectPath { get; private set; } public static FilePath PlistFilePath { get; private set; } + public static string AppCenterApiKey { get; private set; } public static string Platform { get; private set; } public static DirectoryPath TestDirectoryPath { get; private set; } public static FilePath IntegrationTestScriptPath { get; private set; } @@ -151,7 +153,12 @@ public static class BuildParameters SetBuildPaths(BuildPaths.GetPaths(context)); - ShouldDeployAppCenter = ((!IsLocalBuild && !IsPullRequest && (IsMainBranch || IsReleaseBranch || IsDevBranch || IsHotFixBranch || IsTagged)) || shouldDeployAppCenter); + ShouldDeployAppCenter = (((!IsLocalBuild && !IsPullRequest && (IsMainBranch || IsReleaseBranch || IsDevBranch || IsHotFixBranch || IsTagged)) && + ((context.EnvironmentVariable(Environment.AppCenterTokenVariable) != null) && + (context.EnvironmentVariable(Environment.AppCenterAppNameVariable) != null) && + (context.EnvironmentVariable(Environment.AppCenterGroupVariable) != null) && + (context.EnvironmentVariable(Environment.AppCenterOwnerVariable) != null))) || + shouldDeployAppCenter); ShouldRunxUnit = shouldRunxUnit ?? !IsDotNetCoreBuild; @@ -199,6 +206,9 @@ public static class BuildParameters context.Information("IOSProjectPath: {0}", IOSProjectPath); context.Information("\n"); + context.Information("ShouldDeployAppCenter: {0}", ShouldDeployAppCenter); + context.Information("\n"); + context.Information("ShouldRunFastlaneMatch: {0}", ShouldRunFastlaneMatch); context.Information("ShouldRunFastlaneDeliver: {0}", ShouldRunFastlaneDeliver); context.Information("\n"); diff --git a/Xamarin.Recipe/Content/toolsettings.cake b/Xamarin.Recipe/Content/toolsettings.cake index 0bfaede..5f5e04e 100644 --- a/Xamarin.Recipe/Content/toolsettings.cake +++ b/Xamarin.Recipe/Content/toolsettings.cake @@ -44,7 +44,7 @@ public static class ToolSettings Func xUnitSettings = null, Action fastlaneDeliverConfigurator = null, Action fastlaneMatchConfigurator = null, - Action azureDevOpsPublishCodeCoverageData = null + Action azureDevOpsPublishCodeCoverageData = default(Action) ) { context.Information("Setting up tools..."); @@ -76,7 +76,7 @@ public static class ToolSettings XUnitSettings = xUnitSettings ?? _xUnitSettings; FastlaneDeliverConfigurator = fastlaneDeliverConfigurator ?? _defaultDeliverConfiguration; FastlaneMatchConfigurator = fastlaneMatchConfigurator ?? _defaultMatchConfiguration; - AzureDevOpsPublishCodeCoverageData = azureDevOpsPublishCodeCoverageData ?? _defaultPublishCodeCoverageData; + AzureDevOpsPublishCodeCoverageData = azureDevOpsPublishCodeCoverageData; } private static Func _defaultDotNetTestSettings = () => new DotNetCoreTestSettings @@ -97,8 +97,6 @@ public static class ToolSettings NoAppDomain = true }; - private static Action _defaultPublishCodeCoverageData = data => { data = new TFBuildPublishCodeCoverageData(); }; - private static Action _defaultDeliverConfiguration = cfg => { cfg = new FastlaneDeliverConfiguration(); }; private static Action _defaultMatchConfiguration = cfg => { cfg = new FastlaneMatchConfiguration(); };