Skip to content

Commit

Permalink
Revert "Merge pull request chocolatey#616 from gep13/use-recipe"
Browse files Browse the repository at this point in the history
This reverts commit 4752ab5, reversing
changes made to 5c28c7b.
  • Loading branch information
gep13 committed Dec 14, 2022
1 parent 4752ab5 commit 8f286e4
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.3.0",
"version": "1.1.0",
"commands": [
"dotnet-cake"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
STATIQ_DEPLOY_REMOTE: ${{ secrets.STATIQ_DEPLOY_REMOTE }}
run: |
dotnet tool restore
dotnet cake recipe.cake --target=Publish-Documentation
dotnet cake --target=Publish-Documentation
2 changes: 1 addition & 1 deletion .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
dotnet tool restore
dotnet cake recipe.cake --target=Statiq-Build
dotnet cake --target=Statiq-Build
195 changes: 195 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
///////////////////////////////////////////////////////////////////////////////
// Tools
///////////////////////////////////////////////////////////////////////////////

#tool dotnet:https://www.myget.org/F/cake-contrib/api/v3/index.json?package=KuduSync.Tool&version=1.5.4-g3916ad7218

///////////////////////////////////////////////////////////////////////////////
// Addins
///////////////////////////////////////////////////////////////////////////////

#addin nuget:?package=Cake.Git&version=0.22.0
#addin nuget:?package=Cake.Kudu&version=1.0.1
#addin nuget:?package=Cake.Gulp&version=1.0.0
#addin nuget:?package=Cake.Yarn&version=0.4.8

///////////////////////////////////////////////////////////////////////////////
// Scripts
///////////////////////////////////////////////////////////////////////////////

#load "buildData.cake"

///////////////////////////////////////////////////////////////////////////////
// Arguments
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

///////////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////////

Setup<BuildData>(context =>
{
Information("Setting up BuildData...");

var buildData = new BuildData(context);

return buildData;
});

var projectPath = "./Docs.csproj";

///////////////////////////////////////////////////////////////////////////////
// Tasks
///////////////////////////////////////////////////////////////////////////////

Task("OS-test")
.Does(() =>
{
Information(Context.Environment.Platform.Family);
});
Task("Clean")
.Does<BuildData>((context, buildData) =>
{
var directoriesToClean = new []{
buildData.PublishDirectory,
buildData.OutputDirectory,
"./bin",
"./obj",
"./temp",
"./wwwroot"
};

CleanDirectories(directoriesToClean);
});

Task("Yarn-Install")
.WithCriteria(() => FileExists("./package.json"), "package.json file not found in repository")
.IsDependentOn("Clean")
.Does(() =>
{
if (BuildSystem.IsLocalBuild)
{
Information("Running yarn install...");
Yarn.Install();
}
else
{
Information("Running yarn install --immutable...");
Yarn.Install(settings => settings.ArgumentCustomization = args => args.Append("--immutable"));
}
});

Task("Run-Gulp")
.WithCriteria(() => FileExists("./gulpfile.js"), "gulpfile.js file not found in repository")
.IsDependentOn("Yarn-Install")
.Does(() =>
{
Gulp.Local.Execute();
});

Task("Statiq-Preview")
.IsDependentOn("Run-Gulp")
.Does<BuildData>((context, buildData) =>
{
var settings = new DotNetCoreRunSettings {
Configuration = configuration
};

DotNetCoreRun(projectPath, new ProcessArgumentBuilder().Append(string.Format("preview --output \"{0}\"", buildData.OutputDirectory)), settings);
});

Task("Statiq-Build")
.IsDependentOn("Run-Gulp")
.Does<BuildData>((context, buildData) =>
{
var settings = new DotNetCoreRunSettings {
Configuration = configuration
};

DotNetCoreRun(projectPath, new ProcessArgumentBuilder().Append(string.Format("--output \"{0}\"", buildData.OutputDirectory)), settings);
});

Task("Statiq-LinkValidation")
.IsDependentOn("Run-Gulp")
.Does<BuildData>((context, buildData) =>
{
var settings = new DotNetCoreRunSettings {
Configuration = configuration,
ArgumentCustomization = args => args.Append("-a ValidateRelativeLinks=Error -a ValidateAbsoluteLinks=Error")
};

DotNetCoreRun(projectPath, new ProcessArgumentBuilder().Append(string.Format("--output \"{0}\"", buildData.OutputDirectory)), settings);
});

Task("Publish-Documentation")
.IsDependentOn("Statiq-Build")
.Does<BuildData>((context, buildData) =>
{
var sourceCommit = GitLogTip("./");

CleanDirectory(buildData.PublishDirectory);
var publishFolder = buildData.PublishDirectory.Combine(DateTime.Now.ToString("yyyyMMdd_HHmmss"));

Information("Publishing Folder: {0}", publishFolder);
Information("Getting publish branch...");

if (!string.IsNullOrWhiteSpace(buildData.GitHubUserName) && !string.IsNullOrWhiteSpace(buildData.GitHubPassword))
{
Information("Cloning repository using username and password...");
GitClone(buildData.DeployRemote, publishFolder, buildData.GitHubUserName, buildData.GitHubPassword, new GitCloneSettings{ BranchName = buildData.DeployBranch });
}
else if (!string.IsNullOrWhiteSpace(buildData.GitHubToken))
{
Information("Cloning repository using token...");
GitClone(buildData.DeployRemote, publishFolder, buildData.GitHubToken, "x-oauth-basic", new GitCloneSettings{ BranchName = buildData.DeployBranch });
}
else
{
Information("Cloning repository anonymously...");
GitClone(buildData.DeployRemote, publishFolder, new GitCloneSettings{ BranchName = buildData.DeployBranch });
}

Information("Sync output files...");

Kudu.Sync(buildData.OutputDirectory, publishFolder, new KuduSyncSettings {
ArgumentCustomization = args=>args.Append("--ignore").AppendQuoted(".git;CNAME")
});

if (GitHasUncommitedChanges(publishFolder))
{
Information("Stage all changes...");
GitAddAll(publishFolder);

if (GitHasStagedChanges(publishFolder))
{
Information("Commit all changes...");
GitCommit(
publishFolder,
sourceCommit.Committer.Name,
sourceCommit.Committer.Email,
string.Format("Continuous Integration Publish: {0}\r\n{1}", sourceCommit.Sha, sourceCommit.Message)
);

Information("Pushing all changes...");

if (!string.IsNullOrWhiteSpace(buildData.GitHubUserName) && !string.IsNullOrWhiteSpace(buildData.GitHubPassword))
{
Information("Pushing with username and password...");
GitPush(publishFolder, buildData.GitHubUserName, buildData.GitHubPassword, buildData.DeployBranch);
}
else
{
Information("Pushing with token...");
GitPush(publishFolder, buildData.GitHubToken, "x-oauth-basic", buildData.DeployBranch);
}
}
}
});

Task("Default")
.IsDependentOn("Statiq-Preview");

RunTarget(target);
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ $env:DOTNET_NOLOGO = '1'
dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

dotnet cake recipe.cake --target=Statiq-Build
dotnet cake --target=Statiq-Build
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

dotnet tool restore
dotnet cake recipe.cake --target=Statiq-Build
dotnet cake --target=Statiq-Build
28 changes: 28 additions & 0 deletions buildData.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class BuildData
{
public string DeployRemote { get; set; }
public string DeployBranch { get; set; }
public DirectoryPath PublishDirectory { get; set; }
public DirectoryPath OutputDirectory { get; set; }
public string GitHubToken { get; set; }
public string GitHubUserName { get; set; }
public string GitHubPassword { get; set; }
public string ProjectPath { get; set; }

public BuildData(ICakeContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

DeployRemote = context.EnvironmentVariable("STATIQ_DEPLOY_REMOTE");
DeployBranch = context.EnvironmentVariable("STATIQ_DEPLOY_BRANCH");
PublishDirectory = context.MakeAbsolute(context.Directory("publish"));
OutputDirectory = context.MakeAbsolute(context.Directory("output"));
GitHubToken = context.EnvironmentVariable("STATIQ_GITHUB_TOKEN");
GitHubUserName = context.EnvironmentVariable("STATIQ_GITHUB_USER_NAME");
GitHubPassword = context.EnvironmentVariable("STATIQ_GITHUB_PASSWORD");
ProjectPath = context.EnvironmentVariable("STATIQ_PROJECT_PATH");
}
}
17 changes: 0 additions & 17 deletions cake.config

This file was deleted.

2 changes: 1 addition & 1 deletion link-validation.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet tool restore
dotnet cake recipe.cake --target=Statiq-LinkValidation
dotnet cake --target=Statiq-LinkValidation
2 changes: 1 addition & 1 deletion link-validation.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet tool restore
dotnet cake recipe.cake --target=Statiq-LinkValidation
dotnet cake --target=Statiq-LinkValidation
2 changes: 1 addition & 1 deletion preview.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try {
Push-Location $PSScriptRoot
dotnet tool restore
dotnet cake recipe.cake
dotnet cake
} finally {
Pop-Location
}
2 changes: 1 addition & 1 deletion preview.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet tool restore
dotnet cake recipe.cake
dotnet cake
12 changes: 0 additions & 12 deletions recipe.cake

This file was deleted.

0 comments on commit 8f286e4

Please sign in to comment.