-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.fsx
More file actions
129 lines (107 loc) · 3.5 KB
/
build.fsx
File metadata and controls
129 lines (107 loc) · 3.5 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
#r "paket:
nuget Xake ~> 1.1 prerelease //"
#if !FAKE
#load ".fake/build.fsx/intellisense.fsx"
#endif
open Xake
open Xake.Tasks
let frameworks = ["netstandard2.0"; "net46"]
let libtargets =
[ for t in frameworks do
for e in ["dll"; "xml"]
-> sprintf "out/%s/Xake.%s" t e
]
let getVersion () = recipe {
let! verVar = getVar("VER")
let! verEnv = getEnv("VER")
let ver = verVar |> Option.defaultValue (verEnv |> Option.defaultValue "0.0.1")
let! verSuffix =
getVar("SUFFIX")
|> Recipe.map (
function
| None -> "-beta"
| Some "" -> "" // this is release!
| Some s -> "-" + s
)
return ver + verSuffix
}
let makePackageName = sprintf "Xake.%s.nupkg"
let dotnet arglist = recipe {
do! shell {
cmd "dotnet"
args arglist
failonerror
} |> Recipe.Ignore
}
do xakeScript {
filelog "build.log" Verbosity.Diag
// consolelog Verbosity.Normal
rules [
"main" => recipe {
do! need ["build"]
do! need ["test"]
}
"build" <== libtargets
"clean" => rm {dir "out"}
"test" => recipe {
do! alwaysRerun()
let! where =
getVar("FILTER")
|> Recipe.map (function |Some clause -> ["--filter"; sprintf "Name~\"%s\"" clause] | None -> [])
// in case of travis only run tests for standard runtime, eventually will add more
let! limitFwk = getEnv("TRAVIS") |> Recipe.map (function | Some _ -> ["-f:netcoreapp2.0"] | _ -> [])
do! dotnet <| ["test"; "src/tests"; "-c"; "Release"] @ where @ limitFwk
}
libtargets *..> recipe {
let! allFiles
= getFiles <| fileset {
basedir "src/core"
includes "Xake.fsproj"
includes "**/*.fs"
}
do! needFiles allFiles
let! version = getVersion()
for framework in frameworks do
do! dotnet
[
"build"
"src/core"
"/p:Version=" + version
"--configuration"; "Release"
"--framework"; framework
"--output"; "../../out/" + framework
"/p:DocumentationFile=Xake.xml"
]
}
]
(* Nuget publishing rules *)
rules [
"pack" => recipe {
let! version = getVersion()
do! need ["out" </> makePackageName version]
}
"out/Xake.(ver:*).nupkg" ..> recipe {
let! ver = getRuleMatch("ver")
do! dotnet
[
"pack"; "src/core"
"-c"; "Release"
"/p:Version=" + ver
"--output"; "../../out/"
"/p:DocumentationFile=Xake.xml"
]
}
// push need pack to be explicitly called in advance
"push" => recipe {
let! version = getVersion()
let! nuget_key = getEnv("NUGET_KEY")
do! dotnet
[
"nuget"; "push"
"out" </> makePackageName version
"--source"; "https://www.nuget.org/api/v2/package"
"--api-key"; nuget_key |> Option.defaultValue ""
]
}
]
}