From 5d9a0f113a16a4fc4f1463bf66a6e1cdc43ea40e Mon Sep 17 00:00:00 2001 From: RLittlesII Date: Thu, 14 Feb 2019 21:32:36 -0600 Subject: [PATCH 1/4] (build) Adding Azure Pipelines --- Xamarin.Recipe/Content/version.cake | 4 ++-- azure-pipelines.yml | 26 ++++++++++++++++++++++++++ build.ps1 | 4 ++-- recipe.cake | 16 +++++++++++++++- 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 azure-pipelines.yml diff --git a/Xamarin.Recipe/Content/version.cake b/Xamarin.Recipe/Content/version.cake index a44abfa..9d6489f 100644 --- a/Xamarin.Recipe/Content/version.cake +++ b/Xamarin.Recipe/Content/version.cake @@ -1,6 +1,6 @@ public class BuildMetaData { - public static string Date { get; } = "2018-12-12 02:36:45"; - public static string Version { get; } = "0.3.0-cake-recipe0038"; + public static string Date { get; } = "2019-02-15 04:45:40"; + public static string Version { get; } = "0.4.0-pipelines0004"; } \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..72e16f1 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,26 @@ +trigger: + branches: + include: + - dev + - main + - feature/* + - release/* + - hotfix/* +pr: + autoCancel: true + branches: + include: + - dev + +pool: + vmImage: 'vs2017-win2016' + +steps: +- task: DotNetCoreInstaller@0 + displayName: 'dotnet install' + inputs: + packageType: 'sdk' # Options: runtime, sdk + version: '2.2.100' + +- powershell: '.\build.ps1 -t AzureDevOps' + displayName: 'cake build' \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 65f6f35..19413d4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -31,9 +31,9 @@ Param( [string[]]$ScriptArgs ) -$CakeVersion = "0.29.0" +$CakeVersion = "0.32.1" $DotNetChannel = "preview"; -$DotNetVersion = "2.1.101"; +$DotNetVersion = "2.2.100"; $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; $NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" diff --git a/recipe.cake b/recipe.cake index 68bf66a..d4e8389 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:https://ci.appveyor.com/nuget/cake-recipe?package=Cake.Recipe&version=0.3.0-unstable0441 +#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&prerelease Environment.SetVariableNames(); @@ -41,4 +41,18 @@ Task("Generate-Version-File") ); }); +Task("UploadAzureDevOpsArtifacts") + .WithCriteria(() => TFBuild.IsRunningOnVSTS) + .Does(() => + { + BuildSystem + .TFBuild + .Commands + .UploadArtifactDirectory(BuildParameters.Paths.Directories.NuGetPackages.MakeAbsolute(Context.Environment).FullPath, "Packages"); + }); + +Task("AzureDevOps") + .IsDependentOn("Publish-MyGet-Packages") + .IsDependentOn("UploadAzureDevOpsArtifacts"); + Build.RunNuGet(); \ No newline at end of file From e75098c6076bf5e1173375d03a1aa657ccd07095 Mon Sep 17 00:00:00 2001 From: RLittlesII Date: Thu, 14 Feb 2019 23:14:12 -0600 Subject: [PATCH 2/4] (housekeeping) Added Azure Pipelines badges to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ed4fd6..b881e35 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ Xamarin.Recipe is a set of convention based scripts for building and deploying X |dev|main| |:--:|:--:| -[![Build status](https://ci.appveyor.com/api/projects/status/mbn32rx9rc874dqm/branch/dev?svg=true)](https://ci.appveyor.com/project/RocketSurgeonsGuild/xamarin-recipe/branch/dev)|[![Build status](https://ci.appveyor.com/api/projects/status/mbn32rx9rc874dqm/branch/main?svg=true)](https://ci.appveyor.com/project/RocketSurgeonsGuild/xamarin-recipe/branch/main)| \ No newline at end of file +[![Build status](https://ci.appveyor.com/api/projects/status/mbn32rx9rc874dqm/branch/dev?svg=true)](https://ci.appveyor.com/project/RocketSurgeonsGuild/xamarin-recipe/branch/dev)|[![Build status](https://ci.appveyor.com/api/projects/status/mbn32rx9rc874dqm/branch/main?svg=true)](https://ci.appveyor.com/project/RocketSurgeonsGuild/xamarin-recipe/branch/main)| +[![Build Status](https://dev.azure.com/rocketsurgeonsguild/Libraries/_apis/build/status/RSG.Xamarin.Recipe?branchName=dev)](https://dev.azure.com/rocketsurgeonsguild/Libraries/_build/latest?definitionId=25&branchName=dev)|[![Build Status](https://dev.azure.com/rocketsurgeonsguild/Libraries/_apis/build/status/RSG.Xamarin.Recipe?branchName=main)](https://dev.azure.com/rocketsurgeonsguild/Libraries/_build/latest?definitionId=25&branchName=main) \ No newline at end of file From a418d18d0e62cb23ca9941b57e819999c0ca8249 Mon Sep 17 00:00:00 2001 From: RLittlesII Date: Sat, 16 Feb 2019 00:11:40 -0600 Subject: [PATCH 3/4] (GH-35) Added ShouldRunUnitTests Parameter --- Xamarin.Recipe/Content/build.cake | 2 +- Xamarin.Recipe/Content/parameters.cake | 4 ++++ Xamarin.Recipe/Content/test.cake | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Xamarin.Recipe/Content/build.cake b/Xamarin.Recipe/Content/build.cake index cb0dd2a..caaaaac 100644 --- a/Xamarin.Recipe/Content/build.cake +++ b/Xamarin.Recipe/Content/build.cake @@ -188,7 +188,7 @@ public class Builder private static void Setup() { - if(!BuildParameters.IsDotNetCoreBuild) + if(BuildParameters.ShouldRunxUnit) { BuildParameters.Tasks.TestTask.IsDependentOn("xUnit-Tests"); } diff --git a/Xamarin.Recipe/Content/parameters.cake b/Xamarin.Recipe/Content/parameters.cake index e5ec26a..e68cf2e 100644 --- a/Xamarin.Recipe/Content/parameters.cake +++ b/Xamarin.Recipe/Content/parameters.cake @@ -34,6 +34,7 @@ public static class BuildParameters public static bool ShouldRunFastlaneMatch { get; private set; } public static bool ShouldCopyImages { get; private set; } public static bool ShouldRunxUnit { get; private set; } + public static bool ShouldRunUnitTests { get; private set; } public static BuildVersion Version { get; private set; } public static BuildPaths Paths { get; private set; } @@ -91,6 +92,7 @@ public static class BuildParameters bool shouldDeployAppCenter = false, bool shouldCopyImages = false, bool? shouldRunxUnit = null, + bool? shouldRunUnitTests = null, bool shouldRunFastlaneMatch = false, string mainBranch = "main", string devBranch = "dev", @@ -162,6 +164,8 @@ public static class BuildParameters ShouldRunxUnit = shouldRunxUnit ?? !IsDotNetCoreBuild; + ShouldRunUnitTests = shouldRunUnitTests ?? context.GetFiles(UnitTestFilePattern).All(x => x != null); + ShouldRunFastlaneDeliver = context.DirectoryExists(BuildParameters.Paths.Directories.Metadata) && (IsReleaseBranch || IsHotFixBranch || (IsMainBranch && IsTagged)); ShouldRunFastlaneMatch = IsiOSBuild && IsRunningOnUnix && shouldRunFastlaneMatch; diff --git a/Xamarin.Recipe/Content/test.cake b/Xamarin.Recipe/Content/test.cake index a7845a0..391ad52 100644 --- a/Xamarin.Recipe/Content/test.cake +++ b/Xamarin.Recipe/Content/test.cake @@ -1,4 +1,5 @@ Task("Unit-Test") + .WithCriteria(() => BuildParameters.ShouldRunUnitTests) .Does(() => { Verbose("Executing Unit Tests"); From b2e12e39ce66420ee56c2c7945764ab9cec3cb3b Mon Sep 17 00:00:00 2001 From: RLittlesII Date: Sat, 16 Feb 2019 01:05:08 -0600 Subject: [PATCH 4/4] (GH-31) Added BuildNumber to BuildParameters --- Xamarin.Recipe/Content/android.cake | 4 ++-- Xamarin.Recipe/Content/ios.cake | 2 +- Xamarin.Recipe/Content/parameters.cake | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Xamarin.Recipe/Content/android.cake b/Xamarin.Recipe/Content/android.cake index 7b6dd0b..7362a03 100644 --- a/Xamarin.Recipe/Content/android.cake +++ b/Xamarin.Recipe/Content/android.cake @@ -57,7 +57,7 @@ Task("Android-Manifest") var manifest = DeserializeAppManifest(BuildParameters.AndroidManifest); manifest.VersionName = BuildParameters.Version.Version; - manifest.VersionCode = Convert.ToInt32(BuildParameters.Version.BuildMetaData); + manifest.VersionCode = BuildParameters.BuildNumber == 0 ? manifest.VersionCode ++ : BuildParameters.BuildNumber; Verbose("Version Name: {0}", BuildParameters.Version.Version); Verbose("Version Code: {0}", BuildParameters.Version.PreReleaseNumber); @@ -125,4 +125,4 @@ Task("Upload-AzureDevOps-Apk") Verbose("Apk Path: {0}", apk.FullPath); BuildSystem.TFBuild.Commands.UploadArtifact(artifactPath.ToString(), apk, apk.GetFilename().ToString()); - }); \ No newline at end of file + }); diff --git a/Xamarin.Recipe/Content/ios.cake b/Xamarin.Recipe/Content/ios.cake index 43acf6f..7823667 100644 --- a/Xamarin.Recipe/Content/ios.cake +++ b/Xamarin.Recipe/Content/ios.cake @@ -43,7 +43,7 @@ Task("iPhone-Info-Plist") Verbose("CFBundleShortVersionString: {0}", BuildParameters.Version.Version); Verbose("CFBundleVersion: {0}", BuildParameters.Version.PreReleaseNumber); plist["CFBundleShortVersionString"] = BuildParameters.Version.Version; - plist["CFBundleVersion"] = BuildParameters.Version.BuildMetaData; + plist["CFBundleVersion"] = BuildParameters.BuildNumber == 0 ? BuildParameters.Version.BuildMetaData : BuildParameters.BuildNumber.ToString(); var bundleIdentifier = EnvironmentVariable(Environment.BundleIdentifierVariable); if(!string.IsNullOrEmpty(bundleIdentifier)) diff --git a/Xamarin.Recipe/Content/parameters.cake b/Xamarin.Recipe/Content/parameters.cake index e68cf2e..deb7ebf 100644 --- a/Xamarin.Recipe/Content/parameters.cake +++ b/Xamarin.Recipe/Content/parameters.cake @@ -27,6 +27,8 @@ public static class BuildParameters public static bool IsNuGetBuild { get; set; } public static bool TransifexEnabled { get; set; } public static bool PrepareLocalRelease { get; set; } + + public static int BuildNumber { get; private set; } public static bool ShouldRunGitVersion { get; private set; } public static bool ShouldDeployAppCenter { get; private set; } @@ -94,6 +96,7 @@ public static class BuildParameters bool? shouldRunxUnit = null, bool? shouldRunUnitTests = null, bool shouldRunFastlaneMatch = false, + int buildNumber = 0, string mainBranch = "main", string devBranch = "dev", FilePath androidManifest = null, @@ -169,6 +172,8 @@ public static class BuildParameters ShouldRunFastlaneDeliver = context.DirectoryExists(BuildParameters.Paths.Directories.Metadata) && (IsReleaseBranch || IsHotFixBranch || (IsMainBranch && IsTagged)); ShouldRunFastlaneMatch = IsiOSBuild && IsRunningOnUnix && shouldRunFastlaneMatch; + + BuildNumber = buildNumber; } public static void SetBuildVersion(BuildVersion version)