From 70f5bd71a73431568425368f92b2c55259710f5c Mon Sep 17 00:00:00 2001 From: Loic Denuziere Date: Fri, 14 Dec 2018 18:47:49 +0100 Subject: [PATCH] Add AppVeyor config to publish to github-pages --- .gitignore | 3 ++- appveyor.yml | 22 ++++++++++++++++++++++ tools/gh-pages.ps1 | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 appveyor.yml create mode 100644 tools/gh-pages.ps1 diff --git a/.gitignore b/.gitignore index 0ed13d8..4bfb2de 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ bin/ obj/ paket-files/ .vs/ -*.user \ No newline at end of file +*.user +publish/ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..9a22005 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,22 @@ +version: 0.1.{build} +image: Visual Studio 2017 + +build: + verbosity: minimal + +branches: + only: + - master + +init: +- git config --global core.autocrlf input + +build_script: +- ps: dotnet publish src/WebFsc.Client/ -o $PWD/publish/ -c Release + +on_success: +- ps: .\tools\gh-pages.ps1 -env appveyor + +environment: + GH_TOKEN: + secure: dhFy1eZoqG4QPkKTuLFxix7QQMxaIyIpYjkvTU3CukYZz1CEOJeHfBSaT8tkPsGL diff --git a/tools/gh-pages.ps1 b/tools/gh-pages.ps1 new file mode 100644 index 0000000..de7b91d --- /dev/null +++ b/tools/gh-pages.ps1 @@ -0,0 +1,42 @@ +# pushes src/wwwroot to gh-pages branch + +param ([string] $env = "local") + +$msg = 'gh-pages.ps1: src/WebFsc.Client/wwwroot -> gh-pages' +$gitURL = "https://github.com/fsbolero/TryFSharpOnWasm" + +write-host -foregroundColor "green" "=====> $msg" + +function clearDir() { + rm -r build/gh-pages -errorAction ignore +} + +if ($env -eq "appveyor") { + clearDir + $d = mkdir -force build + git clone $gitURL build/gh-pages -b gh-pages --single-branch + cd build/gh-pages + git config credential.helper "store --file=.git/credentials" + $t = $env:GH_TOKEN + $cred = "https://" + $t + ":@github.com" + $d = pwd + [System.IO.File]::WriteAllText("$pwd/.git/credentials", $cred) + git config user.name "AppVeyor" + git config user.email "websharper-support@intellifactory.com" +} else { + clearDir + cd build + git clone .. gh-pages -b gh-pages --single-branch + cd gh-pages +} + +git rm -rf * +cp -r -force ../../publish/WebFsc.Client/dist/* . +echo $null >> .nojekyll +(get-content '.\index.html' -encoding utf8).replace('git.log +git commit --amend -am $msg +git push -f -u origin gh-pages +cd ../.. +clearDir +write-host -foregroundColor "green" "=====> DONE"