Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 46 additions & 24 deletions martenbuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class MartenBuild

static void Main(string[] args)
{
var platformID = Environment.OSVersion.Platform;

var configuration = Environment.GetEnvironmentVariable("config");
configuration = string.IsNullOrEmpty(configuration) ? "debug" : configuration;

Expand All @@ -34,26 +32,12 @@ static void Main(string[] args)

Target("install", () =>
{
if (platformID == PlatformID.Unix || platformID == PlatformID.MacOSX)
{
Run("npm", "install");
}
else
{
Run("cmd.exe", "/c npm install");
}
RunNpm("install");
});

Target("mocha", DependsOn("install"), () =>
{
if (platformID == PlatformID.Unix || platformID == PlatformID.MacOSX)
{
Run("npm", "run test");
}
else
{
Run("cmd.exe", "/c npm run test");
}
RunNpm("run test");
});

Target("compile", DependsOn("clean"), () =>
Expand Down Expand Up @@ -83,22 +67,36 @@ static void Main(string[] args)

Target("docs", DependsOn("docs-restore"), () =>
{
Run("dotnet", $"stdocs run -d ../../documentation -c ../../src -v {BUILD_VERSION}", "tools/stdocs");
RunStoryTellerDocs($"run -d ../../documentation -c ../../src -v {BUILD_VERSION}");
});

// Exports the documentation to jasperfx.github.io/marten - requires Git access to that repo though!
Target("publish", () =>
{
var docTargetDir = InitializeDirectory("doc-target");
const string docTargetDir = "doc-target";

Run("git", $"clone -b gh-pages https://github.com/jasperfx/marten.git {docTargetDir}");
if (!Directory.Exists(docTargetDir))
{
InitializeDirectory(docTargetDir);
Run("git", $"clone -b gh-pages https://github.com/jasperfx/marten.git {docTargetDir}");

Run("dotnet", "restore", "tools/stdocs");
Run("dotnet", $"stdocs export ../../{docTargetDir} ProjectWebsite -d ../../documentation -c ../../src -v {BUILD_VERSION} --project marten", "tools/stdocs");
// if you are not using git --global config, uncomment the block below, update and use it
// Run("git", "config user.email email_address");
// Run("git", "config user.name your_name");
}
else
{
Run("git", "checkout --force", docTargetDir);
Run("git", "clean -xfd", docTargetDir);
Run("git", "pull origin master", docTargetDir);
}

RunStoryTellerDocs(
$"export ../../{docTargetDir} ProjectWebsite -d ../../documentation -c ../../src -v {BUILD_VERSION} --project marten");

Run("git", "add --all", docTargetDir);
Run("git", $"commit -a -m \"Documentation Update for {BUILD_VERSION}\" --allow-empty", docTargetDir);
Run("git", "git push origin gh-pages", docTargetDir);
Run("git", "push origin gh-pages", docTargetDir);
});

Target("benchmarks", () =>
Expand Down Expand Up @@ -138,5 +136,29 @@ private static void EnsureDirectoryDeleted(string path)
Directory.Delete(path, true);
}
}

private static bool IsWindowsPlatform()
{
var platformId = Environment.OSVersion.Platform;
return platformId != PlatformID.Unix && platformId != PlatformID.MacOSX;
}

private static void RunNpm(string args)
{
if (IsWindowsPlatform())
{
Run("cmd.exe", $"/c npm {args}");
}
else
{
Run("npm", args);
}
}

private static void RunStoryTellerDocs(string args)
{
Run("dotnet", "restore", "tools/stdocs");
Run("dotnet", $"stdocs {args}", "tools/stdocs");
}
}
}