Skip to content

Commit

Permalink
Merge #4188 Add Prepare-SignPath target to build script
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 21, 2024
2 parents c2b8464 + 040b8be commit 982bc5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Build nuget package, support netstandard2.0 build (#4039 by: HebaruSan)
- [Core] Use fully sanitized archive.org bucket names (#4043 by: HebaruSan)
- [Netkan] Omit duplicate inflation warnings in queue (#4071 by: HebaruSan)
- [Build] Refactor + Modernise Actions (#4082, #4088, #4089, #4091, #4093, #4094, #4095, #4117, #4162 by: techman83, HebaruSan; reviewed: HebaruSan)
- [Build] Refactor + Modernise Actions (#4082, #4088, #4089, #4091, #4093, #4094, #4095, #4117, #4162, #4188 by: techman83, HebaruSan; reviewed: HebaruSan)
- [Multiple] Translation updates from Crowdin (#4105, #4149, #4157 by: vinix38, frankieorabona, ambition, Francesco Ricina, S.O.2; reviewed: HebaruSan)
- [Netkan] Allow string "Harmony" in DLL parent folder names (#4123 by: HebaruSan)
- [Netkan] Allow licenses to be absent from netkans (#4137 by: HebaruSan)
Expand Down
35 changes: 26 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ var buildDirectory = rootDirectory.Combine("_build");
var nugetDirectory = buildDirectory.Combine("lib")
.Combine("nuget");
var outDirectory = buildDirectory.Combine("out");
var nupkgFile = outDirectory.Combine("CKAN")
.Combine(configuration)
.Combine("bin")
.CombineWithFilePath($"CKAN.{GetVersion(false)}.nupkg");
var repackDirectory = buildDirectory.Combine("repack");
var ckanFile = repackDirectory.Combine(configuration)
.CombineWithFilePath("ckan.exe");
var updaterFile = repackDirectory.Combine(configuration)
.CombineWithFilePath("AutoUpdater.exe");
var netkanFile = repackDirectory.Combine(configuration)
.CombineWithFilePath("netkan.exe");

Expand Down Expand Up @@ -202,7 +208,7 @@ Task("Repack-Ckan")
// Need facade to instantiate types from netstandard2.0 DLLs on Mono
assemblyPaths.Add(FacadesDirectory().CombineWithFilePath("netstandard.dll"));
var ckanLogFile = repackDirectory.Combine(configuration)
.CombineWithFilePath($"ckan.log");
.CombineWithFilePath("ckan.log");
ReportRepacking(ckanFile, ckanLogFile);
ILRepack(
ckanFile,
Expand All @@ -222,10 +228,8 @@ Task("Repack-Ckan")
.Combine(configuration)
.Combine("bin")
.Combine(buildNetFramework);
var updaterFile = repackDirectory.Combine(configuration)
.CombineWithFilePath("AutoUpdater.exe");
var updaterLogFile = repackDirectory.Combine(configuration)
.CombineWithFilePath($"AutoUpdater.log");
.CombineWithFilePath("AutoUpdater.log");
ReportRepacking(updaterFile, updaterLogFile);
ILRepack(
updaterFile,
Expand All @@ -242,7 +246,7 @@ Task("Repack-Ckan")
Log = updaterLogFile.FullPath,
});

CopyFile(ckanFile, buildDirectory.CombineWithFilePath("ckan.exe"));
CopyFile(ckanFile, buildDirectory.CombineWithFilePath(ckanFile.GetFilename()));
});

Task("Repack-Netkan")
Expand All @@ -256,7 +260,7 @@ Task("Repack-Netkan")
.Combine("bin")
.Combine(buildNetFramework);
var netkanLogFile = repackDirectory.Combine(configuration)
.CombineWithFilePath($"netkan.log");
.CombineWithFilePath("netkan.log");
var assemblyPaths = GetFiles(string.Format("{0}/*.dll", netkanBinDirectory));
// Need facade to instantiate types from netstandard2.0 DLLs on Mono
assemblyPaths.Add(FacadesDirectory().CombineWithFilePath("netstandard.dll"));
Expand All @@ -276,7 +280,20 @@ Task("Repack-Netkan")
}
);

CopyFile(netkanFile, buildDirectory.CombineWithFilePath("netkan.exe"));
CopyFile(netkanFile, buildDirectory.CombineWithFilePath(netkanFile.GetFilename()));
});

Task("Prepare-SignPath")
.Description("Create a folder with all artifacts to be signed")
.IsDependentOn("Repack-Ckan")
.Does(() =>
{
var targetDir = buildDirectory.Combine("signpath")
.Combine(configuration);
CreateDirectory(targetDir);
CopyFile(ckanFile, targetDir.CombineWithFilePath(ckanFile.GetFilename()));
CopyFile(updaterFile, targetDir.CombineWithFilePath(updaterFile.GetFilename()));
CopyFile(nupkgFile, targetDir.CombineWithFilePath(nupkgFile.GetFilename()));
});

private void ReportRepacking(FilePath target, FilePath log)
Expand Down Expand Up @@ -447,7 +464,7 @@ private DirectoryPath FacadesDirectory()
.Combine("4.8-api")
.Combine("Facades");

private Semver.SemVersion GetVersion()
private Semver.SemVersion GetVersion(bool withBuild = true)
{
var pattern = new Regex(@"^\s*##\s+v(?<version>\S+)\s?.*$");
var rootDirectory = Context.Environment.WorkingDirectory;
Expand All @@ -459,7 +476,7 @@ private Semver.SemVersion GetVersion()

var version = ParseSemVer(versionMatch.Groups["version"].Value);

if (DirectoryExists(rootDirectory.Combine(".git")))
if (withBuild && DirectoryExists(rootDirectory.Combine(".git")))
{
var commitDate = GitLogTip(rootDirectory).Committer.When;
version = CreateSemVer(version.Major,
Expand Down

0 comments on commit 982bc5c

Please sign in to comment.