Skip to content

Commit

Permalink
Merge branch 'release/5.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Mar 20, 2021
2 parents 7c78116 + 8a70a58 commit 5da5116
Show file tree
Hide file tree
Showing 29 changed files with 780 additions and 91 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/cake-buildscripts-dependabot.yml

This file was deleted.

3 changes: 2 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ Parameters["Company"] = "Fody";
Parameters["RepositoryUrl"] = string.Format("https://github.com/{0}/{1}", GetBuildServerVariable("SolutionName"), GetBuildServerVariable("SolutionName"));
Parameters["StartYear"] = "2015";
Parameters["UseVisualStudioPrerelease"] = "false";
Parameters["DeployCostura"] = "false";
Parameters["SkipComponentsThatAreNotDeployable"] = "false";
Parameters["BuildCostura"] = "true";
Parameters["DeployCostura"] = "false";

// Note: the rest of the variables should be coming from the build server,
// see `/deployment/cake/*-variables.cake` for customization options
Expand Down
9 changes: 9 additions & 0 deletions deployment/cake/apps-wpf-tasks.cake
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ public class WpfProcessor : ProcessorBase

BuildContext.CakeContext.LogSeparator($"Deploying WPF app '{wpfApp}'");

// TODO: Respect the deploy settings per category, requires changes to AzureStorageSync
if (!BuildContext.Wpf.DeployUpdatesToAlphaChannel ||
!BuildContext.Wpf.DeployUpdatesToBetaChannel ||
!BuildContext.Wpf.DeployUpdatesToStableChannel ||
!BuildContext.Wpf.DeployInstallers)
{
throw new Exception("Not deploying a specific channel is not yet supported, please implement");
}

//%DeploymentsShare%\%ProjectName% /%ProjectName% -c %AzureDeploymentsStorageConnectionString%
var deploymentShare = BuildContext.Wpf.GetDeploymentShareForProject(wpfApp);
var projectSlug = GetProjectSlug(wpfApp, "-");
Expand Down
22 changes: 21 additions & 1 deletion deployment/cake/apps-wpf-variables.cake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public class WpfContext : BuildContextWithItemsBase
public bool UpdateDeploymentsShare { get; set; }
public string AzureDeploymentsStorageConnectionString { get; set; }

public bool GenerateDeploymentCatalog { get; set; }
public bool GroupUpdatesByMajorVersion { get; set; }
public bool DeployUpdatesToAlphaChannel { get; set; }
public bool DeployUpdatesToBetaChannel { get; set; }
public bool DeployUpdatesToStableChannel { get; set; }
public bool DeployInstallers { get; set; }

protected override void ValidateContext()
{

Expand All @@ -24,6 +31,13 @@ public class WpfContext : BuildContextWithItemsBase
protected override void LogStateInfoForContext()
{
CakeContext.Information($"Found '{Items.Count}' wpf projects");

CakeContext.Information($"Generate Deployment Catalog: '{GenerateDeploymentCatalog}'");
CakeContext.Information($"Group updates by major version: '{GroupUpdatesByMajorVersion}'");
CakeContext.Information($"Deploy updates to alpha channel: '{DeployUpdatesToAlphaChannel}'");
CakeContext.Information($"Deploy updates to beta channel: '{DeployUpdatesToBetaChannel}'");
CakeContext.Information($"Deploy updates to stable channel: '{DeployUpdatesToStableChannel}'");
CakeContext.Information($"Deploy installers: '{DeployInstallers}'");
}

public string GetDeploymentShareForProject(string projectName)
Expand All @@ -46,7 +60,13 @@ private WpfContext InitializeWpfContext(BuildContext buildContext, IBuildContext
Channel = buildContext.BuildServer.GetVariable("Channel", showValue: true),
AppendDeploymentChannelSuffix = buildContext.BuildServer.GetVariableAsBool("AppendDeploymentChannelSuffix", false, showValue: true),
UpdateDeploymentsShare = buildContext.BuildServer.GetVariableAsBool("UpdateDeploymentsShare", true, showValue: true),
AzureDeploymentsStorageConnectionString = buildContext.BuildServer.GetVariable("AzureDeploymentsStorageConnectionString")
AzureDeploymentsStorageConnectionString = buildContext.BuildServer.GetVariable("AzureDeploymentsStorageConnectionString"),
GenerateDeploymentCatalog = buildContext.BuildServer.GetVariableAsBool("WpfGenerateDeploymentCatalog", true, showValue: true),
GroupUpdatesByMajorVersion = buildContext.BuildServer.GetVariableAsBool("WpfGroupUpdatesByMajorVersion", false, showValue: true),
DeployUpdatesToAlphaChannel = buildContext.BuildServer.GetVariableAsBool("WpfDeployUpdatesToAlphaChannel", true, showValue: true),
DeployUpdatesToBetaChannel = buildContext.BuildServer.GetVariableAsBool("WpfDeployUpdatesToBetaChannel", true, showValue: true),
DeployUpdatesToStableChannel = buildContext.BuildServer.GetVariableAsBool("WpfDeployUpdatesToStableChannel", true, showValue: true),
DeployInstallers = buildContext.BuildServer.GetVariableAsBool("WpfDeployInstallers", true, showValue: true),
};

if (string.IsNullOrWhiteSpace(data.Channel))
Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/docker-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#l "docker-variables.cake"
#l "lib-octopusdeploy.cake"

#addin "nuget:?package=Cake.Docker&version=0.11.1"
#addin "nuget:?package=Cake.Docker&version=1.0.0"

//-------------------------------------------------------------

Expand Down
27 changes: 27 additions & 0 deletions deployment/cake/generic-variables.cake
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,33 @@ public class VersionContext : BuildContextBase
}

