@@ -111,9 +111,11 @@ let releaseSecret replacement name =
111
111
match getVarOrDefaultFromVault name " default_unset" with
112
112
| " default_unset" -> failwithf " variable '%s ' is not set" name
113
113
| s -> s
114
+
114
115
if BuildServer.buildServer <> BuildServer.TeamFoundation then
115
116
// on TFS/VSTS the build will take care of this.
116
117
TraceSecrets.register replacement env
118
+
117
119
env
118
120
119
121
secrets <- secret :: secrets
@@ -130,10 +132,12 @@ let chocoSource =
130
132
getVarOrDefaultFromVault " CHOCO_SOURCE" " https://push.chocolatey.org/"
131
133
132
134
let artifactsDir = getVarOrDefaultFromVault " ARTIFACTS_DIRECTORY" " "
135
+
133
136
let docsDomain =
134
137
match BuildServer.isLocalBuild with
135
138
| true -> " http://127.0.0.1:8083/"
136
139
| false -> getVarOrDefaultFromVault " DOCS_DOMAIN" " fake.build"
140
+
137
141
let fromArtifacts = not <| String.isNullOrEmpty artifactsDir
138
142
let apiKey = releaseSecret " <nugetkey>" " NUGET_KEY"
139
143
let chocoKey = releaseSecret " <chocokey>" " CHOCOLATEY_API_KEY"
@@ -209,7 +213,9 @@ let version =
209
213
210
214
let d = System.DateTime.Now
211
215
let newLocalVersionNumber = currentVer + 1 I
212
- [ PreReleaseSegment.AlphaNumeric( " local." + newLocalVersionNumber.ToString()) ], d.ToString( " yyyy-MM-dd-HH-mm" )
216
+
217
+ [ PreReleaseSegment.AlphaNumeric( " local." + newLocalVersionNumber.ToString()) ],
218
+ d.ToString( " yyyy-MM-dd-HH-mm" )
213
219
214
220
let semVer = SemVer.parse release.NugetVersion
215
221
@@ -220,11 +226,7 @@ let version =
220
226
221
227
match String.IsNullOrWhiteSpace toAdd with
222
228
| true -> None
223
- | false ->
224
- Some
225
- { Name = " "
226
- Values = source
227
- Origin = toAdd }
229
+ | false -> Some { Name = " " ; Values = source; Origin = toAdd }
228
230
| Some p ->
229
231
let toAdd = String.Join( " ." , source |> Seq.map segToString)
230
232
let toAdd = if String.IsNullOrEmpty toAdd then toAdd else " ." + toAdd
@@ -450,9 +452,14 @@ let rec nugetPush tries nugetPackage =
450
452
try
451
453
if not <| String.IsNullOrEmpty apiKey.Value then
452
454
let quoteString str = sprintf " \" %s \" " str
453
-
454
- let args = sprintf " push %s %s -Source %s " ( quoteString nugetPackage) ( quoteString apiKey.Value) ( quoteString nugetSource)
455
-
455
+
456
+ let args =
457
+ sprintf
458
+ " push %s %s -Source %s "
459
+ ( quoteString nugetPackage)
460
+ ( quoteString apiKey.Value)
461
+ ( quoteString nugetSource)
462
+
456
463
let errors = System.Collections.Generic.List< string>()
457
464
let results = System.Collections.Generic.List< string>()
458
465
@@ -470,22 +477,24 @@ let rec nugetPush tries nugetPackage =
470
477
|> CreateProcess.redirectOutput
471
478
|> CreateProcess.withOutputEventsNotNull errorF messageF
472
479
|> Proc.run
473
-
480
+
474
481
if processResult.ExitCode <> 0 then
475
482
if
476
483
not ignore_ conflict
477
484
|| not ( errors |> Seq.exists ( fun err -> err.Contains " 409" ))
478
485
then
479
486
let msgs =
480
- errors |> Seq.map ( fun c -> " (Err) " + c)
481
- |> Seq.append results |> Seq.map ( fun c -> c)
487
+ errors
488
+ |> Seq.map ( fun c -> " (Err) " + c)
489
+ |> Seq.append results
490
+ |> Seq.map ( fun c -> c)
482
491
483
492
let msg = String.Join( " \n " , msgs)
484
493
485
494
failwithf " failed to push package %s (code %d ): \n %s " nugetPackage processResult.ExitCode msg
486
495
else
487
496
Trace.traceFAKE " ignore conflict error because IGNORE_CONFLICT=true!"
488
-
497
+
489
498
else
490
499
Trace.traceFAKE " could not push '%s ', because api key was not set" nugetPackage
491
500
with exn when tries > 1 ->
@@ -521,9 +530,7 @@ Target.create "Clean" (fun _ ->
521
530
Shell.rm ( " paket-files" </> " paket.restore.cached" )
522
531
callPaket " ." " restore"
523
532
524
- Shell.cleanDirs
525
- [ nugetDncDir
526
- collectedArtifactsDir ]
533
+ Shell.cleanDirs [ nugetDncDir; collectedArtifactsDir ]
527
534
528
535
// Clean Data for tests
529
536
cleanForTests ())
@@ -533,7 +540,9 @@ Target.create "CheckReleaseSecrets" (fun _ ->
533
540
secret.Force() |> ignore)
534
541
535
542
Target.create " CheckFormatting" ( fun _ ->
536
- let dotnetOptions = ( fun ( buildOptions : DotNet.Options ) -> { buildOptions with RedirectOutput = false })
543
+ let dotnetOptions =
544
+ ( fun ( buildOptions : DotNet.Options ) -> { buildOptions with RedirectOutput = false })
545
+
537
546
let result =
538
547
DotNet.exec id " fantomas" " src/app/ src/template/ src/test/ --check"
539
548
@@ -543,23 +552,22 @@ Target.create "CheckFormatting" (fun _ ->
543
552
failwith
544
553
" Some files need formatting, please run \" dotnet fantomas src/app/ src/template/ src/test/\" to resolve this."
545
554
else
546
- failwith " Errors while formatting"
547
- )
555
+ failwith " Errors while formatting" )
548
556
549
557
// ----------------------------------------------------------------------------------------------------
550
558
// Documentation targets.
551
559
552
560
Target.create " GenerateDocs" ( fun _ ->
553
561
let source = " ./docs"
554
-
562
+
555
563
Shell.cleanDir " .fsdocs"
556
564
Directory.ensure " output"
557
565
558
566
let projInfo =
559
567
seq {
560
- ( " root" , docsDomain)
561
- ( " fsdocs-logo-src" , docsDomain @@ " content/img/logo.svg" )
562
- ( " fsdocs-fake-version" , simpleVersion)
568
+ ( " root" , docsDomain)
569
+ ( " fsdocs-logo-src" , docsDomain @@ " content/img/logo.svg" )
570
+ ( " fsdocs-fake-version" , simpleVersion)
563
571
}
564
572
565
573
File.writeString false " ./output/.nojekyll" " "
@@ -568,26 +576,31 @@ Target.create "GenerateDocs" (fun _ ->
568
576
569
577
try
570
578
Npm.install ( fun o -> { o with WorkingDirectory = " ./docs" })
571
-
579
+
572
580
Npm.run " build" ( fun o -> { o with WorkingDirectory = " ./docs" })
573
581
574
- Shell.copy " ./output" [ source </> " robots.txt" ]
582
+ Shell.copy " ./output" [ source </> " robots.txt" ]
575
583
576
584
// renaming node_modules directory so that fsdocs skip it when generating site.
577
585
Directory.Move( " ./docs/node_modules" , " ./docs/.node_modules" )
578
586
579
- let command = sprintf " build --clean --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s " ( docsDomain @@ " content/img/logo.svg" ) simpleVersion
587
+ let command =
588
+ sprintf
589
+ " build --clean --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s "
590
+ ( docsDomain @@ " content/img/logo.svg" )
591
+ simpleVersion
592
+
580
593
DotNet.exec id " fsdocs" command |> ignore
581
594
582
- // Fsdocs.build (fun p -> { p with
583
- // Input = Some(source)
584
- // SaveImages = Some(true)
585
- // Clean = Some(true)
586
- // Parameters = Some projInfo
587
- // Properties = Some "Configuration=debug"
588
- // //Strict = Some(true)
589
- // })
590
-
595
+ // Fsdocs.build (fun p -> { p with
596
+ // Input = Some(source)
597
+ // SaveImages = Some(true)
598
+ // Clean = Some(true)
599
+ // Parameters = Some projInfo
600
+ // Properties = Some "Configuration=debug"
601
+ // //Strict = Some(true)
602
+ // })
603
+
591
604
finally
592
605
// clean up
593
606
Shell.rm ( source </> " guide/RELEASE_NOTES.md" )
@@ -597,19 +610,31 @@ Target.create "GenerateDocs" (fun _ ->
597
610
598
611
599
612
// validate site generation and ensure all components are generated successfully.
600
- if DirectoryInfo.ofPath( " ./output/guide" ) .GetFiles() .Length = 0 then failwith " site generation failed due to missing guide directory"
601
- if DirectoryInfo.ofPath( " ./output/reference" ) .GetFiles() .Length = 0 then failwith " site generation failed due to missing reference directory"
602
- if DirectoryInfo.ofPath( " ./output/articles" ) .GetFiles() .Length = 0 then failwith " site generation failed due to missing articles directory"
603
- if not ( File.exists( " ./output/data.json" )) then failwith " site generation failed due to missing data.json file"
604
- if not ( File.exists( " ./output/guide/RELEASE_NOTES.html" )) then failwith " site generation failed due to missing RELEASE_NOTES.html file"
605
- if not ( File.exists( " ./output/guide.html" )) then failwith " site generation failed due to missing guide.html file"
606
- if not ( File.exists( " ./output/index.html" )) then failwith " site generation failed due to missing index.html file"
613
+ if DirectoryInfo.ofPath( " ./output/guide" ) .GetFiles() .Length = 0 then
614
+ failwith " site generation failed due to missing guide directory"
615
+
616
+ if DirectoryInfo.ofPath( " ./output/reference" ) .GetFiles() .Length = 0 then
617
+ failwith " site generation failed due to missing reference directory"
618
+
619
+ if DirectoryInfo.ofPath( " ./output/articles" ) .GetFiles() .Length = 0 then
620
+ failwith " site generation failed due to missing articles directory"
621
+
622
+ if not ( File.exists ( " ./output/data.json" )) then
623
+ failwith " site generation failed due to missing data.json file"
624
+
625
+ if not ( File.exists ( " ./output/guide/RELEASE_NOTES.html" )) then
626
+ failwith " site generation failed due to missing RELEASE_NOTES.html file"
627
+
628
+ if not ( File.exists ( " ./output/guide.html" )) then
629
+ failwith " site generation failed due to missing guide.html file"
630
+
631
+ if not ( File.exists ( " ./output/index.html" )) then
632
+ failwith " site generation failed due to missing index.html file"
607
633
608
634
// prepare artifact
609
635
Directory.ensure " temp"
610
-
611
- !!( " output" </> " **/*" )
612
- |> Zip.zip docsDir " temp/docs.zip"
636
+
637
+ !!( " output" </> " **/*" ) |> Zip.zip docsDir " temp/docs.zip"
613
638
publish " temp/docs.zip" )
614
639
615
640
Target.create " HostDocs" ( fun _ ->
@@ -622,23 +647,28 @@ Target.create "HostDocs" (fun _ ->
622
647
623
648
Shell.copy ( source @@ " guide" ) [ " RELEASE_NOTES.md" ]
624
649
625
- Shell.copy " ./output" [ source </> " robots.txt" ]
626
-
650
+ Shell.copy " ./output" [ source </> " robots.txt" ]
651
+
627
652
// renaming node_modules directory so that fsdocs skip it when generating site.
628
653
Directory.Move( " ./docs/node_modules" , " ./docs/.node_modules" )
629
654
630
- let command = sprintf " watch --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s " ( docsDomain @@ " content/img/logo.svg" ) simpleVersion
655
+ let command =
656
+ sprintf
657
+ " watch --input ./docs --saveimages --properties Configuration=release --parameters fsdocs-logo-src %s fsdocs-fake-version %s "
658
+ ( docsDomain @@ " content/img/logo.svg" )
659
+ simpleVersion
660
+
631
661
DotNet.exec id " fsdocs" command |> ignore
632
662
633
- // Fsdocs.watch id
663
+ // Fsdocs.watch id
634
664
635
665
finally
636
666
// clean up
637
667
Shell.rm ( source </> " guide/RELEASE_NOTES.md" )
638
668
639
669
// renaming node_modules directory back after fsdocs generated site.
640
670
Directory.Move( " ./docs/.node_modules" , " ./docs/node_modules" )
641
-
671
+
642
672
)
643
673
644
674
// ----------------------------------------------------------------------------------------------------
@@ -659,7 +689,7 @@ Target.create "TemplateIntegrationTests" (fun _ ->
659
689
targetDir
660
690
" bin/Release/net6.0/Fake.DotNet.Cli.IntegrationTests.dll"
661
691
" Fake_DotNet_Cli_IntegrationTests.TestResults.xml"
662
-
692
+
663
693
Shell.rm_ rf ( root </> " test" ))
664
694
665
695
Target.create " DotNetCoreUnitTests" ( fun _ ->
@@ -723,14 +753,16 @@ Target.create "BootstrapFake" (fun _ ->
723
753
724
754
725
755
let processResult =
726
- CreateProcess.fromRawCommandLine fileName ( sprintf " run --fsiargs \" --define:BOOTSTRAP\" %s --target %s " script target)
756
+ CreateProcess.fromRawCommandLine
757
+ fileName
758
+ ( sprintf " run --fsiargs \" --define:BOOTSTRAP\" %s --target %s " script target)
727
759
|> CreateProcess.withWorkingDirectory " ."
728
760
|> CreateProcess.setEnvironmentVariable " FAKE_DETAILED_ERRORS" " true"
729
761
|> CreateProcess.withTimeout timeout
730
762
|> Proc.run
731
-
763
+
732
764
processResult.ExitCode
733
-
765
+
734
766
let result = executeTarget " BootstrapFake_PrintColors"
735
767
736
768
if result <> 0 then
@@ -967,11 +999,7 @@ Target.create "DotNetPushChocolateyPackage" (fun _ ->
967
999
{ p with ToolPath = altToolPath }
968
1000
969
1001
path
970
- |> Choco.push ( fun p ->
971
- { p with
972
- Source = chocoSource
973
- ApiKey = chocoKey.Value }
974
- |> changeToolPath))
1002
+ |> Choco.push ( fun p -> { p with Source = chocoSource; ApiKey = chocoKey.Value } |> changeToolPath))
975
1003
976
1004
Target.create " DotNetPushToNuGet" ( fun _ ->
977
1005
!!( appDir </> " */*.fsproj" ) -- ( appDir </> " Fake.netcore/*.fsproj" )
@@ -1031,7 +1059,7 @@ Target.create "GitHubRelease" (fun _ ->
1031
1059
|> GitHub.uploadFiles files
1032
1060
|> GitHub.publishDraft
1033
1061
|> Async.RunSynchronously
1034
-
1062
+
1035
1063
let bumpVersionMessage = ( sprintf " Bump version to %s " simpleVersion)
1036
1064
let branch = " bump-version-to-" + simpleVersion
1037
1065
Git.Staging.stageAll " .config"
@@ -1041,9 +1069,12 @@ Target.create "GitHubRelease" (fun _ ->
1041
1069
1042
1070
// when we release the GitHub module, this will be replaced with GitHub.createPullRequest API
1043
1071
let pullRequest = new NewPullRequest( bumpVersionMessage, branch, " master" )
1072
+
1044
1073
let pullRequestTask ( client : GitHubClient ) =
1045
- client.PullRequest.Create( githubReleaseUser, gitName, pullRequest) |> Async.AwaitTask |> Async.RunSynchronously
1046
-
1074
+ client.PullRequest.Create( githubReleaseUser, gitName, pullRequest)
1075
+ |> Async.AwaitTask
1076
+ |> Async.RunSynchronously
1077
+
1047
1078
GitHub.createClientWithToken token
1048
1079
|> Async.RunSynchronously
1049
1080
|> pullRequestTask
0 commit comments