-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.fsx
executable file
·86 lines (68 loc) · 1.91 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.JavaScript.Yarn"
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.Tools.Git"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open System
open Fake.JavaScript
let gitName = "sample-react-todo"
let gitOwner = "fable-elmish"
let gitHome = sprintf "https://github.com/%s" gitOwner
// Filesets
let projects =
!! "src/**.fsproj"
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false __SOURCE_FILE__
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
Target.create "Clean" (fun _ ->
Shell.cleanDir "build"
)
Target.create "Install" (fun _ ->
Yarn.install id
projects
|> Seq.iter (fun s ->
let dir = IO.Path.GetDirectoryName s
DotNet.restore id dir
)
)
Target.create "Build" (fun _ ->
DotNet.exec id "fable" "src -o src/out --run webpack" |> ignore
)
Target.create "Watch" (fun _ ->
DotNet.exec id "fable" "watch src -o src/out -s --run webpack serve" |> ignore
)
// --------------------------------------------------------------------------------------
// Release Scripts
open Fake.Tools.Git
Target.create "ReleaseSample" (fun _ ->
let tempDocsDir = "temp/gh-pages"
Shell.cleanDir tempDocsDir
Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "gh-pages" tempDocsDir
Shell.copyRecursive "build" tempDocsDir true |> ignore
Staging.stageAll tempDocsDir
Commit.exec tempDocsDir (sprintf "Update generated sample")
Branches.push tempDocsDir
)
Target.create "Publish" ignore
// Build order
"Clean"
==> "Install"
==> "Build"
"Clean"
==> "Install"
==> "Watch"
"Publish"
<== [ "Build"
"ReleaseSample" ]
// start build
Target.runOrDefault "Build"