public bool ClearCache { get; set; }

private string _major;

public string Major
{
get
{
if (string.IsNullOrWhiteSpace(_major))
{
_major = string.Empty;

for (int i = 0; i < MajorMinorPatch.Length; i++)
{
var character = MajorMinorPatch[i];
if (!char.IsDigit(character))
{
break;
}

_major += character.ToString();
}
}

return _major;
}
}

public string MajorMinorPatch { get; set; }
public string FullSemVer { get; set; }
public string NuGet { get; set; }
Expand Down
122 changes: 122 additions & 0 deletions deployment/cake/installers-innosetup.cake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class InnoSetupInstaller : IInstaller

public bool IsAvailable { get; private set; }

//-------------------------------------------------------------

public async Task PackageAsync(string projectName, string channel)
{
if (!IsAvailable)
Expand Down Expand Up @@ -100,4 +102,124 @@ public class InnoSetupInstaller : IInstaller
BuildContext.CakeContext.CopyFile(installerSourceFile, System.IO.Path.Combine(installersOnDeploymentsShare, $"{projectName}{setupSuffix}.exe"));
}
}

//-------------------------------------------------------------

public async Task<DeploymentTarget> GenerateDeploymentTargetAsync(string projectName)
{
var deploymentTarget = new DeploymentTarget
{
Name = "Inno Setup"
};

var channels = new []
{
"alpha",
"beta",
"stable"
};

var deploymentGroupNames = new List<string>();
var projectDeploymentShare = BuildContext.Wpf.GetDeploymentShareForProject(projectName);

// Just a single group
deploymentGroupNames.Add("all");

foreach (var deploymentGroupName in deploymentGroupNames)
{
BuildContext.CakeContext.Information($"Searching for releases for deployment group '{deploymentGroupName}'");

var deploymentGroup = new DeploymentGroup
{
Name = deploymentGroupName
};

foreach (var channel in channels)
{
BuildContext.CakeContext.Information($"Searching for releases for deployment channel '{deploymentGroupName}/{channel}'");

var deploymentChannel = new DeploymentChannel
{
Name = channel
};

var targetDirectory = GetDeploymentsShareRootDirectory(projectName, channel);

BuildContext.CakeContext.Information($"Searching for release files in '{targetDirectory}'");

var filter = $"{projectName}_*{channel}*.exe";
if (channel == "stable")
{
filter = $"{projectName}_*.exe";
}

var installationFiles = System.IO.Directory.GetFiles(targetDirectory, filter);

foreach (var installationFile in installationFiles)
{
var releaseFileInfo = new System.IO.FileInfo(installationFile);
var relativeFileName = new DirectoryPath(projectDeploymentShare).GetRelativePath(new FilePath(releaseFileInfo.FullName)).FullPath.Replace("\\", "/");

var releaseVersion = releaseFileInfo.Name
.Replace($"{projectName}", string.Empty)
.Replace($".exe", string.Empty)
.Trim('_');

// Either empty or matching a release channel should be ignored
if (string.IsNullOrWhiteSpace(releaseVersion) ||
channels.Any(x => x == releaseVersion))
{
BuildContext.CakeContext.Information($"Ignoring '{installationFile}'");
continue;
}

// Special case for stable releases
if (channel == "stable")
{
if (releaseVersion.Contains("-alpha") ||
releaseVersion.Contains("-beta"))
{
BuildContext.CakeContext.Information($"Ignoring '{installationFile}'");
continue;
}
}

BuildContext.CakeContext.Information($"Applying release based on '{installationFile}'");

var release = new DeploymentRelease
{
Name = releaseVersion,
Timestamp = releaseFileInfo.CreationTimeUtc
};

// Full release
release.Full = new DeploymentReleasePart
{
RelativeFileName = relativeFileName,
Size = (ulong)releaseFileInfo.Length
};

deploymentChannel.Releases.Add(release);
}

deploymentGroup.Channels.Add(deploymentChannel);
}

deploymentTarget.Groups.Add(deploymentGroup);
}

return deploymentTarget;
}

//-------------------------------------------------------------

private string GetDeploymentsShareRootDirectory(string projectName, string channel)
{
var deploymentShare = BuildContext.Wpf.GetDeploymentShareForProject(projectName);

var installersOnDeploymentsShare = System.IO.Path.Combine(deploymentShare, "installer");
BuildContext.CakeContext.CreateDirectory(installersOnDeploymentsShare);

return installersOnDeploymentsShare;
}
}
Loading

0 comments on commit 5da5116

Please sign in to comment.