forked from ionide/FsAutoComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
190 lines (149 loc) · 6.33 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#r "paket: groupref build //"
#load ".fake/build.fsx/intellisense.fsx"
// open Fake
open Fake.Core
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.DotNet
open Fake.Core.TargetOperators
open Fake.Api
open Fake.Tools
let project = "FsAutoComplete"
// Read additional information from the release notes document
let release = ReleaseNotes.load "RELEASE_NOTES.md"
let configuration = Environment.environVarOrDefault "configuration" "Release"
let buildDir = "src" </> project </> "bin" </> "Debug"
let buildReleaseDir = "src" </> project </> "bin" </> "Release"
let pkgsDir = "bin" </> "pkgs"
let releaseArchive = pkgsDir </> "fsautocomplete.zip"
let releaseArchiveNetCore = pkgsDir </> "fsautocomplete.netcore.zip"
let gitOwner = "fsharp"
let gitName = project
let gitHome = "https://github.com/" + gitOwner
Target.initEnvironment ()
Target.create "LspTest" (fun _ ->
DotNet.exec
(fun p ->
{ p with
Timeout = Some (System.TimeSpan.FromMinutes 10.) })
"run"
"""-c Release --no-build -p "./test/FsAutoComplete.Tests.Lsp/FsAutoComplete.Tests.Lsp.fsproj" -- --fail-on-focused-tests --debug --summary"""
|> fun r -> if not r.OK then failwithf "Errors while running LSP tests:\n%s" (r.Errors |> String.concat "\n\t")
)
Target.create "ReleaseArchive" (fun _ ->
Shell.cleanDirs [ "bin/pkgs" ]
Directory.ensure "bin/pkgs"
!! "bin/release/**/*"
|> Zip.zip "bin/release" releaseArchive
!! "bin/release_netcore/**/*"
|> Zip.zip "bin/release_netcore" releaseArchiveNetCore
!! (sprintf "bin/release_as_tool/fsautocomplete.%s.nupkg" release.AssemblyVersion)
|> Shell.copy "bin/pkgs"
!! (sprintf "bin/project_system/ProjectSystem.%s.nupkg" release.AssemblyVersion)
|> Shell.copy "bin/pkgs"
)
Target.create "LocalRelease" (fun _ ->
Directory.ensure "bin/release"
Shell.cleanDirs [ "bin/release"; "bin/release_netcore" ]
DotNet.publish (fun p ->
{ p with
OutputPath = Some (__SOURCE_DIRECTORY__ </> "bin/release")
Framework = Some "net461"
Configuration = DotNet.BuildConfiguration.fromString configuration
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = [ "SourceLinkCreate","true"; "Version", release.AssemblyVersion ] } }) "src/FsAutoComplete"
Shell.cleanDirs [ "bin/release_netcore" ]
DotNet.publish (fun p ->
{ p with
OutputPath = Some (__SOURCE_DIRECTORY__ </> "bin/release_netcore")
Framework = Some "netcoreapp2.1"
Configuration = DotNet.BuildConfiguration.fromString configuration
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = [ "SourceLinkCreate","true"; "Version", release.AssemblyVersion ] } }) "src/FsAutoComplete"
Shell.cleanDirs [ "bin/release_as_tool" ]
DotNet.publish (fun p ->
{ p with
OutputPath = Some (__SOURCE_DIRECTORY__ </> "bin/release_as_tool")
Configuration = DotNet.BuildConfiguration.fromString configuration
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = [ "SourceLinkCreate","true"; "Version", release.AssemblyVersion; "PackAsTool", "true" ] } }) "src/FsAutoComplete"
Shell.cleanDirs [ "bin/project_system" ]
DotNet.pack (fun p ->
{ p with
OutputPath = Some ( __SOURCE_DIRECTORY__ </> "bin/project_system")
Configuration = DotNet.BuildConfiguration.fromString configuration
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = [ "SourceLinkCreate","true"; "Version", release.AssemblyVersion ] } }) "src/ProjectSystem"
)
Target.create "Clean" (fun _ ->
Shell.cleanDirs [ buildDir; buildReleaseDir; pkgsDir ]
)
Target.create "Restore" (fun _ ->
DotNet.restore id ""
)
Target.create "Build" (fun _ ->
DotNet.build (fun p ->
{ p with
Configuration = DotNet.BuildConfiguration.fromString configuration
MSBuildParams = { MSBuild.CliArguments.Create () with Properties = [ "SourceLinkCreate","true"; "Version", release.AssemblyVersion ] } }) "FsAutoComplete.sln"
)
Target.create "ReplaceFsLibLogNamespaces" <| fun _ ->
let replacements =
[ "FsLibLog\\n", "FsAutoComplete.Logging\n"
"FsLibLog\\.", "FsAutoComplete.Logging" ]
replacements
|> List.iter (fun (``match``, replace) ->
(!! "paket-files/TheAngryByrd/FsLibLog/**/FsLibLog*.fs")
|> Shell.regexReplaceInFilesWithEncoding ``match`` replace System.Text.Encoding.UTF8
)
Target.create "ReleaseGitHub" (fun _ ->
let remote =
Git.CommandHelper.getGitResult "" "remote -v"
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
Git.Staging.stageAll ""
Git.Commit.exec "" (sprintf "Bump version to %s" release.NugetVersion)
Git.Branches.pushBranch "" remote (Git.Information.getBranchName "")
Git.Branches.tag "" release.NugetVersion
Git.Branches.pushTag "" remote release.NugetVersion
let client =
let user =
match Environment.getBuildParam "github-user" with
| s when not (String.isNullOrWhiteSpace s) -> s
| _ -> UserInput.getUserInput "Username: "
let pw =
match Environment.getBuildParam "github-pw" with
| s when not (String.isNullOrWhiteSpace s) -> s
| _ -> UserInput.getUserPassword "Password: "
// Git.createClient user pw
GitHub.createClient user pw
let files = !! (pkgsDir </> "*.*")
let notes =
release.Notes
|> List.map (fun s -> "* " + s)
// release on github
let cl =
client
|> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) notes
(cl,files)
||> Seq.fold (fun acc e -> acc |> GitHub.uploadFile e)
|> GitHub.publishDraft//releaseDraft
|> Async.RunSynchronously
)
Target.create "NoOp" ignore
Target.create "Test" ignore
Target.create "All" ignore
Target.create "Release" ignore
"Restore"
==> "ReplaceFsLibLogNamespaces"
==> "Build"
"Build"
==> "LspTest"
==> "Test"
==> "All"
"ReplaceFsLibLogNamespaces"
==> "LocalRelease"
==> "ReleaseArchive"
==> "ReleaseGitHub"
==> "Release"
"ReleaseArchive"
==> "All"
Target.runOrDefaultWithArguments "Build"