forked from FakeBuild/Xake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
115 lines (95 loc) · 3.09 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
#r "nuget: Xake, 2.0.0"
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 =
shell {
cmd "dotnet"
args arglist
failonerror
} |> Ignore
do xakeScript {
filelog "build.log" Verbosity.Diag
// consolelog Verbosity.Normal
rules [
"main" <<< ["build"; "test"]
"build" <== libtargets
"clean" => rm {dir "out"}
"test" => recipe {
do! alwaysRerun()
let! where =
getVar("FILTER")
|> map (function |Some clause -> ["--filter"; $"Name~\"{clause}\""] | None -> [])
// in case of travis only run tests for standard runtime, eventually will add more
let! limitFwk = getEnv("TRAVIS") |> 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 ""
]
}
]
}