Skip to content

Commit

Permalink
Add appveyor based build
Browse files Browse the repository at this point in the history
  • Loading branch information
vbfox committed Oct 16, 2016
1 parent 386a470 commit d33d7ce
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
_site
.sass-cache
packages
.fake
7 changes: 6 additions & 1 deletion _config.yml
Expand Up @@ -14,4 +14,9 @@ highlighter: pygments
exclude:
- Gemfile*
- readme.md
- '*.cmd'
- '*.cmd'
- paket.*
- '*.fsx'
- '.fake'
- 'packages'
- 'appveyor.yml'
16 changes: 16 additions & 0 deletions appveyor.yml
@@ -0,0 +1,16 @@
version: 1.0.{build}
branches:
only:
- master
skip_tags: true
environment:
password:
secure: SHp3N2vcWjhD8xFFopC4ufWnsSbyDowKSa+gCLRrIFA=
install:
- cmd: set PATH=C:\Ruby22-x64\bin;C:\Python27-x64;%PATH%
build_script:
- cmd: >-
build.cmd CI -ev password
artifacts:
- path: _site
name: Site
8 changes: 8 additions & 0 deletions build.cmd
@@ -0,0 +1,8 @@
@echo off

paket.exe restore
if errorlevel 1 (
exit /b %errorlevel%
)

packages\FAKE\tools\FAKE.exe build.fsx %*
92 changes: 92 additions & 0 deletions build.fsx
@@ -0,0 +1,92 @@
#r "packages/FAKE/tools/FakeLib.dll"
#r "packages/WinSCP/lib/WinSCPnet.dll"

open Fake
open WinSCP
open System
open System.IO
open System.Diagnostics

module WindowsPath =
open System
open System.IO

let path = lazy (Environment.GetEnvironmentVariable("PATH").Split(';') |> List.ofArray)
let pathExt = lazy (Environment.GetEnvironmentVariable("PATHEXT").Split(';') |> List.ofArray)

let find names =
path.Value
|> Seq.collect (fun dir -> names |> List.map (fun name -> Path.Combine(dir, name)))
|> Seq.tryFind(File.Exists)

let findProgram name =
pathExt.Value
|> List.map ((+) name)
|> find

let rootDir = Path.GetFullPath(__SOURCE_DIRECTORY__)

let getBundlePath() =
match WindowsPath.findProgram "bundle" with
| Some(p) -> p
| None -> failwith "Bundle not found"

let execBundle args =
let config (psi:ProcessStartInfo) =
psi.FileName <- getBundlePath()
psi.Arguments <- args
ExecProcess config (TimeSpan.FromMinutes(5.)) |> ignore

Target "Install" <| fun _ ->
execBundle ""

Target "Build" <| fun _ ->
execBundle "exec jekyll build"

Target "Serve" <| fun _ ->
execBundle "exec jekyll serve --future --watch"

let private winScpPath =
lazy (
let assemblyDir = Path.GetDirectoryName(typedefof<Session>.Assembly.Location)
Path.Combine(assemblyDir, "..", "content", "WinSCP.exe")
)

let uploadFolder localDir remoteDir (options: SessionOptions) =
use session = new Session()
session.ExecutablePath <- winScpPath.Value
session.Open options

let localPath = Path.Combine(localDir, "*")
printfn "Uploading the content of '%s' to '%s' on '%s'" localPath remoteDir options.HostName
let result = session.PutFiles(localPath, remoteDir)

if not result.IsSuccess then
let exceptions = result.Failures |> Seq.map (fun e -> e :> Exception)
raise (new AggregateException(exceptions))

let envVarOrAskUser name question =
match environVarOrNone name with
| Some x -> x
| None -> getUserPassword question

Target "Upload" <| fun _ ->
let options = new SessionOptions()
options.Protocol <- Protocol.Ftp
options.FtpSecure <- FtpSecure.Explicit
options.FtpMode <- FtpMode.Active
options.HostName <- "vbfox.net"
options.UserName <- "blog_upload"
options.Password <- envVarOrAskUser "password" "FTP Password: "
uploadFolder (rootDir </> "_site") "/" options

Target "CI" DoNothing

"Install" ?=> "Build"
"Install" ?=> "Serve"
"Build" ==> "Upload"

"CI" ==> "Install"
"CI" ==> "Upload"

RunTargetOrDefault "Build"
3 changes: 3 additions & 0 deletions paket.dependencies
@@ -0,0 +1,3 @@
source https://api.nuget.org/v3/index.json
nuget FAKE
nuget WinSCP
Binary file added paket.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions paket.lock
@@ -0,0 +1,4 @@
NUGET
remote: http://api.nuget.org/v3/index.json
FAKE (4.41.6)
WinSCP (5.9.2)

0 comments on commit d33d7ce

Please sign in to comment.