-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.fsx
executable file
·136 lines (109 loc) · 3.99 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
131
132
133
134
135
136
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.Core.ReleaseNotes"
#r "nuget: Fake.Tools.Git"
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.Tools
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open System
open System.IO
let gitName = "urlParser"
let gitOwner = "elmish"
let gitHome = sprintf "https://github.com/%s" gitOwner
let gitRepo = sprintf "[email protected]:%s/%s.git" gitOwner gitName
// Filesets
let projects =
!! "src/**.fsproj"
++ "netstandard/**.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 "src/obj"
Shell.cleanDir "src/bin"
Shell.cleanDir "netstandard/obj"
Shell.cleanDir "netstandard/bin"
)
Target.create "Restore" (fun _ ->
projects
|> Seq.iter (Path.GetDirectoryName >> DotNet.restore id)
)
Target.create "Build" (fun _ ->
projects
|> Seq.iter (Path.GetDirectoryName >> DotNet.build id)
)
Target.create "Test" (fun _ ->
DotNet.test (fun a -> a.WithCommon id) "tests"
)
let release = ReleaseNotes.load "RELEASE_NOTES.md"
Target.create "Meta" (fun _ ->
[ "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
"<PropertyGroup>"
"<Description>UrlParser for Elmish apps</Description>"
sprintf "<PackageProjectUrl>http://%s.github.io/%s</PackageProjectUrl>" gitOwner gitName
"<PackageLicenseUrl>https://raw.githubusercontent.com/elmish/urlParser/master/LICENSE.md</PackageLicenseUrl>"
"<PackageIconUrl>https://raw.githubusercontent.com/elmish/elmish/master/docs/files/img/logo.png</PackageIconUrl>"
sprintf "<RepositoryUrl>%s/%s</RepositoryUrl>" gitHome gitName
"<PackageTags>fable;elmish;fsharp</PackageTags>"
sprintf "<PackageReleaseNotes>%s</PackageReleaseNotes>" (List.head release.Notes)
"<Authors>Eugene Tolmachev</Authors>"
sprintf "<Version>%s</Version>" (string release.SemVer)
"</PropertyGroup>"
"</Project>"]
|> File.write false "Directory.Build.props"
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target.create "Package" (fun _ ->
projects
|> Seq.iter (Path.GetDirectoryName >> DotNet.pack id)
)
Target.create "PublishNuget" (fun _ ->
let exec dir = DotNet.exec (DotNet.Options.withWorkingDirectory dir)
let args = sprintf "push Fable.Elmish.UrlParser.%s.nupkg -s nuget.org -k %s" (string release.SemVer) (Environment.environVar "nugetkey")
let result = exec "src/bin/Release" "nuget" args
if (not result.OK) then failwithf "%A" result.Errors
let args = sprintf "push Elmish.UrlParser.%s.nupkg -s nuget.org -k %s" (string release.SemVer) (Environment.environVar "nugetkey")
let result = exec "netstandard/bin/Release" "nuget" args
if (not result.OK) then failwithf "%A" result.Errors
)
// --------------------------------------------------------------------------------------
// Generate the documentation
Target.create "GenerateDocs" (fun _ ->
let res = Shell.Exec("npm", "run docs:build")
if res <> 0 then
failwithf "Failed to generate docs"
)
Target.create "WatchDocs" (fun _ ->
let res = Shell.Exec("npm", "run docs:watch")
if res <> 0 then
failwithf "Failed to watch docs: %d" res
)
// --------------------------------------------------------------------------------------
// Release Scripts
Target.create "ReleaseDocs" (fun _ ->
let res = Shell.Exec("npm", "run docs:publish")
if res <> 0 then
failwithf "Failed to publish docs: %d" res
)
Target.create "Publish" ignore
// Build order
"Clean"
==> "Meta"
==> "Restore"
==> "Build"
==> "Test"
==> "Package"
==> "PublishNuget"
==> "Publish"
// start build
Target.runOrDefault "Test"