forked from sergii-s/fb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
130 lines (107 loc) · 2.88 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
open Fake.DotNet.NuGet
open Fake.SystemHelper
open Fake.DotNet
#r "paket:
storage: none
source https://api.nuget.org/v3/index.json
nuget Fake.Core.Target
nuget Fake.IO.FileSystem
nuget Fake.DotNet.Cli
nuget Fake.DotNet.Nuget
nuget Fake.DotNet.AssemblyInfoFile //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.Core
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.DotNet
let solution = "./fb2.sln"
let artifacts = "./artifacts"
let nugetSource = "https://api.nuget.org/v3/index.json"
let nugetKey = Environment.environVarOrNone "NUGET_KEY"
let version = sprintf "0.11.%s" (Environment.environVar "BUILD_NUMBER")
let buildConfiguration =
if Environment.environVarOrDefault "BUILD_CONF" "Release" = "Release"
then
DotNet.BuildConfiguration.Release
else
DotNet.BuildConfiguration.Debug
// *** Define Targets ***
Target.create "Clean" (fun _ ->
solution
|> DotNet.exec id "clean"
|> ignore
artifacts
|> Shell.cleanDir
artifacts
|> Shell.mkdir
)
Target.create "SetVersion" (fun _ ->
AssemblyInfoFile.createCSharp "SolutionInfo.cs"
[ AssemblyInfo.Version version
AssemblyInfo.FileVersion version ]
)
Target.create "Restore" (fun _ ->
solution
|> DotNet.restore id
)
Target.create "Build" (fun _ ->
solution
|> DotNet.build (fun p ->
{ p with
NoRestore = true
Configuration = buildConfiguration
})
)
Target.create "Test" (fun _ ->
solution
|> DotNet.test (fun p ->
{ p with
NoRestore = true
NoBuild = true
Configuration = buildConfiguration
})
)
Target.create "Nuget-package" (fun _ ->
let projectFiles = !! "./**/fb2.fsproj"
for projectFile in projectFiles do
projectFile
|> DotNet.pack (fun p ->
{ p with
OutputPath = Some(artifacts |> Path.getFullName)
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = ["Version", version]}
NoBuild = true
NoRestore = true
})
)
Target.create "Nuget-publish-local" (fun _ ->
DotNet.exec id "nuget" (sprintf "push %s/*.nupkg -s %s" artifacts "/home/sergii/dev/packages/")
|> ignore
)
Target.create "Nuget-publish" (fun _ ->
match nugetKey with
| Some nugetKey ->
DotNet.exec id "nuget" (sprintf "push artifacts/*.nupkg -k %s -s %s" nugetKey nugetSource)
|> ignore
| None ->
failwith "You should precise 'nugetKey' environment variable to publish nuget"
)
Target.create "Default" (fun _ ->
version
|> sprintf "Build %s done"
|> Trace.trace
)
open Fake.Core.TargetOperators
// *** Define Dependencies ***
"Clean"
==> "SetVersion"
==> "Restore"
==> "Build"
==> "Test"
==> "Default"
"Nuget-package"
==> "Nuget-publish"
"Nuget-package"
==> "Nuget-publish-local"
// *** Start Build ***
Target.runOrDefault "Default"