forked from elmish/elmish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
executable file
·147 lines (119 loc) · 4.57 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
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.Core.Target"
#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
// Filesets
let projects =
!! "src/**.fsproj"
++ "netstandard/**.fsproj"
++ "websharper/**.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"
Shell.cleanDir "websharper/obj"
Shell.cleanDir "websharper/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\">"
"<ItemGroup>"
"<None Include=\"../docs/static/img/logo.png\" Pack=\"true\" PackagePath=\"\\\"/>"
"<PackageReference Include=\"Microsoft.SourceLink.GitHub\" Version=\"1.0.0\" PrivateAssets=\"All\"/>"
"</ItemGroup>"
"<PropertyGroup>"
"<EmbedUntrackedSources>true</EmbedUntrackedSources>"
"<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>"
"<PackageProjectUrl>https://github.com/elmish/elmish</PackageProjectUrl>"
"<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>"
"<PackageIconUrl>https://raw.githubusercontent.com/elmish/elmish/master/docs/files/img/logo.png</PackageIconUrl>"
"<PackageIcon>logo.png</PackageIcon>"
"<RepositoryUrl>https://github.com/elmish/elmish.git</RepositoryUrl>"
sprintf "<PackageReleaseNotes>%s</PackageReleaseNotes>" (List.head release.Notes)
"<PackageTags>MVU;fsharp</PackageTags>"
"<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.%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 WebSharper.Elmish.%s.nupkg -s nuget.org -k %s" (string release.SemVer) (Environment.environVar "nugetkey")
let result = exec "websharper/bin/Release" "nuget" args
if (not result.OK) then failwithf "%A" result.Errors
let args = sprintf "push Elmish.%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"