forked from fslaborg/Deedle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
331 lines (277 loc) · 12.5 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
319
320
321
322
323
324
325
326
327
328
329
330
331
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#load ".fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#endif
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, NetOffice.Excel, and a Deedle extension
which makes it possible to send Deedle Frames to Excel."""
let deedleExcelTags = "Excel"
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
]
let dotnetSdk = lazy DotNet.install DotNet.Versions.Release_2_1_302
let inline dtntWorkDir wd =
DotNet.Options.lift dotnetSdk.Value
>> DotNet.Options.withWorkingDirectory wd
let inline setSdk arg = DotNet.Options.lift dotnetSdk.Value arg
// 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 _ ->
let fileName = "src/Deedle/Common/AssemblyInfo.fs"
AssemblyInfoFile.createFSharp fileName
[ AssemblyInfo.Title project
AssemblyInfo.Product project
AssemblyInfo.Description summary
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! !!"**/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.CSharp.Tests/Deedle.CSharp.Tests.csproj"
"tests/Deedle.Documentation.Tests/Deedle.Documentation.Tests.fsproj"
"tests/Deedle.PerfTests/Deedle.PerfTests.fsproj"
"tests/Deedle.RPlugin.Tests/Deedle.RPlugin.Tests.fsproj" ]
let testCoreProjs =
[ "tests/Deedle.Tests/Deedle.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.RProvider.Plugin/Deedle.RProvider.Plugin.fsproj"
"src/Deedle.Excel/Deedle.Excel.fsproj" ]
let buildCoreProjs =
[ "src/Deedle/Deedle.fsproj"
"src/Deedle.Excel/Deedle.Excel.fsproj" ]
Target.create "Build" ( fun _ ->
Environment.setEnvironVar "GenerateDocumentationFile" "true"
buildProjs
|> Seq.iter (fun proj ->
DotNet.build ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/p:SourceLinkCreate=true"})
|> setSdk ) proj )
)
Target.create "BuildCore" ( fun _ ->
Environment.setEnvironVar "GenerateDocumentationFile" "true"
buildCoreProjs
|> Seq.iter (fun proj ->
DotNet.build ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/p:SourceLinkCreate=true"})
|> setSdk ) proj )
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete
Target.create "BuildTests" (fun _ ->
testProjs
|> Seq.iter (fun proj ->
DotNet.build ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/v:n"})
|> setSdk ) proj )
)
Target.create "RunTests" (fun _ ->
testProjs
|> Seq.iter (fun proj ->
DotNet.test ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/v:n"})
|> setSdk ) proj )
)
Target.create "BuildCoreTests" (fun _ ->
testCoreProjs
|> Seq.iter (fun proj ->
DotNet.build ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/v:n"})
|> setSdk ) proj )
)
Target.create "RunCoreTests" (fun _ ->
testCoreProjs
|> Seq.iter (fun proj ->
DotNet.test ( fun b ->
b.WithCommon( fun c -> {c with CustomParams = Some "/v:n"})
|> setSdk ) 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"
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
"R.NET.Community", NuGet.GetPackageVersion "packages" "R.NET.Community"
"R.NET.Community.FSharp", NuGet.GetPackageVersion "packages" "R.NET.Community.FSharp"
"RProvider", NuGet.GetPackageVersion "packages" "RProvider" ]
AccessKey = Environment.environVarOrDefault "nugetkey" ""
Publish = Environment.hasEnvironVar "nugetkey" })
("nuget/Deedle.RPlugin.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
"NetOffice.Core", NuGet.GetPackageVersion "packages" "NetOffice.Core"
"NetOffice.Excel", NuGet.GetPackageVersion "packages" "NetOffice.Core" ]
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"; }) "docs/tools/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/*.nupkg" |> File.deleteAll
"temp/release/bin/Deedle.fsx" |> Shell.moveFile "temp/release"
"temp/release/bin/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
Target.create "AllCore" ignore
"Clean"
==> "AssemblyInfo"
==> "Build"
==> "All"
"AssemblyInfo"
==> "BuildCore"
==> "AllCore"
"BuildTests" ==> "All"
"RunTests" ==> "All"
"BuildCoreTests" ==> "AllCore"
"RunCoreTests" ==> "AllCore"
"All" ==> "NuGet" ==> "Release"
"All"
==> "CleanDocs"
==> "GenerateDocs"
==> "ReleaseDocs"
==> "ReleaseBinaries"
==> "TagRelease"
==> "Release"
Target.runOrDefault "AllCore"