Skip to content

Commit

Permalink
New build script
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpeRAD committed Jan 14, 2016
1 parent bea0e05 commit 2a2a2d3
Showing 1 changed file with 41 additions and 72 deletions.
113 changes: 41 additions & 72 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var appName = "CakeBoss";


//////////////////////////////////////////////////////////////////////
// PREPARATION
// VARIABLES
//////////////////////////////////////////////////////////////////////

// Get whether or not this is a local build.
Expand All @@ -37,15 +37,18 @@ var buildAddinDir = "./src/Cake.CakeBoss/bin/" + configuration;
var buildAgentDir = "./src/CakeBoss.Agent/bin/" + configuration;

var buildResultDir = "./build/v" + semVersion;
var testResultDir = buildResultDir + "/tests";
var nugetRoot = buildResultDir + "/nuget";
var testResultsDir = buildResultDir + "/test-results";

var nugetRoot = buildResultDir + "/nuget";
var binAddinDir = buildResultDir + "/binAddin";
var binAgentDir = buildResultDir + "/binAgent";

//Get Solutions
var solutions = GetFiles("./**/*.sln");

// Package
var zipPackage = buildResultDir + "/CakeBoss-v" + semVersion + ".zip";




Expand All @@ -72,8 +75,6 @@ Setup(() =>
});
});



Teardown(() =>
{
// Executed AFTER the last task.
Expand All @@ -85,7 +86,7 @@ Teardown(() =>


///////////////////////////////////////////////////////////////////////////////
// TASK DEFINITIONS
// PREPARE
///////////////////////////////////////////////////////////////////////////////

Task("Clean")
Expand All @@ -95,12 +96,12 @@ Task("Clean")
Information("Cleaning old files");
CleanDirectories(new DirectoryPath[]
{
buildResultDir, binAgentDir, binAddinDir, testResultDir, nugetRoot
buildDir, buildTestDir, buildResultDir,
binAgentDir, binAddinDir,
testResultsDir, nugetRoot
});
});



Task("Restore-Nuget-Packages")
.IsDependentOn("Clean")
.Does(() =>
Expand All @@ -113,6 +114,14 @@ Task("Restore-Nuget-Packages")
}
});





///////////////////////////////////////////////////////////////////////////////
// BUILD
///////////////////////////////////////////////////////////////////////////////

Task("Patch-Assembly-Info")
.IsDependentOn("Restore-Nuget-Packages")
.Does(() =>
Expand All @@ -129,8 +138,6 @@ Task("Patch-Assembly-Info")
});
});



Task("Build")
.IsDependentOn("Patch-Assembly-Info")
.Does(() =>
Expand Down Expand Up @@ -160,6 +167,12 @@ Task("Run-Unit-Tests")





///////////////////////////////////////////////////////////////////////////////
// PACKAGE
///////////////////////////////////////////////////////////////////////////////

Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
Expand Down Expand Up @@ -234,9 +247,7 @@ Task("Zip-Files")
.IsDependentOn("Copy-Files")
.Does(() =>
{
var filename = buildResultDir + "/CakeBoss-v" + semVersion + ".zip";

Zip(binAgentDir, filename);
Zip(binAgentDir, zipPackage);
});


Expand Down Expand Up @@ -283,6 +294,12 @@ Task("Publish-Nuget")





///////////////////////////////////////////////////////////////////////////////
// APPVEYOR
///////////////////////////////////////////////////////////////////////////////

Task("Update-AppVeyor-Build-Number")
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() =>
Expand All @@ -295,49 +312,16 @@ Task("Upload-AppVeyor-Artifacts")
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() =>
{
var artifact = new FilePath(buildResultDir + "/Cake-CakeBoss-v" + semVersion + ".zip");

AppVeyor.UploadArtifact(artifact);
AppVeyor.UploadArtifact(zipPackage);
});



Task("Create-GitHub-Release")
.IsDependentOn("Zip-Files")
.Does(() =>
{
//Get Arguments
var milestone = string.Concat("v", version);

var userName = EnvironmentVariable("GITHUB_USERNAME");
if(string.IsNullOrEmpty(userName))
{
throw new InvalidOperationException("Could not resolve GitHub username.");
}

var password = EnvironmentVariable("GITHUB_PASSWORD");
if(string.IsNullOrEmpty(password))
{
throw new InvalidOperationException("Could not resolve GitHub password.");
}



//Create Release
var asset = new FilePath(buildResultDir + "/Cake-CakeBoss-v" + semVersion + ".zip");

GitReleaseManagerCreate(userName, password, "SharpeRAD", "CakeBoss", new GitReleaseManagerCreateSettings
{
Milestone = milestone,
Name = milestone,
Prerelease = true,
TargetCommitish = "main",
InputFilePath = "./ReleaseNotes.md",
Assets = asset.FullPath
});
});


///////////////////////////////////////////////////////////////////////////////
// MESSAGE
///////////////////////////////////////////////////////////////////////////////

Task("Slack")
.Does(() =>
Expand All @@ -352,21 +336,9 @@ Task("Slack")



//Get Text
var text = "";

if (isPullRequest)
{
text = "PR submitted for " + appName;
}
else
{
text = "Published " + appName + " v" + version;
}



// Post Message
var text = "Published " + appName + " v" + version;

var result = Slack.Chat.PostMessage(token, "#code", text);

if (result.Ok)
Expand All @@ -392,18 +364,15 @@ Task("Slack")
Task("Package")
.IsDependentOn("Zip-Files")
.IsDependentOn("Create-NuGet-Packages");

Task("Release")
.IsDependentOn("Create-GitHub-Release");


Task("Publish")
.IsDependentOn("Publish-NuGet");
.IsDependentOn("Publish-Nuget");

Task("AppVeyor")
.IsDependentOn("Publish")
.IsDependentOn("Update-AppVeyor-Build-Number")
.IsDependentOn("Upload-AppVeyor-Artifacts")
//.IsDependentOn("Release")
.IsDependentOn("Publish");
.IsDependentOn("Slack");



Expand Down

0 comments on commit 2a2a2d3

Please sign in to comment.