forked from justcoding121/titanium-web-proxy
-
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.
update build script to auto-generate documentation
- Loading branch information
1 parent
6ffe116
commit 7657809
Showing
10 changed files
with
243 additions
and
575 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
$PSake.use_exit_on_error = $true | ||
|
||
$Here = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
|
||
$SolutionRoot = (Split-Path -parent $Here) | ||
|
||
$ProjectName = "Titanium.Web.Proxy" | ||
$GitHubProjectName = "Titanium-Web-Proxy" | ||
$GitHubUserName = "justcoding121" | ||
|
||
$SolutionFile = "$SolutionRoot\$ProjectName.sln" | ||
|
||
## This comes from the build server iteration | ||
if(!$BuildNumber) { $BuildNumber = $env:APPVEYOR_BUILD_NUMBER } | ||
if(!$BuildNumber) { $BuildNumber = "0"} | ||
|
||
## The build configuration, i.e. Debug/Release | ||
if(!$Configuration) { $Configuration = $env:Configuration } | ||
if(!$Configuration) { $Configuration = "Release" } | ||
|
||
if(!$Version) { $Version = $env:APPVEYOR_BUILD_VERSION } | ||
if(!$Version) { $Version = "0.0.$BuildNumber" } | ||
|
||
if(!$Branch) { $Branch = $env:APPVEYOR_REPO_BRANCH } | ||
if(!$Branch) { $Branch = "local" } | ||
|
||
if($Branch -eq "beta" ) { $Version = "$Version-beta" } | ||
|
||
$NuGet = Join-Path $SolutionRoot ".nuget\nuget.exe" | ||
|
||
$MSBuild = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" | ||
$MSBuild -replace ' ', '` ' | ||
|
||
FormatTaskName (("-"*25) + "[{0}]" + ("-"*25)) | ||
|
||
#default task | ||
Task default -depends Clean, Build, Document, Package | ||
|
||
#cleans obj, b | ||
Task Clean { | ||
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { Remove-Item $_.fullname -Force -Recurse } | ||
exec { . $MSBuild $SolutionFile /t:Clean /v:quiet } | ||
} | ||
|
||
#install build tools | ||
Task Install-BuildTools -depends Clean { | ||
if(!(Test-Path $MSBuild)) | ||
{ | ||
cinst microsoft-build-tools -y | ||
} | ||
} | ||
|
||
#restore nuget packages | ||
Task Restore-Packages -depends Install-BuildTools { | ||
exec { . dotnet restore "$SolutionRoot\$ProjectName" } | ||
} | ||
|
||
#build | ||
Task Build -depends Restore-Packages{ | ||
exec { . $MSBuild $SolutionFile /t:Build /v:normal /p:Configuration=$Configuration /t:restore } | ||
} | ||
|
||
#publish API documentation changes for GitHub pages under master\docs directory | ||
Task Document -depends Build { | ||
|
||
if($Branch -eq "master") | ||
{ | ||
#use docfx to generate API documentation from source metadata | ||
docfx docfx.json | ||
|
||
#patch index.json so that it is always sorted | ||
#otherwise git will think file was changed | ||
$IndexJsonFile = "$SolutionRoot\docs\index.json" | ||
$unsorted = Get-Content $IndexJsonFile | Out-String | ||
[Reflection.Assembly]::LoadFile("$Here\lib\Newtonsoft.Json.dll") | ||
[System.Reflection.Assembly]::LoadWithPartialName("System") | ||
$hashTable = [Newtonsoft.Json.JsonConvert]::DeserializeObject($unsorted, [System.Collections.Generic.SortedDictionary[[string],[object]]]) | ||
$obj = [Newtonsoft.Json.JsonConvert]::SerializeObject($hashTable, [Newtonsoft.Json.Formatting]::Indented) | ||
Set-Content -Path $IndexJsonFile -Value $obj | ||
|
||
#setup clone directory | ||
$TEMP_REPO_DIR =(Split-Path -parent $SolutionRoot) + "\temp-repo-clone" | ||
|
||
If(test-path $TEMP_REPO_DIR) | ||
{ | ||
Remove-Item $TEMP_REPO_DIR -Force -Recurse | ||
} | ||
|
||
New-Item -ItemType Directory -Force -Path $TEMP_REPO_DIR | ||
|
||
#clone | ||
git clone https://github.com/$GitHubUserName/$GitHubProjectName.git --branch master $TEMP_REPO_DIR | ||
|
||
If(test-path "$TEMP_REPO_DIR\docs") | ||
{ | ||
Remove-Item "$TEMP_REPO_DIR\docs" -Force -Recurse | ||
} | ||
New-Item -ItemType Directory -Force -Path "$TEMP_REPO_DIR\docs" | ||
|
||
#cd to docs folder | ||
cd "$TEMP_REPO_DIR\docs" | ||
|
||
#copy docs to clone directory\docs | ||
Copy-Item -Path "$SolutionRoot\docs\*" -Destination "$TEMP_REPO_DIR\docs" -Recurse -Force | ||
|
||
#push changes to master | ||
git config --global credential.helper store | ||
Add-Content "$HOME\.git-credentials" "https://$($env:github_access_token):[email protected]`n" | ||
git config --global user.email $env:github_email | ||
git config --global user.name "buildbot121" | ||
git add . -A | ||
git commit -m "Maintanance commit by build server" | ||
git push origin master | ||
|
||
#move cd back to current location | ||
cd $Here | ||
} | ||
} | ||
|
||
#package nuget files | ||
Task Package -depends Document { | ||
exec { . $NuGet pack "$SolutionRoot\$ProjectName\$ProjectName.nuspec" -Properties Configuration=$Configuration -OutputDirectory "$SolutionRoot" -Version "$Version" } | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"metadata": [ | ||
{ | ||
"src": [ | ||
{ | ||
"files": [ "Titanium.Web.Proxy.Docs.sln"], | ||
"src": "../" | ||
} | ||
], | ||
"dest": "obj/api" | ||
} | ||
], | ||
"build": { | ||
"content": [ | ||
{ | ||
"files": [ "**/*.yml" ], | ||
"src": "obj/api", | ||
"dest": "api" | ||
}, | ||
{ | ||
"files": [ "*.md" ] | ||
} | ||
], | ||
"resource": [ | ||
{ | ||
"files": [ ""] | ||
} | ||
], | ||
"overwrite": "specs/*.md", | ||
"globalMetadata": { | ||
"_appTitle": "Titanium Web Proxy", | ||
"_enableSearch": true | ||
}, | ||
"dest": "../docs", | ||
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ] | ||
} | ||
} |
Binary file not shown.
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,81 @@ | ||
param ( | ||
[string]$Action="default", | ||
[hashtable]$properties=@{}, | ||
[switch]$Help | ||
) | ||
|
||
function Install-Chocolatey() | ||
{ | ||
if(-not $env:ChocolateyInstall -or -not (Test-Path "$env:ChocolateyInstall")) | ||
{ | ||
Write-Output "Chocolatey Not Found, Installing..." | ||
iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) | ||
} | ||
$env:Path += ";${env:ChocolateyInstall}" | ||
} | ||
|
||
function Install-Psake() | ||
{ | ||
if(!(Test-Path $env:ChocolateyInstall\lib\Psake\tools\Psake*)) | ||
{ | ||
choco install psake -y | ||
} | ||
} | ||
|
||
function Install-Git() | ||
{ | ||
if(!((Test-Path ${env:ProgramFiles(x86)}\Git*) -Or (Test-Path ${env:ProgramFiles}\Git*))) | ||
{ | ||
choco install git.install | ||
} | ||
$env:Path += ";${env:ProgramFiles(x86)}\Git" | ||
$env:Path += ";${env:ProgramFiles}\Git" | ||
} | ||
|
||
function Install-DocFx() | ||
{ | ||
if(!(Test-Path $env:ChocolateyInstall\lib\docfx\tools*)) | ||
{ | ||
choco install docfx | ||
} | ||
$env:Path += ";$env:ChocolateyInstall\lib\docfx\tools" | ||
} | ||
|
||
#current directory | ||
$Here = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
|
||
$ErrorActionPreference = 'Stop' | ||
Set-StrictMode -Version Latest | ||
|
||
$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition | ||
$SolutionRoot = Split-Path -Parent $ScriptPath | ||
$ToolsPath = Join-Path -Path $SolutionRoot -ChildPath "lib" | ||
|
||
if(-not $env:ChocolateyInstall) | ||
{ | ||
$env:ChocolateyInstall = "${env:ALLUSERSPROFILE}\chocolatey"; | ||
} | ||
|
||
Install-Chocolatey | ||
|
||
Install-Psake | ||
|
||
Install-Git | ||
|
||
Install-DocFx | ||
|
||
$psakeDirectory = (Resolve-Path $env:ChocolateyInstall\lib\Psake*) | ||
|
||
#appveyor for some reason have different location for psake (it has older psake version?) | ||
if(Test-Path $psakeDirectory\tools\Psake\Psake.psm*) | ||
{ | ||
Import-Module (Join-Path $psakeDirectory "tools\Psake\Psake.psm1") | ||
} | ||
else | ||
{ | ||
Import-Module (Join-Path $psakeDirectory "tools\Psake.psm1") | ||
} | ||
|
||
|
||
#invoke the task | ||
Invoke-Psake -buildFile "$Here\build.ps1" -parameters $properties -tasklist $Action |
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,11 +1,4 @@ | ||
@echo off | ||
|
||
if '%1'=='/?' goto help | ||
if '%1'=='-help' goto help | ||
if '%1'=='-h' goto help | ||
|
||
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0.build\bootstrap.ps1 %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }" | ||
exit /B %errorlevel% | ||
|
||
:help | ||
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0.build\bootstrap.ps1' -help" | ||
powershell -NoProfile -ExecutionPolicy bypass -Command "%~dp0.build\setup.ps1 %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }" | ||
exit /B %errorlevel% |
Oops, something went wrong.