forked from aaronpowell/Chauffeur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
176 lines (141 loc) · 5.66 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
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
#r @"tools/FAKE.Core/tools/FakeLib.dll"
#r @"tools/FSharpLint.Fake/tools/FSharpLint.Fake.dll"
open Fake
open Fake.Testing.XUnit2
open Fake.AssemblyInfoFile
open FSharpLint.Fake
let authors = ["Aaron Powell"]
let chauffeurDir = "./Chauffeur/bin/"
let chauffeurRunnerDir = "./Chauffeur.Runner/bin/"
let packagingRoot = "./.packaging/"
let packagingDir = packagingRoot @@ "chauffeur"
let packagingRunnerDir = packagingRoot @@ "chauffeur.runner"
let testDir = "./.testresults"
let buildMode = getBuildParamOrDefault "buildMode" "Release"
let isAppVeyorBuild = not (isNull (environVar "APPVEYOR"))
let projectName = "Chauffeur"
let chauffeurSummary = "Chauffeur is a tool for helping with delivering changes to an Umbraco instance."
let chauffeurDescription = chauffeurSummary
let chauffeurRunnerSummary = "Chauffeur Runner is a CLI for executing Chauffeur deliverables against an Umbraco instance."
let chauffeurRunnerDescription = chauffeurRunnerSummary
let releaseNotes =
ReadFile "ReleaseNotes.md"
|> ReleaseNotesHelper.parseReleaseNotes
let trimBranchName (branch: string) =
if branch.Length > 10 then
branch.Substring(0, 10)
else
branch
let prv = match environVar "APPVEYOR_REPO_BRANCH" with
| "master" -> ""
| branch -> sprintf "-%s%s" (trimBranchName branch) (
match environVar "APPVEYOR_BUILD_NUMBER" with
| null -> ""
| _ -> sprintf "-%s" (environVar "APPVEYOR_BUILD_NUMBER")
)
let nugetVersion = sprintf "%d.%d.%d%s" releaseNotes.SemVer.Major releaseNotes.SemVer.Minor releaseNotes.SemVer.Patch prv
Target "Default" DoNothing
Target "AssemblyInfo" (fun _ ->
CreateCSharpAssemblyInfo "SolutionInfo.cs"
[ Attribute.Product projectName
Attribute.Version releaseNotes.AssemblyVersion
Attribute.FileVersion releaseNotes.AssemblyVersion
Attribute.ComVisible false ]
)
Target "Clean" (fun _ ->
CleanDirs [chauffeurDir; chauffeurRunnerDir; testDir]
)
Target "RestoreChauffeurPackages" (fun _ ->
RestorePackage id "./Chauffeur/packages.config"
)
Target "RestoreChauffeurDemoPackages" (fun _ ->
RestorePackage id "./Chauffeur.Demo/packages.config"
)
Target "RestoreChauffeurTestsPackages" (fun _ ->
RestorePackage id "./Chauffeur.Tests/packages.config"
RestorePackage id "./Chauffeur.Tests.Integration/packages.config"
)
Target "Build" (fun _ ->
MSBuild null "Build" ["Configuration", buildMode] ["Chauffeur.sln"]
|> Log "AppBuild-Output: "
)
Target "UnitTests" (fun _ ->
!! (sprintf "./Chauffeur.Tests/bin/%s/**/Chauffeur.Tests.dll" buildMode)
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.html") })
)
Target "EnsureSqlExpressAssemblies" (fun _ ->
CopyDir (sprintf "./Chauffeur.Tests.Integration/bin/%s" buildMode) "packages/UmbracoCms.7.5.4/UmbracoFiles/bin" (fun x -> true)
)
Target "CleanXUnitVSRunner" (fun _ ->
DeleteFile (sprintf "./Chauffeur.Tests.Integration/bin/%s/xunit.runner.visualstudio.testadapter.dll" buildMode)
)
Target "IntegrationTests" (fun _ ->
!! (sprintf "./Chauffeur.Tests.Integration/bin/%s/**/Chauffeur.Tests.Integration.dll" buildMode)
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit-integration.html") })
)
Target "CreateChauffeurPackage" (fun _ ->
let libDir = packagingDir @@ "lib/net45/"
CleanDirs [libDir]
CopyFile libDir (chauffeurDir @@ "Release/Chauffeur.dll")
CopyFiles packagingDir ["LICENSE.md"; "README.md"]
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = chauffeurDescription
OutputPath = packagingRoot
Summary = chauffeurSummary
WorkingDir = packagingDir
Version = nugetVersion
ReleaseNotes = toLines releaseNotes.Notes
SymbolPackage = NugetSymbolPackage.Nuspec
AccessKey = getBuildParamOrDefault "nugetkey" ""
Dependencies =
["System.IO.Abstractions", "1.4.0.83"]
Publish = hasBuildParam "nugetkey" }) "Chauffeur/Chauffeur.nuspec"
)
Target "CreateRunnerPackage" (fun _ ->
let libDir = packagingRunnerDir @@ "lib/net45/"
CleanDirs [libDir]
CopyFile libDir (chauffeurRunnerDir @@ "Release/Chauffeur.Runner.exe")
CopyFiles packagingDir ["LICENSE.md"; "README.md"]
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = chauffeurRunnerDescription
OutputPath = packagingRoot
Summary = chauffeurRunnerSummary
WorkingDir = packagingRunnerDir
Version = nugetVersion
ReleaseNotes = toLines releaseNotes.Notes
SymbolPackage = NugetSymbolPackage.Nuspec
Dependencies =
["Chauffeur", NormalizeVersion nugetVersion]
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey" }) "Chauffeur.Runner/Chauffeur.Runner.nuspec"
)
Target "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" nugetVersion) |> ignore
)
Target "Package" DoNothing
Target "Lint" (fun _ ->
!! "src/**/*.fsproj"
|> Seq.iter (FSharpLint id))
"Clean"
=?> ("BuildVersion", isAppVeyorBuild)
==> "Lint"
==> "Build"
"RestoreChauffeurPackages"
==> "RestoreChauffeurDemoPackages"
==> "RestoreChauffeurTestsPackages"
==> "Build"
"UnitTests"
==> "Default"
"EnsureSqlExpressAssemblies"
==> "CleanXUnitVSRunner"
==> "IntegrationTests"
"CreateChauffeurPackage"
==> "CreateRunnerPackage"
==> "Package"
RunTargetOrDefault "Default"