-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.fs
More file actions
198 lines (179 loc) · 5.32 KB
/
Build.fs
File metadata and controls
198 lines (179 loc) · 5.32 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
module Build.Build
open System.IO
open Fake.Core
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.Tools
open Partas.GitNet.RepoCracker
open Spec
open Projects
open Partas.GitNet.ConfigTypes
open Partas.GitNet
Helpers.initializeContext()
// GitNet Config
let gitnetConfig =
let ignorePath = fun (str: string) -> Path.GetFileNameWithoutExtension(str)
{
GitNetConfig.initFSharp with
RepositoryPath = __SOURCE_DIRECTORY__
Output.Ignore = Defaults.ignoreCommits @ [
IgnoreCommit.SkipCi
]
Bump.DefaultBumpStrategy = ForceBumpStrategy.All
ProjectType =
{
ProjectFSharpConfig.init with
IgnoredProjects = List.map ignorePath [
Files.Root.Devgrounds.``Devgrounds.fsproj``
Files.Root.``Build.fsproj``
]
}
|> Some
|> ProjectType.FSharp
}
// GitNet Runtime
let runtime =
lazy
new GitNetRuntime(gitnetConfig)
// GitNet Projects
let crackedProjects =
lazy
runtime.Value
|> _.CrackRepo
|> Seq.choose (CrackedProject.getFSharp >> ValueOption.toOption)
|> Seq.toList
// Setup repo
Target.create Ops.Prelude <| fun args ->
task {
crackedProjects.Value
|> ignore
}
|> ignore
let isLocal =
Args.local
|| args.Context.AllExecutingTargets
|> List.exists (_.Name >> (=) Ops.PublishLocal)
if not isLocal then
[ $"config --local user.email \"{githubEmail}\""
$"config --local user.name \"{githubUsername}\"" ]
|> List.iter (Git.CommandHelper.directRunGitCommandAndFail Files.Root.``.``)
// Cleanup dirs
Target.create Ops.Clean <| fun args ->
!! "**/**/bin"
-- "bin"
++ "temp/"
|> Shell.cleanDirs
Target.create Ops.GitNet <| fun args ->
let runtime = runtime.Value
if Args.local ||
args.Context.AllExecutingTargets
|> List.map _.Name
|> List.exists ((=) Ops.PublishLocal)
then
let bumps,content = runtime.DryRun()
bumps
|> Seq.map (fun keyVal ->
(keyVal.Key, keyVal.Value.SemVer.ToString(), keyVal.Value.ToString())
|||> sprintf "Scope: %s | Next: %s | SepochSemver: %s")
|> Trace.logItems "GitNet"
runtime.WriteToOutput content
|> ignore
else
runtime.Run(githubUsername, githubEmail)
|> ignore
Target.create Ops.RestoreTools <| fun _ ->
Helpers.run
Helpers.dotnet
[ "tool"; "restore" ]
Files.Root.``.``
open Fake.DotNet
Target.create Ops.Build <| fun _ ->
crackedProjects.Value
// If we trigger the build for Partas.Solid.Primitives, it will
// Build the other projects for us.
|> List.filter (
_.ProjectFileName
>> Path.GetFileNameWithoutExtension
>> (=) "Partas.Solid.Primitives"
)
|> List.iter (fun project ->
DotNet.build
(fun p ->
{
p with
Configuration = DotNet.BuildConfiguration.Release
DotNet.BuildOptions.MSBuildParams.DisableInternalBinLog = true
}
)
project.ProjectFileName
)
Target.create Ops.Pack <| fun _ ->
projects
|> List.toArray
|> (if Args.parallelise
then Array.Parallel.iter
else Array.iter) (fun project ->
project.Path
|> DotNet.pack (fun p ->
{
p with
NoRestore = true
OutputPath = Some "bin"
DotNet.PackOptions.MSBuildParams.DisableInternalBinLog = true
}
)
)
Target.create Ops.GitPush <| fun _ ->
Git.Branches.push Files.Root.``.``
Git.CommandHelper.directRunGitCommandAndFail Files.Root.``.`` "push --tags origin"
let pushLocal path =
path
|> DotNet.nugetPush (fun p ->
{ p with
DotNet.NuGetPushOptions.PushParams.Source = Some "local"
DotNet.NuGetPushOptions.Common.CustomParams = Some "--skip-duplicate" }
)
Target.create Ops.PublishLocal <| fun _ ->
!! "bin/*.nupkg"
|> Seq.toArray
|> (if Args.parallelise
then Array.Parallel.iter
else Array.iter) pushLocal
Target.create Ops.Publish <| fun _ ->
!!"bin/*.nupkg"
|> Seq.toArray
|> (if Args.parallelise
then Array.Parallel.iter
else Array.iter) (fun path ->
path
|> DotNet.nugetPush (fun p ->
{ p with
DotNet.NuGetPushOptions.PushParams.Source = Some "https://api.nuget.org/v3/index.json"
DotNet.NuGetPushOptions.Common.CustomParams = Some "--skip-duplicate"
DotNet.NuGetPushOptions.PushParams.ApiKey = Args.apiKey }
)
if Args.local then
pushLocal path
)
open Fake.Core.TargetOperators
let dependencies = [
Ops.Prelude
==> Ops.RestoreTools
==> Ops.Clean
==> Ops.GitNet
==> Ops.Build
==> Ops.Pack
==> Ops.GitPush
==> Ops.Publish
Ops.Pack
==> Ops.PublishLocal
]
[<EntryPoint>]
let main args =
args |> Args.setArgs
try
args[0] |> Target.runOrDefaultWithArguments
0
with e ->
printfn $"%A{e}"
1