GtkSharp/build.cake

188 lines
5 KiB
Plaintext
Raw Normal View History

#load CakeScripts\GAssembly.cake
#load CakeScripts\Settings.cake
2022-01-26 17:50:22 +00:00
#addin "Cake.FileHelpers&version=5.0.0"
#addin "Cake.Incubator&version=7.0.0"
2017-10-22 23:25:13 +00:00
// VARS
Settings.Cake = Context;
2021-03-07 11:31:19 +00:00
Settings.Version = Argument("BuildVersion", "3.24.24.1");
Settings.BuildTarget = Argument("BuildTarget", "Default");
Settings.Assembly = Argument("Assembly", "");
2019-05-21 17:21:51 +00:00
var configuration = Argument("Configuration", "Release");
2017-10-22 23:25:13 +00:00
var msbuildsettings = new DotNetCoreMSBuildSettings();
var list = new List<GAssembly>();
2017-10-22 23:25:13 +00:00
2022-01-26 17:50:22 +00:00
private void ParseVersion()
{
if (!string.IsNullOrEmpty(EnvironmentVariable("GITHUB_ACTIONS")))
{
var version = "3.24.24." + EnvironmentVariable("GITHUB_RUN_NUMBER");
var upstreamUrl = "GtkSharp/GtkSharp";
var repositoryUrl = EnvironmentVariable("GITHUB_REPOSITORY");
var branch = EnvironmentVariable("GITHUB_REF");
if (string.IsNullOrEmpty(repositoryUrl))
return;
if (repositoryUrl != upstreamUrl) // If we are building a PR
{
var split = repositoryUrl.Split('/');
version = version + "-" + split[0];
}
else if (repositoryUrl == upstreamUrl &&
!string.IsNullOrEmpty(branch) &&
branch != " refs/heads/master") // If we are building our repository
{
var branchName = branch.Substring(11);
version = version + "-" + branchName;
}
Settings.Version = version;
Console.WriteLine("Branch: " + branch);
}
Console.WriteLine("Version: " + Settings.Version);
}
2017-10-22 23:25:13 +00:00
// TASKS
Task("Init")
.Does(() =>
{
2022-01-26 17:50:22 +00:00
ParseVersion();
2017-10-29 14:28:44 +00:00
// Assign some common properties
2017-10-30 13:52:48 +00:00
msbuildsettings = msbuildsettings.WithProperty("Version", Settings.Version);
2017-10-29 14:28:44 +00:00
msbuildsettings = msbuildsettings.WithProperty("Authors", "'GtkSharp Contributors'");
msbuildsettings = msbuildsettings.WithProperty("PackageLicenseUrl", "'https://github.com/GtkSharp/GtkSharp/blob/cakecore/LICENSE'");
// Add stuff to list
2017-10-29 14:28:44 +00:00
Settings.Init();
2017-10-28 22:57:52 +00:00
foreach(var gassembly in Settings.AssemblyList)
if(string.IsNullOrEmpty(Settings.Assembly) || Settings.Assembly == gassembly.Name)
list.Add(gassembly);
});
2017-10-22 23:25:13 +00:00
Task("Prepare")
.IsDependentOn("Clean")
2017-10-22 23:25:13 +00:00
.Does(() =>
{
// Build tools
DotNetCoreRestore("Source/Tools/Tools.sln");
DotNetCoreBuild("Source/Tools/Tools.sln", new DotNetCoreBuildSettings {
Verbosity = DotNetCoreVerbosity.Minimal,
2019-05-21 17:21:51 +00:00
Configuration = configuration
2017-10-22 23:25:13 +00:00
});
// Generate code and prepare libs projects
foreach(var gassembly in list)
2017-10-22 23:25:13 +00:00
gassembly.Prepare();
2018-01-18 17:01:04 +00:00
DotNetCoreRestore("Source/GtkSharp.sln");
2018-02-28 17:55:16 +00:00
// Addin
DotNetCoreRestore("Source/Addins/MonoDevelop.GtkSharp.Addin/MonoDevelop.GtkSharp.Addin.sln");
});
2017-10-22 23:25:13 +00:00
Task("Clean")
.IsDependentOn("Init")
2017-10-22 23:25:13 +00:00
.Does(() =>
{
foreach(var gassembly in list)
2017-10-22 23:25:13 +00:00
gassembly.Clean();
});
Task("FullClean")
.IsDependentOn("Clean")
.Does(() =>
{
2021-03-07 11:31:19 +00:00
DeleteDirectory("BuildOutput", new DeleteDirectorySettings {
Recursive = true,
Force = true
});
});
2017-10-22 23:25:13 +00:00
Task("Build")
.IsDependentOn("Prepare")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
2017-10-22 23:25:13 +00:00
{
2019-05-21 17:21:51 +00:00
Configuration = configuration,
MSBuildSettings = msbuildsettings
};
2017-10-28 22:57:52 +00:00
if (list.Count == Settings.AssemblyList.Count)
2018-01-18 17:01:04 +00:00
DotNetCoreBuild("Source/GtkSharp.sln", settings);
else
{
foreach(var gassembly in list)
DotNetCoreBuild(gassembly.Csproj, settings);
}
});
2018-01-17 22:35:07 +00:00
Task("RunSamples")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
2019-05-21 17:21:51 +00:00
Configuration = configuration,
2018-01-17 22:35:07 +00:00
MSBuildSettings = msbuildsettings
};
DotNetCoreBuild("Source/Samples/Samples.csproj", settings);
DotNetCoreRun("Source/Samples/Samples.csproj");
});
Task("PackageNuGet")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCorePackSettings
{
MSBuildSettings = msbuildsettings,
2019-05-21 17:21:51 +00:00
Configuration = configuration,
OutputDirectory = "BuildOutput/NugetPackages",
NoBuild = true,
};
foreach(var gassembly in list)
DotNetCorePack(gassembly.Csproj, settings);
2017-10-22 23:25:13 +00:00
});
2017-10-28 23:35:22 +00:00
Task("PackageTemplates")
.IsDependentOn("Init")
.Does(() =>
{
var settings = new NuGetPackSettings
{
2017-10-30 13:52:48 +00:00
OutputDirectory = "BuildOutput/NugetPackages",
Version = Settings.Version
2017-10-28 23:35:22 +00:00
};
2017-11-07 19:12:11 +00:00
settings.BasePath = "Source/Templates/GtkSharp.Template.CSharp";
NuGetPack("Source/Templates/GtkSharp.Template.CSharp/GtkSharp.Template.CSharp.nuspec", settings);
2017-11-03 13:46:26 +00:00
2018-02-26 21:41:01 +00:00
settings.BasePath = "Source/Templates/GtkSharp.Template.FSharp";
NuGetPack("Source/Templates/GtkSharp.Template.FSharp/GtkSharp.Template.FSharp.nuspec", settings);
2017-11-07 19:12:11 +00:00
settings.BasePath = "Source/Templates/GtkSharp.Template.VBNet";
NuGetPack("Source/Templates/GtkSharp.Template.VBNet/GtkSharp.Template.VBNet.nuspec", settings);
2017-10-28 23:35:22 +00:00
});
2017-10-22 23:25:13 +00:00
// TASK TARGETS
Task("Default")
2022-01-26 17:50:22 +00:00
.IsDependentOn("Build")
2017-11-12 01:32:36 +00:00
.IsDependentOn("PackageNuGet")
2021-03-07 11:31:19 +00:00
.IsDependentOn("PackageTemplates");
2017-10-22 23:25:13 +00:00
// EXECUTION
RunTarget(Settings.BuildTarget);