-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.fsx
127 lines (106 loc) · 3.15 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
#r @"packages/build/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.UserInputHelper
open System
#if MONO
let inferFrameworkPathOverride () =
let mscorlib = "mscorlib.dll"
let possibleFrameworkPaths =
[
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/"
"/usr/local/Cellar/mono/4.6.12/lib/mono/4.5/"
"/usr/lib/mono/4.5/"
]
possibleFrameworkPaths
|> Seq.find (fun p ->IO.File.Exists(p @@ mscorlib))
Environment.SetEnvironmentVariable("FrameworkPathOverride", inferFrameworkPathOverride ())
#endif
let release = LoadReleaseNotes "RELEASE_NOTES.md"
let srcGlob = "src/**/*.fsproj"
let testsGlob = "tests/**/*.fsproj"
Target "Clean" (fun _ ->
["bin"; "temp" ;"dist"]
|> CleanDirs
!! srcGlob
++ testsGlob
|> Seq.collect(fun p ->
["bin";"obj"]
|> Seq.map(fun sp ->
IO.Path.GetDirectoryName p @@ sp)
)
|> CleanDirs
)
Target "DotnetRestore" (fun _ ->
!! srcGlob
++ testsGlob
|> Seq.iter (fun proj ->
DotNetCli.Restore (fun c ->
{ c with
Project = proj
})
))
Target "DotnetBuild" (fun _ ->
!! srcGlob
|> Seq.iter (fun proj ->
DotNetCli.Build (fun c ->
{ c with
Project = proj
})
))
Target "DotnetTest" (fun _ ->
!! testsGlob
|> Seq.filter(fun proj -> proj.Contains("testProj1") |> not)
|> Seq.iter (fun proj ->
DotNetCli.RunCommand (fun c ->
{ c with
WorkingDir = IO.Path.GetDirectoryName proj
}) "run"
))
Target "DotnetPack" (fun _ ->
!! srcGlob
|> Seq.iter (fun proj ->
DotNetCli.Pack (fun c ->
{ c with
Project = proj
Configuration = "Release"
OutputPath = IO.Directory.GetCurrentDirectory() @@ "dist"
AdditionalArgs =
[
sprintf "/p:PackageVersion=%s" release.NugetVersion
sprintf "/p:PackageReleaseNotes=\"%s\"" (String.Join("\n",release.Notes))
]
})
)
)
Target "Publish" (fun _ ->
Paket.Push(fun c ->
{ c with
PublishUrl = "https://www.nuget.org"
WorkingDir = "dist"
}
)
)
Target "Replace" <| fun _ ->
ReplaceInFiles [ "FsLibLog", "DotnetMono.Logging" ]
[ "paket-files/TheAngryByrd/FsLibLog/src/FsLibLog/FsLibLog.fs" ]
Target "Release" (fun _ ->
if Git.Information.getBranchName "" <> "master" then failwith "Not on master"
let releaseNotesGitCommitFormat = ("",release.Notes |> Seq.map(sprintf "* %s\n")) |> String.Join
StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s \n%s" release.NugetVersion releaseNotesGitCommitFormat)
Branches.push ""
Branches.tag "" release.NugetVersion
Branches.pushTag "" "origin" release.NugetVersion
)
"Clean"
==> "DotnetRestore"
==> "Replace"
==> "DotnetBuild"
==> "DotnetTest"
==> "DotnetPack"
==> "Publish"
==> "Release"
RunTargetOrDefault "DotnetPack"