Skip to content

Commit

Permalink
feature: add additional iOS archive method (#658)
Browse files Browse the repository at this point in the history
Added ICanArchiveiOS
Added IHaveEnableRestore
Added IsNotRunningOnAzurePipelines
Removed dependency on IHaveTestTarget from ICanPackXamariniOS
  • Loading branch information
RLittlesII authored Mar 17, 2022
1 parent e3d0f7b commit eaaeb7c
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 35 deletions.
61 changes: 44 additions & 17 deletions src/Nuke/Azp/AzurePipelinesTasks.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq.Expressions;
using Nuke.Common.CI.AzurePipelines;
using Serilog;
using static Nuke.Common.EnvironmentInfo;

#pragma warning disable CA1822
Expand All @@ -19,6 +20,12 @@ public class AzurePipelinesTasks
public static Expression<Func<bool>> IsRunningOnAzurePipelines => () =>
NukeBuild.Host is AzurePipelines || Environment.GetEnvironmentVariable("LOGNAME") == "vsts";

/// <summary>
/// Gets a value that determines if the build is not running on Azure DevOps.
/// </summary>
public static Expression<Func<bool>> IsNotRunningOnAzurePipelines => () =>
!( NukeBuild.Host is AzurePipelines || Environment.GetEnvironmentVariable("LOGNAME") == "vsts" );

/// <summary>
/// Print the azure pipelines environment
/// </summary>
Expand All @@ -27,25 +34,45 @@ public class AzurePipelinesTasks
.Executes(
() =>
{
Serilog.Log.Information("AGENT_ID: {AgentID}", GetVariable<string>("AGENT_ID"));
Serilog.Log.Information("AGENT_NAME: {AgentName}", GetVariable<string>("AGENT_NAME"));
Serilog.Log.Information("AGENT_VERSION: {AgentVersion}", GetVariable<string>(" "));
Serilog.Log.Information("AGENT_JOBNAME: {AgentJobName}", GetVariable<string>("AGENT_JOBNAME"));
Serilog.Log.Information("AGENT_JOBSTATUS: {AgentJobStatus}", GetVariable<string>("AGENT_JOBSTATUS"));
Serilog.Log.Information("AGENT_MACHINE_NAME: {AgentMachineName}", GetVariable<string>("AGENT_MACHINE_NAME"));
Serilog.Log.Information("\n");
Log.Information("AGENT_ID: {AgentID}", GetVariable<string>("AGENT_ID"));
Log.Information("AGENT_NAME: {AgentName}", GetVariable<string>("AGENT_NAME"));
Log.Information("AGENT_VERSION: {AgentVersion}", GetVariable<string>(" "));
Log.Information("AGENT_JOBNAME: {AgentJobName}", GetVariable<string>("AGENT_JOBNAME"));
Log.Information("AGENT_JOBSTATUS: {AgentJobStatus}", GetVariable<string>("AGENT_JOBSTATUS"));
Log.Information(
"AGENT_MACHINE_NAME: {AgentMachineName}", GetVariable<string>("AGENT_MACHINE_NAME")
);
Log.Information("\n");

Serilog.Log.Information("BUILD_BUILDID: {BuildBuildId}", GetVariable<string>("BUILD_BUILDID"));
Serilog.Log.Information("BUILD_BUILDNUMBER: {BuildBuildnumber}", GetVariable<string>("BUILD_BUILDNUMBER"));
Serilog.Log.Information("BUILD_DEFINITIONNAME: {BuildDefinitionName}", GetVariable<string>("BUILD_DEFINITIONNAME"));
Serilog.Log.Information("BUILD_DEFINITIONVERSION: {BuildDefinitionVersion}", GetVariable<string>("BUILD_DEFINITIONVERSION"));
Serilog.Log.Information("BUILD_QUEUEDBY: {BuildQueuedBy}", GetVariable<string>("BUILD_QUEUEDBY"));
Serilog.Log.Information("\n");
Log.Information("BUILD_BUILDID: {BuildBuildId}", GetVariable<string>("BUILD_BUILDID"));
Log.Information(
"BUILD_BUILDNUMBER: {BuildBuildnumber}", GetVariable<string>("BUILD_BUILDNUMBER")
);
Log.Information(
"BUILD_DEFINITIONNAME: {BuildDefinitionName}", GetVariable<string>("BUILD_DEFINITIONNAME")
);
Log.Information(
"BUILD_DEFINITIONVERSION: {BuildDefinitionVersion}",
GetVariable<string>("BUILD_DEFINITIONVERSION")
);
Log.Information("BUILD_QUEUEDBY: {BuildQueuedBy}", GetVariable<string>("BUILD_QUEUEDBY"));
Log.Information("\n");

Serilog.Log.Information("BUILD_SOURCEBRANCHNAME: {BuildSourceBranchName}", GetVariable<string>("BUILD_SOURCEBRANCHNAME"));
Serilog.Log.Information("BUILD_SOURCEVERSION: {BuildSourceVersion}", GetVariable<string>("BUILD_SOURCEVERSION"));
Serilog.Log.Information("BUILD_REPOSITORY_NAME: {BuildRepositoryName}", GetVariable<string>("BUILD_REPOSITORY_NAME"));
Serilog.Log.Information("BUILD_REPOSITORY_PROVIDER: {BuildRepositoryProvider}", GetVariable<string>("BUILD_REPOSITORY_PROVIDER"));
Log.Information(
"BUILD_SOURCEBRANCHNAME: {BuildSourceBranchName}",
GetVariable<string>("BUILD_SOURCEBRANCHNAME")
);
Log.Information(
"BUILD_SOURCEVERSION: {BuildSourceVersion}", GetVariable<string>("BUILD_SOURCEVERSION")
);
Log.Information(
"BUILD_REPOSITORY_NAME: {BuildRepositoryName}",
GetVariable<string>("BUILD_REPOSITORY_NAME")
);
Log.Information(
"BUILD_REPOSITORY_PROVIDER: {BuildRepositoryProvider}",
GetVariable<string>("BUILD_REPOSITORY_PROVIDER")
);
}
);

Expand Down
15 changes: 15 additions & 0 deletions src/Nuke/IHaveEnableRestore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Rocket.Surgery.Nuke;

/// <summary>
/// Defines a value whether to enable restore.
/// </summary>
public interface IHaveEnableRestore : IHave
{
/// <summary>
/// A value indicating whether to enable restoring for a given target
/// </summary>
[Parameter("A value indicating whether to enable restoring for a given target", Name = "EnableRestore")]
public bool EnableRestore => EnvironmentInfo.GetVariable<bool?>("EnableRestore")
?? TryGetValue<bool?>(() => EnableRestore)
?? false;
}
42 changes: 42 additions & 0 deletions src/Nuke/Xamarin/ios/ICanArchiveiOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

#pragma warning disable CA1304
// ReSharper disable InconsistentNaming
// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin
{
/// <summary>
/// archives a binary.
/// </summary>
public interface ICanArchiveiOS : IHavePackTarget,
IHaveConfiguration,
IHaveOutputLogs,
IHaveGitVersion,
IHaveSolution,
IHaveiOSTargetPlatform,
IHaveEnableRestore,
ICan
{
/// <summary>
/// packages a binary for distribution.
/// </summary>
public Target ArchiveIpa => _ => _.OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX)
.Executes(
() =>
MSBuild(
settings =>
settings.SetSolutionFile(Solution)
.SetRestore(EnableRestore)
.SetProperty("Platform", iOSTargetPlatform)
.SetProperty("BuildIpa", "true")
.SetProperty("ArchiveOnBuild", "true")
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "package.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.AssemblySemVer)
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}
}
37 changes: 19 additions & 18 deletions src/Nuke/Xamarin/ios/ICanPackXamariniOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

// ReSharper disable InconsistentNaming
Expand All @@ -9,8 +9,8 @@ namespace Rocket.Surgery.Nuke.Xamarin;
/// Xamarin iOS Pack
/// </summary>
public interface ICanPackXamariniOS : IHavePackTarget,
IHaveTestTarget,
IHaveConfiguration,
IHaveTestTarget,
IHaveOutputLogs,
IHaveGitVersion,
IHaveSolution,
Expand All @@ -20,20 +20,21 @@ public interface ICanPackXamariniOS : IHavePackTarget,
/// <summary>
/// packages a binary for distribution.
/// </summary>
public Target PackiPhone => _ => _
.DependsOn(Test)
.OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX)
.Executes(
() => MSBuild(
settings => settings.SetSolutionFile(Solution)
.SetProperty("Platform", iOSTargetPlatform)
.SetProperty("BuildIpa", "true")
.SetProperty("ArchiveOnBuild", "true")
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "package.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.AssemblySemVer)
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
public Target PackiPhone => _ => _.DependsOn(Test)
.OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX)
.Executes(
() =>
MSBuild(
settings =>
settings.SetSolutionFile(Solution)
.SetProperty("Platform", iOSTargetPlatform)
.SetProperty("BuildIpa", "true")
.SetProperty("ArchiveOnBuild", "true")
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "package.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.AssemblySemVer)
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}

0 comments on commit eaaeb7c

Please sign in to comment.