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
open Bos_setup
let run_delegate ~dry_run del args =
let verbosity = Logs.level_to_string (Logs.level ()) in
Ok Cmd.(del % "ipc" % verbosity %% args) >>= fun cmd ->
Sos.run_status ~dry_run cmd >>= function
| `Exited 0 -> Ok ()
| `Exited 1 -> R.error_msgf "Action unsupported by delegate %a" Cmd.pp del
| `Exited n | `Signaled n ->
R.error_msgf "Delegate %a errored with %d" Cmd.pp del n
let publish_distrib ?token ?distrib_uri ~dry_run ~msg ~archive ~yes ~draft pkg =
Pkg.delegate pkg >>= function
| None ->
App_log.status (fun l -> l "Publishing to github");
Config.token ~token ~dry_run () >>= fun token ->
Github.publish_distrib ~token ~dry_run ~yes ~msg ~archive ~draft pkg
>>= fun url ->
Pkg.archive_url_path pkg >>= fun url_file ->
Sos.write_file ~dry_run url_file url >>= fun () -> Ok ()
| Some del ->
App_log.status (fun l -> l "Using delegate %a" Cmd.pp del);
App_log.unhappy (fun l ->
l Deprecate.Delegates.warning_usage Deprecate.Delegates.new_workflow);
Pkg.name pkg >>= fun name ->
Pkg.tag pkg >>= fun tag ->
(match distrib_uri with
| Some uri -> Ok uri
| None ->
Pkg.infer_github_distrib_uri pkg)
>>= fun distrib_uri ->
let tag = Vcs.Tag.to_string tag in
run_delegate ~dry_run del
Cmd.(
v "publish" % "distrib" % distrib_uri % name % tag % msg % p archive)
let publish_doc ~dry_run ~msg ~docdir ~yes pkg =
Pkg.delegate pkg >>= function
| None ->
App_log.status (fun l -> l "Publishing to github");
Github.publish_doc ~dry_run ~msg ~docdir ~yes pkg
| Some del ->
App_log.status (fun l -> l "Using delegate %a" Cmd.pp del);
Pkg.name pkg >>= fun name ->
Pkg.version pkg >>= fun version ->
Pkg.doc_uri pkg >>= fun doc_uri ->
let version = Version.to_string version in
run_delegate ~dry_run del
Cmd.(v "publish" % "doc" % doc_uri % name % version % msg % p docdir)
let publish_alt ?distrib_uri ~dry_run ~kind ~msg ~archive p =
Pkg.delegate p >>= function
| None -> R.error_msgf "No default delegate to publish %s" kind
| Some del ->
App_log.status (fun l -> l "Using delegate %a" Cmd.pp del);
Pkg.name p >>= fun name ->
Pkg.version p >>= fun version ->
(match distrib_uri with
| Some uri -> Ok uri
| None -> Pkg.infer_github_distrib_uri p)
>>= fun distrib_uri ->
let version = Version.to_string version in
run_delegate ~dry_run del
Cmd.(
v "publish" % "alt" % distrib_uri % kind % name % version % msg
% p archive)