forked from fslaborg/Deedle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
318 lines (271 loc) · 12.9 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.Tools
open Fake.DotNet
open Fake.BuildServer
open Fake.IO
open Fake.DotNet.NuGet
open Fake.Core.TargetOperators
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open System
// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet and in AssemblyInfo files
// --------------------------------------------------------------------------------------
let project = "Deedle"
let authors = ["BlueMountain Capital";"FsLab"]
let summary = "Easy to use .NET library for data manipulation and scientific programming"
let description = """
Deedle implements an efficient and robust frame and series data structures for
manipulating with structured data. It supports handling of missing values,
aggregations, grouping, joining, statistical functions and more. For frames and
series with ordered indices (such as time series), automatic alignment is also
available. """
let tags = "F# fsharp deedle dataframe series statistics data science"
let rpluginProject = "Deedle.RPlugin"
let rpluginSummary = "Easy to use .NET library for data manipulation with R project integration"
let rpluginDescription = """
This package installs core Deedle package, together with an R type provider plugin
which makes it possible to pass data frames and time series between R and Deedle"""
let rpluginTags = "R RProvider"
let deedleExcelProject = "Deedle.Excel"
let deedleExcelSummary = "Deedle integration with Excel"
let deedleExcelDescription = """
This package installs the core Deedle package, NetOfficeFw.Excel, and a Deedle extension
which makes it possible to send Deedle Frames to Excel."""
let deedleExcelTags = "Excel"
let deedleMathProject = "Deedle.Math"
let deedleMathSummary = "Deedle interop with Math.Net"
let deedleMathDescription = """
This package installs the core Deedle package, Deedle.Math extension and Mathnet.Numerics
to extend mathematic functions on Deedle Frames and Series."""
let deedleMathTags = "F# fsharp deedle dataframe series statistics data science math quantitative finance"
let gitHome = "https://github.com/fslaborg"
let gitName = "Deedle"
let bindir = "./bin"
let docsDir = "./docs"
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
BuildServer.install [
AppVeyor.Installer
Travis.Installer
]
// Read release notes & version info from RELEASE_NOTES.md
let release = ReleaseNotes.load "RELEASE_NOTES.md"
// Generate assembly info files with the right version & up-to-date information
Target.create "AssemblyInfo" (fun _ ->
AssemblyInfoFile.createFSharp "src/Deedle/Common/AssemblyInfo.fs"
[ AssemblyInfo.Title project
AssemblyInfo.Product project
AssemblyInfo.Description summary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.FileVersion release.AssemblyVersion]
AssemblyInfoFile.createFSharp "src/Deedle.RProvider.Plugin/AssemblyInfo.fs"
[ AssemblyInfo.Title rpluginProject
AssemblyInfo.Product rpluginProject
AssemblyInfo.Description rpluginSummary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.FileVersion release.AssemblyVersion]
AssemblyInfoFile.createFSharp "src/Deedle.Excel/AssemblyInfo.fs"
[ AssemblyInfo.Title deedleExcelProject
AssemblyInfo.Product deedleExcelProject
AssemblyInfo.Description deedleExcelSummary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.FileVersion release.AssemblyVersion]
AssemblyInfoFile.createFSharp "src/Deedle.Math/AssemblyInfo.fs"
[ AssemblyInfo.Title deedleMathProject
AssemblyInfo.Product deedleMathProject
AssemblyInfo.Description deedleMathSummary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.FileVersion release.AssemblyVersion]
)
// --------------------------------------------------------------------------------------
// Clean build results
Target.create "Clean" ( fun _ ->
// have to clean netcore output directories because they corrupt the full-framework outputs
seq {
yield bindir
yield "./temp"
yield! !!"**/bin"
yield! !!"**/obj"
} |> Shell.cleanDirs
)
Target.create "CleanDocs" (fun _ ->
Shell.cleanDirs ["docs/output"]
)
// --------------------------------------------------------------------------------------
// Build library & test project
let testProjs =
[
"tests/Deedle.Tests/Deedle.Tests.fsproj"
"tests/Deedle.Math.Tests/Deedle.Math.Tests.fsproj"
"tests/Deedle.CSharp.Tests/Deedle.CSharp.Tests.csproj"
// "tests/Deedle.Documentation.Tests/Deedle.Documentation.Tests.fsproj"
"tests/Deedle.PerfTests/Deedle.PerfTests.fsproj"
]
let buildProjs =
[ "src/Deedle/Deedle.fsproj"
"src/Deedle.Math/Deedle.Math.fsproj"
"src/Deedle.Excel/Deedle.Excel.fsproj"
"src/Deedle.RProvider.Plugin/Deedle.RProvider.Plugin.fsproj" ]
Target.create "Build" ( fun _ ->
Environment.setEnvironVar "GenerateDocumentationFile" "true"
for proj in buildProjs do
DotNet.build (fun opts -> { opts with Common = { opts.Common with
CustomParams = Some "/v:n /p:SourceLinkCreate=true" }
Configuration = DotNet.BuildConfiguration.Release }) proj )
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete
Target.create "BuildTests" (fun _ ->
for proj in testProjs do
DotNet.build (fun opts -> { opts with Configuration = DotNet.BuildConfiguration.Release }) proj )
Target.create "RunTests" (fun _ ->
for proj in testProjs do
DotNet.test (fun opts -> { opts with Configuration = DotNet.BuildConfiguration.Release }) proj )
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target.create "NuGet" (fun _ ->
// Format the description to fit on a single line (remove \r\n and double-spaces)
let description = description.Replace("\r", "").Replace("\n", "").Replace(" ", " ")
let rpluginDescription = rpluginDescription.Replace("\r", "").Replace("\n", "").Replace(" ", " ")
let releaseNotes = release.Notes |> String.concat "\n"
let nugetExe = "packages" </> "build" </> "NuGet.CommandLine" </> "tools" </> "NuGet.exe"
NuGet.NuGetPack (fun p ->
{ p with
ToolPath = nugetExe
Authors = authors
Project = project
Summary = summary
Description = description
Version = release.NugetVersion
ReleaseNotes = releaseNotes
Tags = tags
OutputPath = "bin"
Dependencies = [ "FSharp.Core", NuGet.GetPackageVersion "packages" "FSharp.Core" ]
AccessKey = Environment.environVarOrDefault "nugetkey" ""
Publish = Environment.hasEnvironVar "nugetkey" })
("nuget/Deedle.nuspec")
NuGet.NuGetPack (fun p ->
{ p with
ToolPath = nugetExe
Authors = authors
Project = rpluginProject
Summary = rpluginSummary
Description = description + "\n\n" + rpluginDescription
Version = release.NugetVersion
ReleaseNotes = releaseNotes
Tags = tags + " " + rpluginTags
OutputPath = "bin"
Dependencies =
[ "Deedle", release.NugetVersion
"RProvider", NuGet.GetPackageVersion "packages/rproviderplugin" "RProvider" ]
AccessKey = Environment.environVarOrDefault "nugetkey" ""
Publish = Environment.hasEnvironVar "nugetkey" })
("nuget/Deedle.RPlugin.nuspec")
NuGet.NuGetPack (fun p ->
{ p with
ToolPath = nugetExe
Authors = authors
Project = deedleMathProject
Summary = deedleMathSummary
Description = description + "\n\n" + deedleMathDescription
Version = release.NugetVersion
ReleaseNotes = releaseNotes
Tags = tags + " " + deedleMathTags
OutputPath = "bin"
Dependencies =
[ "Deedle", release.NugetVersion
"MathNet.Numerics", NuGet.GetPackageVersion "packages" "MathNet.Numerics"
"MathNet.Numerics.FSharp", NuGet.GetPackageVersion "packages" "MathNet.Numerics.FSharp" ]
AccessKey = Environment.environVarOrDefault "nugetkey" ""
Publish = Environment.hasEnvironVar "nugetkey" })
("nuget/Deedle.Math.nuspec")
NuGet.NuGetPack (fun p ->
{ p with
Authors = authors
Project = deedleExcelProject
Summary = deedleExcelSummary
Description = description + "\n\n" + deedleExcelDescription
Version = release.NugetVersion
ReleaseNotes = releaseNotes
Tags = tags + " " + deedleExcelTags
OutputPath = "bin"
Dependencies =
[ "Deedle", release.NugetVersion
"NetOfficeFw.Core", NuGet.GetPackageVersion "packages" "NetOfficeFw.Core"
"NetOfficeFw.Excel", NuGet.GetPackageVersion "packages" "NetOfficeFw.Excel" ]
AccessKey = Environment.environVarOrDefault "nugetkey" ""
Publish = Environment.hasEnvironVar "nugetkey" })
("nuget/Deedle.Excel.nuspec")
)
// --------------------------------------------------------------------------------------
// Generate the documentation
Target.create "GenerateDocs" (fun _ ->
let (exitCode, messages) = Fsi.exec (fun p -> { p with WorkingDirectory="docs/tools"; Define="RELEASE"; }) "generate.fsx" []
if exitCode = 0 then () else
failwith (messages |> String.concat Environment.NewLine)
)
// --------------------------------------------------------------------------------------
// Release Scripts
Target.create "ReleaseDocs" (fun _ ->
Git.Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/gh-pages"
Git.Branches.checkoutBranch "temp/gh-pages" "gh-pages"
Shell.copyRecursive "docs/output" "temp/gh-pages" true |> printfn "%A"
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" release.NugetVersion
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
Git.Branches.push "temp/gh-pages"
)
Target.create "ReleaseBinaries" (fun _ ->
Git.Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/release"
Git.Branches.checkoutBranch "temp/release" "release"
// Delete old files and copy in new files
!! "temp/release/*" |> File.deleteAll
"temp/release/bin" |> Shell.cleanDir
Shell.copyRecursive "bin" "temp/release/bin" true |> printfn "%A"
!! "temp/release/bin/*" |> File.deleteAll
"temp/release/bin/netstandard2.0/Deedle.Math.fsx" |> Shell.moveFile "temp/release"
"temp/release/bin/netstandard2.0/Deedle.fsx" |> Shell.moveFile "temp/release"
"temp/release/bin/net5.0/RProvider.fsx" |> Shell.moveFile "temp/release"
Git.CommandHelper.runSimpleGitCommand "temp/release" "add bin/*" |> printfn "%s"
let cmd = sprintf """commit -a -m "Update binaries for version %s""" release.NugetVersion
Git.CommandHelper.runSimpleGitCommand "temp/release" cmd |> printfn "%s"
Git.Branches.push "temp/release"
)
Target.create "TagRelease" (fun _ ->
// Concatenate notes & create a tag in the local repository
let notes = (String.concat " " release.Notes).Replace("\n", ";").Replace("\r", "")
let tagName = "v" + release.NugetVersion
let cmd = sprintf """tag -a %s -m "%s" """ tagName notes
Git.CommandHelper.runSimpleGitCommand "." cmd |> printfn "%s"
// Find the main remote (fslaborg GitHub)
let _, remotes, _ = Git.CommandHelper.runGitCommand "." "remote -v"
let main = remotes |> Seq.find (fun s -> s.Contains("(push)") && s.Contains("fslaborg/Deedle"))
let remoteName = main.Split('\t').[0]
Git.Branches.pushTag "." remoteName tagName
)
Target.create "Release" ignore
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target.create "All" ignore
"Clean"
==> "AssemblyInfo"
==> "Build"
==> "BuildTests"
==> "RunTests"
==> "All"
"All" ==> "NuGet" ==> "Release"
"All"
==> "CleanDocs"
==> "GenerateDocs"
==> "ReleaseDocs"
==> "ReleaseBinaries"
==> "TagRelease"
==> "Release"
Target.runOrDefault "All"