-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathReleaseTasks.fs
168 lines (133 loc) · 4.7 KB
/
ReleaseTasks.fs
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
module ReleaseTasks
open MessagePrompts
open ProjectInfo
open BasicTasks
open TestTasks
open PackageTasks
open DocumentationTasks
open BlackFox.Fake
open Fake.Core
open Fake.DotNet
open Fake.Api
open Fake.Tools
open Fake.IO
open Fake.IO.Globbing.Operators
let createTag =
BuildTask.create "CreateTag" [ clean; build; runTestsAll; pack ] {
if promptYesNo (sprintf "tagging branch with %s OK?" branchTag) then
Git.Branches.tag "" branchTag
Git.Branches.pushTag "" projectRepo branchTag
else
failwith "aborted"
}
let createPrereleaseTag =
BuildTask.create
"CreatePrereleaseTag"
[
setPrereleaseTag
clean
build
runTestsAll
packPrerelease
] {
if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag) then
Git.Branches.tag "" prereleaseTag
Git.Branches.pushTag "" projectRepo prereleaseTag
else
failwith "aborted"
}
let publishNuget =
BuildTask.create "PublishNuget" [ clean; build; runTestsAll; pack ] {
let targets =
(!!(sprintf "%s/*.*pkg" pkgDir))
printfn "package files:"
for target in targets do
printfn "%A" target
printfn "package versions to release:"
projects
|> List.iter (fun p ->
printfn $"{p.Name} @ {p.PackageVersionTag}"
)
if promptYesNo "OK?" then
let source =
"https://api.nuget.org/v3/index.json"
let apikey =
Environment.environVar "NUGET_KEY"
for artifact in targets do
let result =
DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact)
if not result.OK then
failwith "failed to push packages"
else
failwith "aborted"
}
let publishNugetPrerelease =
BuildTask.create
"PublishNugetPrerelease"
[
clean
build
runTestsAll
packPrerelease
] {
let targets =
(!!(sprintf "%s/*.*pkg" pkgDir))
printfn "package files:"
for target in targets do
printfn "%A" target
printfn "package versions to release:"
projects
|> List.iter (fun p ->
printfn $"{p.Name} @ {p.PackagePrereleaseTag}"
)
if promptYesNo "OK?" then
let source =
"https://api.nuget.org/v3/index.json"
let apikey =
Environment.environVar "NUGET_KEY"
for artifact in targets do
let result =
DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact)
if not result.OK then
failwith "failed to push packages"
else
failwith "aborted"
}
let releaseDocs =
BuildTask.create "ReleaseDocs" [ buildDocs ] {
let msg =
sprintf "release docs for version %s?" stableDocsVersionTag
if promptYesNo msg then
Shell.cleanDir "temp"
Git.CommandHelper.runSimpleGitCommand
"."
(sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo)
|> ignore
Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A"
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
let cmd =
sprintf """commit -a -m "Update generated documentation for version %s""" stableDocsVersionTag
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
Git.Branches.push "temp/gh-pages"
else
failwith "aborted"
}
let prereleaseDocs =
BuildTask.create "PrereleaseDocs" [ buildDocsPrerelease ] {
let msg =
sprintf "release docs for version %s?" prereleaseTag
if promptYesNo msg then
Shell.cleanDir "temp"
Git.CommandHelper.runSimpleGitCommand
"."
(sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo)
|> ignore
Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A"
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
let cmd =
sprintf """commit -a -m "Update generated documentation for version %s""" prereleaseTag
Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
Git.Branches.push "temp/gh-pages"
else
failwith "aborted"
}