forked from chocolatey/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request chocolatey#616 from gep13/use-recipe"
- Loading branch information
Showing
13 changed files
with
232 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
dotnet tool restore | ||
dotnet cake recipe.cake | ||
dotnet cake |
This file was deleted.
Oops, something went wrong.