forked from et1975/MassTransit.fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
executable file
·142 lines (120 loc) · 4.59 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
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Fake.Core.ReleaseNotes"
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.Tools.Git"
#r "nuget: Microsoft.Extensions.Configuration.Json"
#r "nuget: Microsoft.Extensions.Configuration.Binder"
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.Tools
open System
let gitName = "MassTransit.fs"
let gitOwner = "et1975"
let gitHome = sprintf "https://github.com/%s" gitOwner
let gitIO = sprintf "https://%s.github.io/%s" gitOwner gitName
let gitRepo = sprintf "[email protected]:%s/%s.git" gitOwner gitName
let gitContent = sprintf "https://raw.githubusercontent.com/%s/%s" gitOwner gitName
let release = ReleaseNotes.load "RELEASE_NOTES.md"
let ver =
match Environment.environVarOrNone "BUILD_NUMBER" with
| Some n -> { release.SemVer with Patch = uint32 n; Original = None }
| _ -> SemVer.parse "0.0.0"
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false __SOURCE_FILE__
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
Target.create "clean" (fun _ ->
!! "**/bin"
++ "**/obj"
++ "out"
|> Seq.iter Shell.cleanDir
)
Target.create "restore" (fun _ ->
DotNet.restore id "."
)
Target.create "build" (fun _ ->
let args = "--no-restore"
DotNet.publish (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args})) "."
)
Target.create "test" (fun _ ->
let args = "--no-restore"
DotNet.test (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args})) "."
)
Target.create "package" (fun _ ->
let args = sprintf "/p:Version=%s --no-restore" ver.AsString
DotNet.pack (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args })) "."
)
Target.create "publish" (fun _ ->
let exec dir =
DotNet.exec (fun a -> a.WithCommon (fun c -> { c with WorkingDirectory=dir }))
let args = sprintf "push %s.%s.nupkg -s %s -k %s"
"MassTransit.fs" ver.AsString
(Environment.environVar "NUGET_REPO_URL")
(Environment.environVar "NUGET_REPO_KEY")
let result = exec ("src/MassTransit.fs/bin/Release") "nuget" args
if (not result.OK) then failwithf "%A" result.Errors
)
Target.create "meta" (fun _ ->
[ "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
"<PropertyGroup>"
"<Copyright>MassTransit.fs contributors. All rights reserved.</Copyright>"
"<Authors>Eugene Tolmachev</Authors>"
sprintf "<PackageProjectUrl>%s</PackageProjectUrl>" gitIO
sprintf "<RepositoryUrl>%s/%s</RepositoryUrl>" gitHome gitName
"<PackageLicense>MIT</PackageLicense>"
sprintf "<PackageReleaseNotes>%s</PackageReleaseNotes>" (List.head release.Notes)
sprintf "<PackageIconUrl>%s/master/docs/content/logo.png</PackageIconUrl>" gitContent
"<PackageTags>MassTransit;fsharp</PackageTags>"
sprintf "<Version>%s</Version>" (string ver)
sprintf "<FsDocsLogoSource>%s/master/docs/img/logo.png</FsDocsLogoSource>" gitContent
sprintf "<FsDocsLicenseLink>%s/%s/blob/master/LICENSE</FsDocsLicenseLink>" gitHome gitName
sprintf "<FsDocsReleaseNotesLink>%s/%s/blob/master/RELEASE_NOTES.md</FsDocsReleaseNotesLink>" gitHome gitName
"<FsDocsNavbarPosition>fixed-right</FsDocsNavbarPosition>"
"<FsDocsWarnOnMissingDocs>true</FsDocsWarnOnMissingDocs>"
"<FsDocsTheme>default</FsDocsTheme>"
"</PropertyGroup>"
"</Project>"]
|> File.write false "Directory.Build.props"
)
Target.create "generateDocs" (fun _ ->
Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" "build --clean" |> ignore
)
Target.create "watchDocs" (fun _ ->
Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" "watch" |> ignore
)
Target.create "releaseDocs" (fun _ ->
let tempDocsDir = "tmp/gh-pages"
Shell.cleanDir tempDocsDir
Git.Repository.cloneSingleBranch "" gitRepo "gh-pages" tempDocsDir
Git.Repository.fullclean tempDocsDir
Shell.copyRecursive "output" tempDocsDir true |> Trace.tracefn "%A"
Git.Staging.stageAll tempDocsDir
Git.Commit.exec tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
Git.Branches.push tempDocsDir
)
Target.create "release" ignore
Target.create "ci" ignore
"clean"
==> "restore"
==> "meta"
==> "build"
==> "test"
==> "generateDocs"
==> "package"
==> "publish"
"releaseDocs"
<== ["test"; "generateDocs" ]
"release"
<== [ "publish" ]
"ci"
<== [ "test" ]
Target.runOrDefaultWithArguments "test"