-
Notifications
You must be signed in to change notification settings - Fork 525
/
build.fsx
731 lines (597 loc) · 24.7 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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
#r @"packages/build/FAKE/tools/FakeLib.dll"
#r "System.IO.Compression.FileSystem"
#r "System.Xml.Linq"
open Fake
open Fake.Git
open Fake.ReleaseNotesHelper
open Fake.UserInputHelper
open System
open System.IO
open Fake.Testing.NUnit3
open System.Security.Cryptography
open System.Xml.Linq
// Information about the project are used
// - for version and project name in generated AssemblyInfo file
// - by the generated NuGet package
// - to run tests and to publish documentation on GitHub gh-pages
// - for documentation, you also need to edit info in "docs/tools/generate.fsx"
// The name of the project
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
let project = "Paket"
// Short summary of the project
// (used as description in AssemblyInfo and as a short summary for NuGet package)
let summary = "A dependency manager for .NET with support for NuGet packages and git repositories."
// Longer description of the project
// (used as a description for NuGet package; line breaks are automatically cleaned up)
let description = "A dependency manager for .NET with support for NuGet packages and git repositories."
// List of author names (for NuGet package)
let authors = [ "Paket team" ]
// Tags for your project (for NuGet package)
let tags = "nuget, bundler, F#"
// File system information
let solutionFile = "Paket.sln"
// Pattern specifying assemblies to be tested using NUnit
let testAssemblies = "tests/**/bin/Release/net461/*Tests*.dll"
let integrationTestAssemblies = "integrationtests/Paket.IntegrationTests/bin/Release/net461/*Tests*.dll"
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "fsprojects"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "Paket"
// The url for the raw files hosted
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/fsprojects"
let dotnetcliVersion = DotNetCli.GetDotNetSDKVersionFromGlobalJson()
let mutable dotnetExePath = "dotnet"
// --------------------------------------------------------------------------------------
// END TODO: The rest of the file includes standard build steps
// --------------------------------------------------------------------------------------
let buildDir = "bin"
let buildDirNet461 = buildDir @@ "net461"
let buildDirNet = buildDir @@ "net8"
let buildDirBootstrapper = "bin_bootstrapper"
let buildDirBootstrapperNet461 = buildDirBootstrapper @@ "net461"
let buildDirBootstrapperNet = buildDirBootstrapper @@ "net8"
let tempDir = "temp"
let buildMergedDir = buildDir @@ "merged"
let paketFile = buildMergedDir @@ "paket.exe"
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
System.Net.ServicePointManager.SecurityProtocol <- unbox 192 ||| unbox 768 ||| unbox 3072 ||| unbox 48
// Read additional information from the release notes document
let releaseNotesData =
File.ReadAllLines "RELEASE_NOTES.md"
|> parseAllReleaseNotes
let release = List.head releaseNotesData
let stable =
match releaseNotesData |> List.tryFind (fun r -> r.NugetVersion.Contains("-") |> not) with
| Some stable -> stable
| _ -> release
let runDotnet workingDir args =
let result =
ExecProcess (fun info ->
info.FileName <- dotnetExePath
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if result <> 0 then
failwithf "dotnet %s failed" args
let testSuiteFilterFlakyTests = getEnvironmentVarAsBoolOrDefault "PAKET_TESTSUITE_FLAKYTESTS" false
Target "InstallDotNetCore" (fun _ ->
dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
Environment.SetEnvironmentVariable("DOTNET_EXE_PATH", dotnetExePath)
)
// --------------------------------------------------------------------------------------
// Clean build results
Target "Clean" (fun _ ->
!! "src/**/bin"
++ "tests/**/bin"
++ buildDir
++ buildDirNet461
++ buildDirNet
++ buildDirBootstrapper
++ buildDirBootstrapperNet461
++ buildDirBootstrapperNet
++ tempDir
|> CleanDirs
!! "**/obj/**/*.nuspec"
|> DeleteFiles
)
Target "CleanDocs" (fun _ ->
CleanDirs ["docs/output"]
)
// --------------------------------------------------------------------------------------
// Build library & test project
let releaseNotesProp releaseNotesLines =
let xn name = XName.Get(name)
let text = releaseNotesLines |> String.concat Environment.NewLine
let doc =
XDocument(
[ XComment("This document was automatically generated.") :> obj
XElement(xn "Project",
XElement(xn "PropertyGroup",
XElement(xn "PackageReleaseNotes", text)
)
) :> obj ]
)
let path = Path.GetTempFileName()
doc.Save(path)
path
let releaseNotesPath = releaseNotesProp release.Notes
let packageProps = [
sprintf "/p:Version=%s" release.NugetVersion
sprintf "/p:PackageReleaseNotesFile=\"%s\"" releaseNotesPath
]
Target "Build" (fun _ ->
DotNetCli.Build (fun c ->
{ c with
Project = solutionFile
ToolPath = dotnetExePath
AdditionalArgs = packageProps
})
)
Target "Restore" (fun _ ->
DotNetCli.RunCommand (fun c ->
{ c with
ToolPath = dotnetExePath
}) "tool restore"
DotNetCli.Restore (fun c ->
{ c with
Project = "Paket.sln"
ToolPath = dotnetExePath
})
)
Target "Publish" (fun _ ->
let publishArgs =
[
"--no-build"
] // since no build, we have to ensure that the build sets assemblyinfo correctly, especially because the publish output of this step
// is used in the ILRepack of the .net executable
DotNetCli.Publish (fun c ->
{ c with
Project = "src/Paket"
Framework = "net461"
Output = FullName (currentDirectory </> buildDirNet461)
ToolPath = dotnetExePath
AdditionalArgs = publishArgs
})
DotNetCli.Publish (fun c ->
{ c with
Project = "src/Paket"
Framework = "net8"
Output = FullName (currentDirectory </> buildDirNet)
ToolPath = dotnetExePath
AdditionalArgs = publishArgs
})
DotNetCli.Publish (fun c ->
{ c with
Project = "src/Paket.Bootstrapper"
Framework = "net461"
Output = FullName (currentDirectory </> buildDirBootstrapperNet461)
ToolPath = dotnetExePath
AdditionalArgs = publishArgs
})
DotNetCli.Publish (fun c ->
{ c with
Project = "src/Paket.Bootstrapper"
Framework = "net8"
Output = FullName (currentDirectory </> buildDirBootstrapperNet)
ToolPath = dotnetExePath
AdditionalArgs = publishArgs
})
)
"Clean" ==> "Build" ?=> "Publish"
// --------------------------------------------------------------------------------------
// Run the unit tests
Target "RunTests" (fun _ ->
let runTest fw proj tfm =
CreateDir (sprintf "tests_result/%s/%s" fw proj)
let logFilePath = (sprintf "tests_result/%s/%s/TestResult.trx" fw proj) |> Path.GetFullPath
DotNetCli.Test (fun c ->
{ c with
Project = "tests/Paket.Tests/Paket.Tests.fsproj"
Framework = tfm
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
sprintf "--logger:trx;LogFileName=%s" logFilePath
"--no-build"
"-v"; "n"]
ToolPath = dotnetExePath
})
runTest "net" "Paket.Tests" "net461"
runTest "netcore" "Paket.Tests" "net8"
runTest "net" "Paket.Bootstrapper.Tests" "net461"
runTest "netcore" "Paket.Bootstrapper.Tests" "net8"
)
Target "QuickTest" (fun _ ->
DotNetCli.Test (fun c ->
{ c with
Project = "tests/Paket.Tests/Paket.Tests.fsproj"
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky") ]
ToolPath = dotnetExePath
})
)
"Clean" ==> "QuickTest"
Target "QuickIntegrationTests" (fun _ ->
DotNetCli.Test (fun c ->
{ c with
Project = "integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj"
AdditionalArgs =
[ "--filter"; "TestCategory=scriptgen" ]
TimeOut = TimeSpan.FromMinutes 40.
ToolPath = dotnetExePath
})
)
"Clean" ==> "Publish" ==> "QuickIntegrationTests"
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target "MergePaketTool" (fun _ ->
CreateDir buildMergedDir
let inBuildDirNet461 (file: string) = buildDirNet461 @@ file
// syntax for ilrepack requires the 'primary' assembly to be the first positional argument, so we enforce that by not making
// paket.exe part of the ordered 'component' libraries
let primaryExe = inBuildDirNet461 "paket.exe"
let mergeLibs =
[
"Argu.dll"
"Chessie.dll"
"Fake.Core.ReleaseNotes.dll"
"FSharp.Core.dll"
"Mono.Cecil.dll"
"Newtonsoft.Json.dll"
"NuGet.Common.dll"
"NuGet.Configuration.dll"
"NuGet.Frameworks.dll"
"NuGet.Packaging.dll"
"NuGet.Versioning.dll"
"Paket.Core.dll"
"System.Buffers.dll"
"System.Configuration.ConfigurationManager.dll"
"System.Memory.dll"
"System.Net.Http.WinHttpHandler.dll"
"System.Numerics.Vectors.dll"
"System.Runtime.CompilerServices.Unsafe.dll"
"System.Security.Cryptography.Cng.dll"
"System.Security.Cryptography.Pkcs.dll"
"System.Threading.Tasks.Extensions.dll"
]
|> List.map inBuildDirNet461
|> separated " "
let result =
ExecProcess (fun info ->
info.FileName <- currentDirectory </> "packages" </> "build" </> "ILRepack" </> "tools" </> "ILRepack.exe"
info.Arguments <- sprintf "/copyattrs /lib:%s /ver:%s /out:%s %s %s" buildDirNet461 release.AssemblyVersion paketFile primaryExe mergeLibs
) (TimeSpan.FromMinutes 5.)
if result <> 0 then failwithf "Error during ILRepack execution."
)
"Publish" ==> "MergePaketTool"
Target "RunIntegrationTestsNet" (fun _ ->
CreateDir "tests_result/net/Paket.IntegrationTests"
// improves the speed of the test-suite by disabling the runtime resolution.
System.Environment.SetEnvironmentVariable("PAKET_DISABLE_RUNTIME_RESOLUTION", "true")
DotNetCli.Test (fun c ->
{ c with
Project = "integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj"
Framework = "net461"
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
sprintf "--logger:trx;LogFileName=%s" ("tests_result/net/Paket.IntegrationTests/TestResult.trx" |> Path.GetFullPath) ]
TimeOut = TimeSpan.FromMinutes 60.
ToolPath = dotnetExePath
})
)
"Clean" ==> "Publish" ==> "RunIntegrationTestsNet"
Target "RunIntegrationTestsNetCore" (fun _ ->
CreateDir "tests_result/netcore/Paket.IntegrationTests"
// improves the speed of the test-suite by disabling the runtime resolution.
System.Environment.SetEnvironmentVariable("PAKET_DISABLE_RUNTIME_RESOLUTION", "true")
DotNetCli.Test (fun c ->
{ c with
Project = "integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj"
Framework = "net8"
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
sprintf "--logger:trx;LogFileName=%s" ("tests_result/netcore/Paket.IntegrationTests/TestResult.trx" |> Path.GetFullPath) ]
TimeOut = TimeSpan.FromMinutes 60.
ToolPath = dotnetExePath
})
)
"Clean" ==> "Publish" ==> "RunIntegrationTestsNetCore"
let pfx = "code-sign.pfx"
let mutable isUnsignedAllowed = true
Target "EnsurePackageSigned" (fun _ -> isUnsignedAllowed <- false)
Target "SignAssemblies" (fun _ ->
// if not <| fileExists pfx then
// if isUnsignedAllowed then ()
// else failwithf "%s not found, can't sign assemblies" pfx
// else
// let filesToSign =
// !! "bin/**/*.exe"
// ++ "bin/**/Paket.Core.dll"
// ++ "bin_bootstrapper/**/*.exe"
// |> Seq.cache
// if Seq.length filesToSign < 3 then failwith "Didn't find files to sign"
// match getBuildParam "cert-pw" with
// | pw when not (String.IsNullOrWhiteSpace pw) ->
// filesToSign
// |> Seq.iter (fun executable ->
// let signtool = currentDirectory @@ "tools" @@ "SignTool" @@ "signtool.exe"
// let args = sprintf "sign /f %s /p \"%s\" /t http://timestamp.comodoca.com/authenticode %s" pfx pw executable
// let result =
// ExecProcess (fun info ->
// info.FileName <- signtool
// info.Arguments <- args) System.TimeSpan.MaxValue
// if result <> 0 then failwithf "Error during signing %s with %s" executable pfx)
// | _ -> failwith "PW for cert missing"
()
)
Target "CalculateDownloadHash" (fun _ ->
use stream = File.OpenRead(paketFile)
use sha = new SHA256Managed()
let checksum = sha.ComputeHash(stream)
let hash = BitConverter.ToString(checksum).Replace("-", String.Empty)
File.WriteAllText(buildMergedDir @@ "paket-sha256.txt", sprintf "%s paket.exe" hash)
)
Target "AddIconToExe" (fun _ ->
// add icon to paket.exe
// workaround https://github.com/dotnet/fsharp/issues/1172
let paketExeIcon = "src" @@ "Paket" @@ "paket.ico"
// use resourcehacker to add the icon
let rhPath = "paket-files" @@ "build" @@ "enricosada" @@ "add_icon_to_exe" @@ "rh" @@ "ResourceHacker.exe"
let args = sprintf """-open "%s" -save "%s" -action addskip -res "%s" -mask ICONGROUP,MAINICON,""" paketFile paketFile paketExeIcon
let result =
ExecProcess (fun info ->
info.FileName <- rhPath
info.Arguments <- args) (TimeSpan.FromMinutes 1.)
if result <> 0 then failwithf "Error during adding icon %s to %s with %s %s" paketExeIcon paketFile rhPath args
)
Target "NuGet" (fun _ ->
DotNetCli.Pack (fun c ->
{ c with
Project = "src/Paket.Core/Paket.Core.fsproj"
OutputPath = tempDir
AdditionalArgs = packageProps
ToolPath = dotnetExePath
})
DotNetCli.Pack (fun c ->
{ c with
Project = "src/Paket/Paket.fsproj"
OutputPath = tempDir
AdditionalArgs = packageProps @ [ "/p:PackAsTool=true" ]
ToolPath = dotnetExePath
})
DotNetCli.Pack (fun c ->
{ c with
Project = "src/Paket.Bootstrapper/Paket.Bootstrapper.csproj"
OutputPath = tempDir
AdditionalArgs = packageProps @ [ "/p:PackAsTool=true" ]
ToolPath = dotnetExePath
})
DotNetCli.Pack (fun c ->
{ c with
Project = "src/FSharp.DependencyManager.Paket/FSharp.DependencyManager.Paket.fsproj"
OutputPath = tempDir
AdditionalArgs = packageProps
ToolPath = dotnetExePath
})
)
Target "PublishNuGet" (fun _ ->
if hasBuildParam "PublishBootstrapper" |> not then
!! (tempDir </> "*bootstrapper*")
|> Seq.iter File.Delete
Paket.Push (fun p ->
{ p with
ToolPath = "bin/merged/paket.exe"
ApiKey = getBuildParam "NugetKey"
WorkingDir = tempDir })
)
// --------------------------------------------------------------------------------------
// Generate the documentation
let disableDocs = false // https://github.com/fsprojects/FSharp.Formatting/issues/461
let fakePath = __SOURCE_DIRECTORY__ @@ "packages" @@ "build" @@ "FAKE" @@ "tools" @@ "FAKE.exe"
let fakeStartInfo fsiargs script workingDirectory args environmentVars =
(fun (info: System.Diagnostics.ProcessStartInfo) ->
info.FileName <- fakePath
info.Arguments <- sprintf "%s --fsiargs %s -d:FAKE \"%s\"" args fsiargs script
info.WorkingDirectory <- workingDirectory
let setVar k v =
info.EnvironmentVariables.[k] <- v
for (k, v) in environmentVars do
setVar k v
setVar "MSBuild" msBuildExe
setVar "GIT" Git.CommandHelper.gitPath
setVar "FSI" fsiPath)
/// Run the given startinfo by printing the output (live)
let executeWithOutput configStartInfo =
let exitCode =
ExecProcessWithLambdas
configStartInfo
TimeSpan.MaxValue false ignore ignore
System.Threading.Thread.Sleep 1000
exitCode
/// Run the given startinfo by redirecting the output (live)
let executeWithRedirect errorF messageF configStartInfo =
let exitCode =
ExecProcessWithLambdas
configStartInfo
TimeSpan.MaxValue true errorF messageF
System.Threading.Thread.Sleep 1000
exitCode
/// Helper to fail when the exitcode is <> 0
let executeHelper executer fail traceMsg failMessage configStartInfo =
trace traceMsg
let exit = executer configStartInfo
if exit <> 0 then
if fail then
failwith failMessage
else
traceImportant failMessage
else
traceImportant "Succeeded"
()
let execute = executeHelper executeWithOutput
Target "GenerateReferenceDocs" (fun _ ->
if disableDocs then () else
let args = ["--define:RELEASE"; "--define:REFERENCE"]
let argLine = System.String.Join(" ", args)
execute
true
(sprintf "Building reference documentation, this could take some time, please wait...")
"generating reference documentation failed"
(fakeStartInfo argLine "generate.fsx" "docs/tools" "" [])
)
let generateHelp' commands fail debug =
// remove FSharp.Compiler.Service.MSBuild.v12.dll
// otherwise FCS thinks it should use msbuild, which leads to insanity
!! "packages/**/FSharp.Compiler.Service.MSBuild.*.dll"
|> DeleteFiles
let args =
[ if not debug then yield "--define:RELEASE"
if commands then yield "--define:COMMANDS"
yield "--define:HELP"]
let argLine = System.String.Join(" ", args)
execute
fail
(sprintf "Building documentation (%A), this could take some time, please wait..." commands)
"generating documentation failed"
(fakeStartInfo argLine "generate.fsx" "docs/tools" "" [])
CleanDir "docs/output/commands"
let generateHelp commands fail =
generateHelp' commands fail false
Target "GenerateHelp" (fun _ ->
if disableDocs then () else
DeleteFile "docs/content/release-notes.md"
CopyFile "docs/content/" "RELEASE_NOTES.md"
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
DeleteFile "docs/content/license.md"
CopyFile "docs/content/" "LICENSE.txt"
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
generateHelp true true
)
Target "GenerateHelpDebug" (fun _ ->
if disableDocs then () else
DeleteFile "docs/content/release-notes.md"
CopyFile "docs/content/" "RELEASE_NOTES.md"
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
DeleteFile "docs/content/license.md"
CopyFile "docs/content/" "LICENSE.txt"
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
generateHelp' true true true
)
Target "KeepRunning" (fun _ ->
use watcher = !! "docs/content/**/*.*" |> WatchChanges (fun changes ->
generateHelp false false
)
traceImportant "Waiting for help edits. Press any key to stop."
System.Console.ReadKey() |> ignore
watcher.Dispose()
)
Target "GenerateDocs" DoNothing
// --------------------------------------------------------------------------------------
// Release Scripts
Target "ReleaseDocs" (fun _ ->
if disableDocs then () else
let tempDocsDir = "temp/gh-pages"
CleanDir tempDocsDir
Repository.cloneSingleBranch "" "[email protected]:fsprojects/Paket.git" "gh-pages" tempDocsDir
Git.CommandHelper.runSimpleGitCommand tempDocsDir "rm . -f -r" |> ignore
CopyRecursive "docs/output" tempDocsDir true |> tracefn "%A"
File.WriteAllText("temp/gh-pages/latest",sprintf "https://github.com/fsprojects/Paket/releases/download/%s/paket.exe" release.NugetVersion)
File.WriteAllText("temp/gh-pages/stable",sprintf "https://github.com/fsprojects/Paket/releases/download/%s/paket.exe" stable.NugetVersion)
StageAll tempDocsDir
Git.Commit.Commit tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
Branches.push tempDocsDir
)
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit
Target "ReleaseGitHub" (fun _ ->
let user =
match getBuildParam "github_user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ ->
eprintfn "Please update your release script to set 'github_user'!"
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github_password" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ ->
eprintfn "Please update your release script to set 'github_password'!"
match getBuildParam "github_pw", getBuildParam "github-pw" with
| s, _ | _, s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "
let remote =
Git.CommandHelper.getGitResult "" "remote -v"
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Branches.pushBranch "" remote (Information.getBranchName "")
Branches.tag "" release.NugetVersion
Branches.pushTag "" remote release.NugetVersion
tracefn "Creating gihub release"
// release on github
createClient user pw
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> uploadFile "./bin/merged/paket.exe"
|> uploadFile "./bin/merged/paket-sha256.txt"
|> uploadFile "./src/FSharp.DependencyManager.Paket/bin/Release/netstandard2.0/FSharp.DependencyManager.Paket.dll"
|> uploadFile "./bin_bootstrapper/net461/paket.bootstrapper.exe"
|> uploadFile ".paket/paket.targets"
|> uploadFile ".paket/Paket.Restore.targets"
|> uploadFile (tempDir </> sprintf "Paket.%s.nupkg" (release.NugetVersion))
|> uploadFile (tempDir </> sprintf "FSharp.DependencyManager.Paket.%s.nupkg" (release.NugetVersion))
|> releaseDraft
|> Async.RunSynchronously
)
Target "Release" DoNothing
Target "BuildPackage" DoNothing
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
let hasBuildParams buildParams =
buildParams
|> List.map hasBuildParam
|> List.exists id
let unlessBuildParams buildParams =
not (hasBuildParams buildParams)
Target "All" DoNothing
"Clean"
==> "InstallDotNetCore"
==> "Restore"
==> "Build"
==> "Publish"
=?> ("RunTests", unlessBuildParams [ "SkipTests"; "SkipUnitTests" ])
=?> ("GenerateReferenceDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
=?> ("GenerateDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
==> "All"
=?> ("ReleaseDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
"All"
==> "MergePaketTool"
=?> ("AddIconToExe", not isMono)
=?> ("RunIntegrationTestsNet", unlessBuildParams [ "SkipTests"; "SkipIntegrationTests"; "SkipIntegrationTestsNet" ] )
=?> ("RunIntegrationTestsNetCore", unlessBuildParams [ "SkipTests"; "SkipIntegrationTests"; "SkipIntegrationTestsNetCore" ] )
==> "SignAssemblies"
==> "CalculateDownloadHash"
=?> ("NuGet", unlessBuildParams [ "SkipNuGet" ])
==> "BuildPackage"
"EnsurePackageSigned"
?=> "SignAssemblies"
"CleanDocs"
==> "GenerateHelp"
==> "GenerateReferenceDocs"
==> "GenerateDocs"
"CleanDocs"
==> "GenerateHelpDebug"
"GenerateHelp"
==> "KeepRunning"
"BuildPackage"
==> "PublishNuGet"
"ReleaseGitHub"
==> "ReleaseDocs"
==> "PublishNuGet"
==> "Release"
"EnsurePackageSigned"
==> "Release"
RunTargetOrDefault "All"