-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
491 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module BasicTasks | ||
|
||
open BlackFox.Fake | ||
open Fake.IO | ||
open Fake.DotNet | ||
open Fake.IO.Globbing.Operators | ||
|
||
open ProjectInfo | ||
|
||
let setPrereleaseTag = BuildTask.create "SetPrereleaseTag" [] { | ||
printfn "Please enter pre-release package suffix" | ||
let suffix = System.Console.ReadLine() | ||
prereleaseSuffix <- suffix | ||
prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix) | ||
isPrerelease <- true | ||
} | ||
|
||
let clean = BuildTask.create "Clean" [] { | ||
!! "src/**/bin" | ||
++ "src/**/obj" | ||
++ "tests/**/bin" | ||
++ "tests/**/obj" | ||
++ "pkg" | ||
|> Shell.cleanDirs | ||
} | ||
|
||
let build = BuildTask.create "Build" [clean] { | ||
solutionFile | ||
|> DotNet.build id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
open BlackFox.Fake | ||
open System.IO | ||
open Fake.Core | ||
open Fake.DotNet | ||
open Fake.IO | ||
open Fake.IO.FileSystemOperators | ||
open Fake.IO.Globbing.Operators | ||
open Fake.Tools | ||
|
||
open Helpers | ||
|
||
initializeContext() | ||
|
||
open BasicTasks | ||
open TestTasks | ||
open PackageTasks | ||
open DocumentationTasks | ||
open ReleaseTasks | ||
|
||
/// Full release of nuget package, git tag, and documentation for the stable version. | ||
let _release = | ||
BuildTask.createEmpty | ||
"Release" | ||
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs] | ||
|
||
/// Full release of nuget package, git tag, and documentation for the prerelease version. | ||
let _preRelease = | ||
BuildTask.createEmpty | ||
"PreRelease" | ||
[setPrereleaseTag; clean; build; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs] | ||
|
||
/// Full release of nuget package for the prerelease version. | ||
let _releaseNoDocs = | ||
BuildTask.createEmpty | ||
"ReleaseNoDocs" | ||
[clean; build; runTests; pack; createTag; publishNuget;] | ||
|
||
/// Full release of nuget package for the prerelease version. | ||
let _preReleaseNoDocs = | ||
BuildTask.createEmpty | ||
"PreReleaseNoDocs" | ||
[setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease] | ||
|
||
[<EntryPoint>] | ||
let main args = | ||
runOrDefault build args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module DocumentationTasks | ||
|
||
open Helpers | ||
open ProjectInfo | ||
open BasicTasks | ||
|
||
open BlackFox.Fake | ||
|
||
let buildDocs = BuildTask.create "BuildDocs" [build] { | ||
printfn "building docs with stable version %s" stableVersionTag | ||
runDotNet | ||
(sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag) | ||
"./" | ||
} | ||
|
||
let buildDocsPrerelease = BuildTask.create "BuildDocsPrerelease" [setPrereleaseTag; build] { | ||
printfn "building docs with prerelease version %s" prereleaseTag | ||
runDotNet | ||
(sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag) | ||
"./" | ||
} | ||
|
||
let watchDocs = BuildTask.create "WatchDocs" [build] { | ||
printfn "watching docs with stable version %s" stableVersionTag | ||
runDotNet | ||
(sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag) | ||
"./" | ||
} | ||
|
||
let watchDocsPrerelease = BuildTask.create "WatchDocsPrerelease" [setPrereleaseTag; build] { | ||
printfn "watching docs with prerelease version %s" prereleaseTag | ||
runDotNet | ||
(sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag) | ||
"./" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Helpers | ||
|
||
open BlackFox.Fake | ||
open Fake.Core | ||
open Fake.DotNet | ||
|
||
let initializeContext () = | ||
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ] | ||
Context.setExecutionContext (Context.RuntimeContext.Fake execContext) | ||
|
||
/// Executes a dotnet command in the given working directory | ||
let runDotNet cmd workingDir = | ||
let result = | ||
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd "" | ||
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir | ||
|
||
let runOrDefault defaultTarget args = | ||
Trace.trace (sprintf "%A" args) | ||
try | ||
match args with | ||
| [| target |] -> Target.runOrDefault target | ||
| arr when args.Length > 1 -> | ||
Target.run 0 (Array.head arr) ( Array.tail arr |> List.ofArray ) | ||
| _ -> BuildTask.runOrDefault defaultTarget | ||
0 | ||
with e -> | ||
printfn "%A" e | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module MessagePrompts | ||
|
||
let prompt (msg:string) = | ||
System.Console.Write(msg) | ||
System.Console.ReadLine().Trim() | ||
|> function | "" -> None | s -> Some s | ||
|> Option.map (fun s -> s.Replace ("\"","\\\"")) | ||
|
||
let rec promptYesNo msg = | ||
match prompt (sprintf "%s [Yn]: " msg) with | ||
| Some "Y" | Some "y" -> true | ||
| Some "N" | Some "n" -> false | ||
| _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg | ||
|
||
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. | ||
Do you want to continue?""" | ||
|
||
let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module PackageTasks | ||
|
||
open ProjectInfo | ||
|
||
open MessagePrompts | ||
open BasicTasks | ||
open TestTasks | ||
|
||
open BlackFox.Fake | ||
open Fake.Core | ||
open Fake.IO.Globbing.Operators | ||
|
||
open System.Text.RegularExpressions | ||
|
||
/// https://github.com/Freymaurer/Fake.Extensions.Release#release-notes-in-nuget | ||
let private replaceCommitLink input = | ||
let commitLinkPattern = @"\[\[#[a-z0-9]*\]\(.*\)\] " | ||
Regex.Replace(input,commitLinkPattern,"") | ||
|
||
let pack = BuildTask.create "Pack" [clean; build; runTests] { | ||
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag ) | ||
then | ||
!! "src/**/*.*proj" | ||
-- "src/bin/*" | ||
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p -> | ||
let msBuildParams = | ||
{p.MSBuildParams with | ||
Properties = ([ | ||
"Version",stableVersionTag | ||
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" ) | ||
] @ p.MSBuildParams.Properties) | ||
} | ||
{ | ||
p with | ||
MSBuildParams = msBuildParams | ||
OutputPath = Some pkgDir | ||
} | ||
)) | ||
else failwith "aborted" | ||
} | ||
|
||
let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; runTests] { | ||
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) | ||
then | ||
!! "src/**/*.*proj" | ||
-- "src/bin/*" | ||
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p -> | ||
let msBuildParams = | ||
{p.MSBuildParams with | ||
Properties = ([ | ||
"Version", prereleaseTag | ||
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines ) | ||
] @ p.MSBuildParams.Properties) | ||
} | ||
{ | ||
p with | ||
VersionSuffix = Some prereleaseSuffix | ||
OutputPath = Some pkgDir | ||
MSBuildParams = msBuildParams | ||
} | ||
)) | ||
else | ||
failwith "aborted" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module ProjectInfo | ||
|
||
open Fake.Core | ||
|
||
let project = "FsOboParser" | ||
|
||
let testProjects = | ||
[ | ||
// add relative paths (from project root) to your testprojects here | ||
] | ||
|
||
let solutionFile = $"{project}.sln" | ||
|
||
let configuration = "Release" | ||
|
||
let gitOwner = "CSBiology" | ||
|
||
let gitHome = $"https://github.com/{gitOwner}" | ||
|
||
let projectRepo = $"https://github.com/{gitOwner}/{project}" | ||
|
||
let pkgDir = "pkg" | ||
|
||
// Create RELEASE_NOTES.md if not existing. Or "release" would throw an error. | ||
Fake.Extensions.Release.ReleaseNotes.ensure() | ||
|
||
let release = ReleaseNotes.load "RELEASE_NOTES.md" | ||
|
||
let stableVersion = SemVer.parse release.NugetVersion | ||
|
||
let stableVersionTag = (sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch ) | ||
|
||
let mutable prereleaseSuffix = "" | ||
|
||
let mutable prereleaseTag = "" | ||
|
||
let mutable isPrerelease = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module ReleaseNotesTasks | ||
|
||
open Fake.Extensions.Release | ||
open BlackFox.Fake | ||
|
||
/// This might not be necessary, mostly useful for apps which want to display current version as it creates an accessible F# version script from RELEASE_NOTES.md | ||
let createAssemblyVersion = BuildTask.create "createvfs" [] { | ||
AssemblyVersion.create ProjectInfo.project | ||
} | ||
|
||
// https://github.com/Freymaurer/Fake.Extensions.Release#releaseupdate | ||
let updateReleaseNotes = BuildTask.createFn "ReleaseNotes" [] (fun config -> | ||
ReleaseNotes.update(ProjectInfo.gitOwner, ProjectInfo.project, config) | ||
) | ||
|
||
|
||
// https://github.com/Freymaurer/Fake.Extensions.Release#githubdraft | ||
let githubDraft = BuildTask.createFn "GithubDraft" [] (fun config -> | ||
|
||
let body = "We are ready to go for the first release!" | ||
|
||
Github.draft( | ||
ProjectInfo.gitOwner, | ||
ProjectInfo.project, | ||
(Some body), | ||
None, | ||
config | ||
) | ||
) |
Oops, something went wrong.