-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
74 lines (59 loc) · 2.15 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
#r "nuget: Fun.Build, 1.0.5"
open Fun.Build
open System.IO
let options = {|
GithubAction = EnvArg.Create("GITHUB_ACTION", description = "Run only in in github action container")
|}
let stage_update_manifest =
stage "Update Manifest" {
run(fun _ ->
let version =
Changelog.GetLastVersion(__SOURCE_DIRECTORY__)
|> Option.defaultWith(fun () -> failwith "Version is not found")
let fileName =
Path.Combine(__SOURCE_DIRECTORY__, "src/com.sergeytihon.homebridge.sdPlugin/manifest.json")
let lines =
File.ReadAllLines fileName
|> Seq.map(fun line ->
if line.TrimStart().StartsWith($"\"Version\":") then
let indent = line.Substring(0, line.IndexOf("\""))
sprintf "%s\"%s\": \"%s\"," indent "Version" version.Version
else
line)
File.WriteAllLines(fileName, lines))
}
pipeline "build" {
workingDir __SOURCE_DIRECTORY__
runBeforeEachStage(fun ctx ->
if ctx.GetStageLevel() = 0 then
printfn $"::group::{ctx.Name}")
runAfterEachStage(fun ctx ->
if ctx.GetStageLevel() = 0 then
printfn "::endgroup::")
stage "Check environment" {
run "dotnet tool restore"
run "dotnet paket restore"
run "npm install"
run(fun ctx -> printfn $"""github action name: {ctx.GetEnvVar options.GithubAction.Name}""")
}
stage "Lint" {
stage "Format" {
whenNot { envVar options.GithubAction }
run "dotnet fantomas ."
}
stage "Check" {
whenEnvVar options.GithubAction
run "dotnet fantomas . --check"
}
}
stage "Build" {
run "rm -rf ./bin"
run "mkdir bin"
stage_update_manifest
run "cp -r ./src/com.sergeytihon.homebridge.sdPlugin ./bin/com.sergeytihon.homebridge.sdPlugin"
run "npm run build"
run "./DistributionTool -b -i bin/com.sergeytihon.homebridge.sdPlugin -o ./bin"
}
runIfOnlySpecified
}
tryPrintPipelineCommandHelp()