-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.fsx
130 lines (105 loc) · 3.47 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#load ".fake/build.fsx/intellisense.fsx"
open Fake.SystemHelper
open Fake.JavaScript
open Fake.IO
open Fake.Core
open Fake.DotNet
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.Api
open Fake.Tools.Git
let outputDir = "nuget"
let release = ReleaseNotes.load "RELEASE_NOTES.md"
let gitOwner = "mvsmal"
let gitRepo = "fable-material-ui"
let paketToolPath = "paket"
let toLines = String.concat "\n"
let removeBackTicks = String.replace "`" ""
let cleanDirs root output _ =
!! (root + "src/**/bin")
++ (root + "src/**/obj")
++ output
|> Shell.cleanDirs
let build root _ =
!! (root + "src/**/*.*proj")
|> Seq.iter (DotNet.build id)
Target.create "Clean" (cleanDirs "" outputDir)
Target.create "Restore" (fun _ ->
Paket.restore (fun p -> { p with ToolPath = paketToolPath })
)
Target.create "Build" (build "")
Target.create "NuGet" (fun _ ->
Paket.pack(fun p ->
{ p with
ToolPath = paketToolPath
OutputPath = outputDir
Version = release.NugetVersion
ReleaseNotes = release.Notes |> toLines |> removeBackTicks })
)
Target.create "PublishNuGet" (fun _ ->
Paket.push(fun p ->
{ p with
ToolPath = paketToolPath
PublishUrl = "https://www.nuget.org"
WorkingDir = outputDir })
)
Target.create "GitHubRelease" (fun _ ->
let token =
match Environment.environVarOrDefault "github_token" "" with
| s when not (System.String.IsNullOrWhiteSpace s) -> s
| _ -> failwith "please set the github_token environment variable to a github personal access token with repro access."
let files = !! ".output/**/*.*"
token
|> GitHub.createClientWithToken
|> GitHub.draftNewRelease gitOwner gitRepo release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> GitHub.uploadFiles files
|> GitHub.publishDraft
|> Async.RunSynchronously)
let inline withDocsWorkDir (p : Yarn.YarnParams) =
{ p with WorkingDirectory = "docs/" }
Target.create "DocsClean" (cleanDirs "docs/" "docs/dist")
Target.create "DocsBuild" (build "docs/")
Target.create "DocsYarnInstall" (fun _ -> Yarn.install withDocsWorkDir)
Target.create "DocsRun" (fun _ -> Yarn.exec "start" withDocsWorkDir)
Target.create "DocsPackage" (fun _ -> Yarn.exec "build" withDocsWorkDir)
// Where to push generated documentation
let githubLink = "https://github.com/mvsmal/fable-material-ui.git"
let publishBranch = "gh-pages"
let temp = "docs/temp"
let docsOuput = "docs/dist"
// --------------------------------------------------------------------------------------
// Release Scripts
Target.create "DocsPublish" (fun _ ->
let now = System.DateTime.Now
Shell.cleanDir temp
Repository.cloneSingleBranch "" githubLink publishBranch temp
Shell.copyRecursive docsOuput temp true |> Trace.tracefn "%A"
Staging.stageAll temp
Commit.exec temp (sprintf "Update site (%s)" (now.ToShortDateString()))
Branches.push temp
)
Target.create "All" ignore
Target.create "BuildPackage" ignore
Target.create "BuildSamples" ignore
Target.create "Release" ignore
"Clean"
==> "Restore"
==> "DocsClean"
==> "DocsBuild"
==> "DocsYarnInstall"
"DocsYarnInstall"
==> "DocsRun"
"DocsYarnInstall"
==> "DocsPackage"
==> "DocsPublish"
"Clean"
==> "Restore"
==> "Build"
==> "Nuget"
==> "BuildPackage"
==> "All"
"BuildPackage"
==> "PublishNuget"
==> "GitHubRelease"
==> "Release"
Target.runOrDefault "Build"