Skip to content

Commit 735e6bb

Browse files
committed
Add targets for building and publishing prerelease packages
1 parent 167e4dc commit 735e6bb

File tree

1 file changed

+56
-84
lines changed

1 file changed

+56
-84
lines changed

Diff for: build.fsx

+56-84
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#r @"paket:
32
nuget Fake.Core.Target
43
nuget Fake.Core.Process
@@ -25,75 +24,11 @@ open System.IO
2524
open Fake.Core
2625
open Fake.Core.TargetOperators
2726
open Fake.DotNet
28-
open Fake.IO.Globbing
29-
open Fake.DotNet.NuGet
30-
open Fake.DotNet.Testing
3127
open Fake.IO
3228
open Fake.IO.FileSystemOperators
3329
open Fake.IO.Globbing.Operators
3430
open Fake.Tools
3531

36-
[<AutoOpen>]
37-
module TemporaryDocumentationHelpers =
38-
39-
type LiterateArguments =
40-
{ ToolPath : string
41-
Source : string
42-
OutputDirectory : string
43-
Template : string
44-
ProjectParameters : (string * string) list
45-
LayoutRoots : string list
46-
FsiEval : bool }
47-
48-
let private run toolPath arguments =
49-
Command.RawCommand
50-
(
51-
toolPath,
52-
arguments
53-
)
54-
|> CreateProcess.fromCommand
55-
|> CreateProcess.withFramework
56-
|> CreateProcess.ensureExitCode
57-
|> Proc.run
58-
|> ignore
59-
60-
61-
let createDocs p =
62-
let toolPath =
63-
match ProcessUtils.tryFindLocalTool "" "fsformatting.exe" [(Directory.GetCurrentDirectory() @@ "/lib")] with
64-
|Some tool -> tool
65-
| _ -> failwith "FSFormatting executable not found"
66-
//let toolPath = Tools.findToolInSubPath "fsformatting.exe" (Directory.GetCurrentDirectory() @@ "lib/Formatting")
67-
68-
let defaultLiterateArguments =
69-
{ ToolPath = toolPath
70-
Source = ""
71-
OutputDirectory = ""
72-
Template = ""
73-
ProjectParameters = []
74-
LayoutRoots = []
75-
FsiEval = false }
76-
77-
let arguments = (p:LiterateArguments->LiterateArguments) defaultLiterateArguments
78-
let layoutroots =
79-
if arguments.LayoutRoots.IsEmpty then []
80-
else [ "--layoutRoots" ] @ arguments.LayoutRoots
81-
let source = arguments.Source
82-
let template = arguments.Template
83-
let outputDir = arguments.OutputDirectory
84-
let fsiEval = if arguments.FsiEval then [ "--fsieval" ] else []
85-
86-
let command =
87-
arguments.ProjectParameters
88-
|> Seq.map (fun (k, v) -> [ k; v ])
89-
|> Seq.concat
90-
|> Seq.append
91-
(["literate"; "--processdirectory" ] @ layoutroots @ [ "--inputdirectory"; source; "--templatefile"; template;
92-
"--outputDirectory"; outputDir] @ fsiEval @ [ "--replacements" ])
93-
|> Arguments.OfArgs
94-
run arguments.ToolPath command
95-
printfn "Successfully generated docs for %s" source
96-
9732
let project = "FSharp.Plotly"
9833

9934
let summary = "A F# interactive charting library using plotly.js"
@@ -117,6 +52,29 @@ let pkgDir = "pkg"
11752

11853
let release = ReleaseNotes.load "RELEASE_NOTES.md"
11954

55+
let mutable prereleaseTag = ""
56+
let mutable isPrerelease = false
57+
58+
[<AutoOpen>]
59+
module MessagePrompts =
60+
61+
let prompt (msg:string) =
62+
System.Console.Write(msg)
63+
System.Console.ReadLine().Trim()
64+
|> function | "" -> None | s -> Some s
65+
|> Option.map (fun s -> s.Replace ("\"","\\\""))
66+
67+
let rec promptYesNo msg =
68+
match prompt (sprintf "%s [Yn]: " msg) with
69+
| Some "Y" | Some "y" -> true
70+
| Some "N" | Some "n" -> false
71+
| _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg
72+
73+
let releaseMsg = """This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file.
74+
Do you want to continue?"""
75+
76+
let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?"""
77+
12078
// Generate assembly info files with the right version & up-to-date information
12179
Target.create "AssemblyInfo" (fun _ ->
12280
let getAssemblyInfoAttributes projectName =
@@ -209,26 +167,33 @@ Target.create "RunTests" (fun _ ->
209167
// --------------------------------------------------------------------------------------
210168
// Build and publish NuGet package
211169

212-
Target.create "BuildPreReleasePackages" (fun _ ->
213-
printfn "Please enter pre-release package suffix"
214-
let suffix = Console.ReadLine()
215-
Paket.pack(fun p ->
216-
{ p with
217-
ToolType = ToolType.CreateLocalTool()
218-
OutputPath = pkgDir
219-
Version = sprintf "%s-%s" release.NugetVersion suffix
220-
ReleaseNotes = release.Notes |> String.toLines })
221-
)
170+
Target.create "buildPrereleasePackages" (fun _ ->
171+
printfn "Please enter pre-release package suffix"
172+
let suffix = System.Console.ReadLine()
173+
isPrerelease <- true
174+
prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix)
175+
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag )
176+
then
177+
Paket.pack(fun p ->
178+
{ p with
179+
180+
ToolType = ToolType.CreateLocalTool()
181+
OutputPath = pkgDir
182+
Version = prereleaseTag
183+
ReleaseNotes = release.Notes |> String.toLines })
184+
else
185+
failwith "aborted"
186+
)
222187

223188
Target.create "BuildReleasePackages" (fun _ ->
224-
Paket.pack(fun p ->
225-
{ p with
226-
ToolType = ToolType.CreateLocalTool()
227-
OutputPath = pkgDir
228-
Version = release.NugetVersion
229-
ReleaseNotes = release.Notes |> String.toLines })
230-
)
231-
189+
isPrerelease <- false
190+
Paket.pack(fun p ->
191+
{ p with
192+
ToolType = ToolType.CreateLocalTool()
193+
OutputPath = pkgDir
194+
Version = release.NugetVersion
195+
ReleaseNotes = release.Notes |> String.toLines })
196+
)
232197
Target.create "BuildCIPackages" (fun _ ->
233198
Paket.pack(fun p ->
234199
{ p with
@@ -246,6 +211,13 @@ Target.create "PublishNuget" (fun _ ->
246211
ApiKey = Environment.environVarOrDefault "NuGet-key" ""})
247212
)
248213

214+
Target.create "publishPrereleaseNugetPackages"(fun _ ->
215+
Paket.push(fun p ->
216+
{ p with
217+
WorkingDir = pkgDir
218+
ToolType = ToolType.CreateLocalTool()
219+
ApiKey = Environment.environVarOrDefault "NuGet-key" "" })
220+
)
249221

250222
// --------------------------------------------------------------------------------------
251223
// Generate the documentation
@@ -368,6 +340,6 @@ Target.create "DotnetCoreBuild" ignore
368340
==> "CopyBinaries"
369341
==> "RunTests"
370342
==> "BuildPreReleasePackages"
371-
==> "GitReleaseNuget"
343+
==> "publishPrereleaseNugetPackages"
372344

373345
Target.runOrDefaultWithArguments "All"

0 commit comments

Comments
 (0)