7
7
open Bos_setup
8
8
open Dune_release
9
9
10
- let gen_doc ~dry_run ~force dir pkg_names =
11
- let names = String. concat ~sep: " ," pkg_names in
12
- let build_doc = Cmd. (v " dune" % " build" % " -p" % names % " @doc" ) in
13
- let doc_dir = Pkg. doc_dir in
14
- let do_doc () = Sos. run ~dry_run ~force build_doc in
15
- R. join @@ Sos. with_dir ~dry_run dir do_doc () >> = fun () ->
16
- Ok Fpath. (dir // doc_dir)
17
-
18
- let publish_doc ~dry_run ~yes pkg_names pkg =
19
- App_log. status (fun l -> l " Publishing documentation" );
20
- Pkg. distrib_file ~dry_run pkg >> = fun archive ->
21
- Pkg. publish_msg pkg >> = fun msg ->
22
- Archive. untbz ~dry_run ~clean: true archive >> = fun dir ->
23
- OS.Dir. exists dir >> = fun force ->
24
- Pkg. infer_pkg_names dir pkg_names >> = fun pkg_names ->
25
- App_log. status (fun l ->
26
- l " Selected packages: %a"
27
- Fmt. (list ~sep: (any " @ " ) (styled `Bold string ))
28
- pkg_names);
29
- App_log. status (fun l ->
30
- l " Generating documentation from %a" Text.Pp. path archive);
31
- gen_doc ~dry_run ~force dir pkg_names >> = fun docdir ->
32
- App_log. status (fun l -> l " Publishing to github" );
33
- Github. publish_doc ~dry_run ~msg ~docdir ~yes pkg
34
-
35
- let pp_field = Fmt. (styled `Bold string )
36
-
37
- (* If `publish doc` is invoked explicitly from the CLI, we should fail if the
38
- documentation cannot be published. If it is not called explicitly, we can
39
- skip this step if the `doc` field of the opam file is not set. *)
40
- let publish_doc ~specific ~dry_run ~yes pkg_names pkg =
41
- match Pkg. doc_uri pkg with
42
- | _ when specific -> publish_doc ~dry_run ~yes pkg_names pkg
43
- | Error _ | Ok "" ->
44
- Pkg. name pkg >> = fun name ->
45
- Pkg. opam pkg >> = fun opam ->
46
- App_log. status (fun l ->
47
- l
48
- " Skipping documentation publication for package %s: no %a field in \
49
- %a"
50
- name pp_field " doc" Fpath. pp opam);
51
- Ok ()
52
- | Ok _ -> publish_doc ~dry_run ~yes pkg_names pkg
53
-
54
10
let publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg =
55
11
App_log. status (fun l -> l " Publishing distribution" );
56
12
Pkg. distrib_file ~dry_run pkg >> = fun archive ->
@@ -63,63 +19,26 @@ let publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg =
63
19
Sos. write_file ~dry_run url_file url >> = fun () -> Ok ()
64
20
65
21
let publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token
66
- ?dev_repo ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes
67
- ~draft () =
68
- let specific_doc =
69
- List. exists (function `Doc -> true | _ -> false ) publish_artefacts
70
- in
71
- let publish_artefacts =
72
- match publish_artefacts with [] -> [ `Doc ; `Distrib ] | v -> v
73
- in
22
+ ?dev_repo ~version ~tag ~keep_v ~dry_run ~yes ~draft () =
74
23
Config. keep_v ~keep_v >> = fun keep_v ->
75
24
let pkg =
76
25
Pkg. v ~dry_run ?version ?tag ~keep_v ?build_dir ?opam ?change_log
77
26
?distrib_file ?publish_msg ()
78
27
in
79
- let publish_artefact acc artefact =
80
- acc >> = fun () ->
81
- match artefact with
82
- | `Doc -> publish_doc ~specific: specific_doc ~dry_run ~yes pkg_names pkg
83
- | `Distrib -> publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg
84
- in
85
- List. fold_left publish_artefact (Ok () ) publish_artefacts >> = fun () -> Ok 0
28
+ publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg >> = fun () -> Ok 0
86
29
87
- let publish_cli () (`Build_dir build_dir ) (`Package_names pkg_names )
88
- (`Package_version version ) (`Dist_tag tag ) (`Keep_v keep_v )
89
- (`Dist_opam opam ) (`Change_log change_log ) (`Dist_file distrib_file )
90
- (`Publish_msg publish_msg ) (`Dry_run dry_run )
91
- (`Publish_artefacts publish_artefacts ) (`Yes yes ) (`Token token )
92
- (`Draft draft ) (`Dev_repo dev_repo ) =
30
+ let publish_cli () (`Build_dir build_dir ) (`Package_version version )
31
+ (`Dist_tag tag ) (`Keep_v keep_v ) (`Dist_opam opam ) (`Change_log change_log )
32
+ (`Dist_file distrib_file ) (`Publish_msg publish_msg ) (`Dry_run dry_run )
33
+ (`Yes yes ) (`Token token ) (`Draft draft ) (`Dev_repo dev_repo ) =
93
34
publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token
94
- ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft
95
- ?dev_repo ()
35
+ ~version ~tag ~keep_v ~dry_run ~yes ~draft ?dev_repo ()
96
36
|> Cli. handle_error
97
37
98
38
(* Command line interface *)
99
39
100
40
open Cmdliner
101
41
102
- let artefacts =
103
- let parser = function
104
- | "do" | "doc" -> `Ok `Doc
105
- | "di" | "dis" | "dist" | "distr" | "distri" | "distrib" -> `Ok `Distrib
106
- | s -> `Error (strf " `%s' unknown publication artefact" s)
107
- in
108
- let printer ppf = function
109
- | `Doc -> Fmt. string ppf " doc"
110
- | `Distrib -> Fmt. string ppf " distrib"
111
- in
112
- let artefact = (parser, printer) in
113
- let doc =
114
- strf
115
- " The artefact to publish. $(docv) must be either `doc` or `distrib`. If \
116
- absent, the set of default publication artefacts is determined by the \
117
- package description."
118
- in
119
- Cli. named
120
- (fun x -> `Publish_artefacts x)
121
- Arg. (value & pos_all artefact [] & info [] ~doc ~docv: " ARTEFACT" )
122
-
123
42
let doc = " Publish package distribution archives and/or documentation."
124
43
let sdocs = Manpage. s_common_options
125
44
let exits = Cli. exits
@@ -128,29 +47,20 @@ let man_xrefs = [ `Main; `Cmd "distrib" ]
128
47
let man =
129
48
[
130
49
`S Manpage. s_synopsis;
131
- `P " $(mname) $(tname) [$(i,OPTION)]... [$(i,ARTEFACT)]... " ;
50
+ `P " $(mname) $(tname) [$(i,OPTION)]..." ;
132
51
`S Manpage. s_description;
133
- `P
134
- " The $(tname) command publishes package distribution archives and/or \
135
- documentation." ;
52
+ `P " The $(tname) command publishes package distribution archives." ;
136
53
`P
137
54
" Artefact publication always relies on a distribution archive having \
138
55
been generated before with dune-release-distrib(1)." ;
139
- `S " ARTEFACTS" ;
140
- `I
141
- ( " $(b,distrib)" ,
142
- " Publishes a distribution archive as part of a Github release." );
143
- `I
144
- ( " $(b,doc)" ,
145
- " Publishes the documentation of a distribution archive to gh-pages." );
146
56
]
147
57
148
58
let term =
149
59
Term. (
150
- const publish_cli $ Cli. setup $ Cli. build_dir $ Cli. pkg_names
151
- $ Cli. pkg_version $ Cli. dist_tag $ Cli. keep_v $ Cli. dist_opam
152
- $ Cli. change_log $ Cli. dist_file $ Cli. publish_msg $ Cli. dry_run $ artefacts
153
- $ Cli. yes $ Cli. token $ Cli. draft $ Cli. dev_repo)
60
+ const publish_cli $ Cli. setup $ Cli. build_dir $ Cli. pkg_version
61
+ $ Cli. dist_tag $ Cli. keep_v $ Cli. dist_opam $ Cli. change_log $ Cli. dist_file
62
+ $ Cli. publish_msg $ Cli. dry_run $ Cli. yes $ Cli. token $ Cli. draft
63
+ $ Cli. dev_repo)
154
64
155
65
let info = Cmd. info " publish" ~doc ~sdocs ~exits ~man ~man_xrefs
156
66
let cmd = Cmd. v info term
0 commit comments