Skip to content

Commit 6d9f26b

Browse files
authored
Merge pull request #494 from tarides/dev-repo
Allow to overwrite the dev-repo field when creating a GH tag/release
2 parents 8e235b2 + be7972e commit 6d9f26b

File tree

8 files changed

+37
-15
lines changed

8 files changed

+37
-15
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Add `dune-release delegate-info version` to show the current version as infered
66
by the tool (#495, @samoht)
7+
- Add `--dev-repo` to `dune-release` and `dune-release publish` to overwrite
8+
the `dev-repo` field specified in the opam file (#494, @samoht)
79

810
### Changed
911

bin/bistro.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ let bistro () (`Dry_run dry_run) (`Package_names pkg_names)
1414
(`Include_submodules include_submodules) (`Draft draft)
1515
(`Keep_build_dir keep_dir) (`Skip_lint skip_lint) (`Skip_build skip_build)
1616
(`Skip_tests skip_tests) (`Local_repo local_repo) (`Remote_repo remote_repo)
17-
(`Opam_repo opam_repo) (`No_auto_open no_auto_open) =
17+
(`Opam_repo opam_repo) (`No_auto_open no_auto_open) (`Dev_repo dev_repo) =
1818
Cli.handle_error
1919
( Dune_release.Config.token ~token ~dry_run () >>= fun token ->
2020
let token = Dune_release.Config.Cli.make token in
2121
Distrib.distrib ~dry_run ~pkg_names ~version ~tag ~keep_v ~keep_dir
2222
~skip_lint ~skip_build ~skip_tests ~include_submodules ()
2323
>! fun () ->
24-
Publish.publish ~token ~pkg_names ~version ~tag ~keep_v ~dry_run
24+
Publish.publish ~token ~pkg_names ~version ~tag ~keep_v ~dry_run ?dev_repo
2525
~publish_artefacts:[] ~yes:false ~draft ()
2626
>! fun () ->
2727
Opam.get_pkgs ~dry_run ~keep_v ~tag ~pkg_names ~version () >>= fun pkgs ->
@@ -55,7 +55,8 @@ let term =
5555
const bistro $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version
5656
$ Cli.dist_tag $ Cli.keep_v $ Cli.token $ Cli.include_submodules $ Cli.draft
5757
$ Cli.keep_build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests
58-
$ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo $ Cli.no_auto_open)
58+
$ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo $ Cli.no_auto_open
59+
$ Cli.dev_repo)
5960

6061
let info = Cmd.info "bistro" ~doc ~sdocs ~exits ~man ~man_xrefs
6162
let cmd = Cmd.v info term

bin/cli.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ let remote_repo =
227227
in
228228
named (fun x -> `Remote_repo x) (config_opt arg)
229229

230+
let dev_repo =
231+
let doc = "Location of the dev repo of the current package" in
232+
let env = Cmd.Env.info "DUNE_RELEASE_DEV_REPO" in
233+
let arg =
234+
Arg.(
235+
value & opt (some string) None & info ~env [ "dev-repo" ] ~doc ~docv:"URI")
236+
in
237+
named (fun x -> `Dev_repo x) arg
238+
230239
let opam_repo =
231240
let doc =
232241
"The Github opam-repository to which packages should be released. Use this \

bin/cli.mli

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ val local_repo :
8787
(** A [--local-repo] option to define the location of the local fork of
8888
opam-repository. *)
8989

90+
val dev_repo : [ `Dev_repo of string option ] Term.t
91+
(** A [--dev-repo] option to define the Github opam-repository to which packages
92+
should be released. *)
93+
9094
val remote_repo :
9195
[ `Remote_repo of string Dune_release.Config.Cli.t option ] Term.t
9296
(** A [--remote-repo] option to define the location of the remote fork of
9397
opam-repository. *)
9498

9599
val opam_repo : [ `Opam_repo of (string * string) option ] Term.t
96-
(** A [--opam_repo] option to define the Github opam-repository to which
100+
(** A [--opam-repo] option to define the Github opam-repository to which
97101
packages should be released. *)
98102

99103
val skip_lint : [> `Skip_lint of bool ] Term.t

bin/publish.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ let publish_doc ~specific ~dry_run ~yes pkg_names pkg =
5151
Ok ()
5252
| Ok _ -> publish_doc ~dry_run ~yes pkg_names pkg
5353

54-
let publish_distrib ?token ~dry_run ~yes ~draft pkg =
54+
let publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg =
5555
App_log.status (fun l -> l "Publishing distribution");
5656
Pkg.distrib_file ~dry_run pkg >>= fun archive ->
5757
Pkg.publish_msg pkg >>= fun msg ->
5858
App_log.status (fun l -> l "Publishing to github");
5959
Config.token ~token ~dry_run () >>= fun token ->
60-
Github.publish_distrib ~token ~dry_run ~yes ~msg ~archive ~draft pkg
60+
Github.publish_distrib ~token ~dry_run ~yes ~msg ~archive ~draft ?dev_repo pkg
6161
>>= fun url ->
6262
Pkg.archive_url_path pkg >>= fun url_file ->
6363
Sos.write_file ~dry_run url_file url >>= fun () -> Ok ()
6464

6565
let publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token
66-
~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft ()
67-
=
66+
?dev_repo ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes
67+
~draft () =
6868
let specific_doc =
6969
List.exists (function `Doc -> true | _ -> false) publish_artefacts
7070
in
@@ -80,7 +80,7 @@ let publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token
8080
acc >>= fun () ->
8181
match artefact with
8282
| `Doc -> publish_doc ~specific:specific_doc ~dry_run ~yes pkg_names pkg
83-
| `Distrib -> publish_distrib ?token ~dry_run ~yes ~draft pkg
83+
| `Distrib -> publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg
8484
in
8585
List.fold_left publish_artefact (Ok ()) publish_artefacts >>= fun () -> Ok 0
8686

@@ -89,9 +89,10 @@ let publish_cli () (`Build_dir build_dir) (`Package_names pkg_names)
8989
(`Dist_opam opam) (`Change_log change_log) (`Dist_file distrib_file)
9090
(`Publish_msg publish_msg) (`Dry_run dry_run)
9191
(`Publish_artefacts publish_artefacts) (`Yes yes) (`Token token)
92-
(`Draft draft) =
92+
(`Draft draft) (`Dev_repo dev_repo) =
9393
publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token
94-
~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft ()
94+
~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft
95+
?dev_repo ()
9596
|> Cli.handle_error
9697

9798
(* Command line interface *)
@@ -149,7 +150,7 @@ let term =
149150
const publish_cli $ Cli.setup $ Cli.build_dir $ Cli.pkg_names
150151
$ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v $ Cli.dist_opam
151152
$ Cli.change_log $ Cli.dist_file $ Cli.publish_msg $ Cli.dry_run $ artefacts
152-
$ Cli.yes $ Cli.token $ Cli.draft)
153+
$ Cli.yes $ Cli.token $ Cli.draft $ Cli.dev_repo)
153154

154155
let info = Cmd.info "publish" ~doc ~sdocs ~exits ~man ~man_xrefs
155156
let cmd = Cmd.v info term

bin/publish.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ val publish :
1313
?distrib_file:Fpath.t ->
1414
?publish_msg:string ->
1515
?token:string Dune_release.Config.Cli.t ->
16+
?dev_repo:string ->
1617
pkg_names:string list ->
1718
version:Dune_release.Version.t option ->
1819
tag:Dune_release.Vcs.Tag.t option ->

lib/github.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ let undraft_pr ~token ~dry_run ~opam_repo:(user, repo) ~pr_id =
283283
run_with_auth ~dry_run ~default_body curl_t
284284
>>= Github_v4_api.Pull_request.Response.url
285285

286-
let dev_repo p =
286+
let pkg_dev_repo p =
287287
Pkg.dev_repo p >>= function
288288
| Some r -> Ok r
289289
| None ->
@@ -432,13 +432,16 @@ let create_release ~dry_run ~yes ~dev_repo ~token ~msg ~tag ~version ~user ~repo
432432
App_log.status (fun l -> l "Release with id %d already exists" id);
433433
Ok id
434434

435-
let publish_distrib ~token ~dry_run ~msg ~archive ~yes ~draft p =
435+
let publish_distrib ~token ?dev_repo ~dry_run ~msg ~archive ~yes ~draft p =
436436
Pkg.infer_github_repo p >>= fun { owner; repo } ->
437437
Pkg.tag p >>= fun tag ->
438438
assert_tag_exists ~dry_run tag >>= fun () ->
439439
Vcs.get () >>= fun vcs ->
440440
check_tag ~dry_run vcs tag >>= fun () ->
441-
dev_repo p >>= fun dev_repo ->
441+
let dev_repo =
442+
match dev_repo with Some d -> Ok d | None -> pkg_dev_repo p
443+
in
444+
dev_repo >>= fun dev_repo ->
442445
Pkg.build_dir p >>= fun build_dir ->
443446
Pkg.name p >>= fun name ->
444447
Pkg.version p >>= fun version ->

lib/github.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ end
1717

1818
val publish_distrib :
1919
token:string ->
20+
?dev_repo:string ->
2021
dry_run:bool ->
2122
msg:string ->
2223
archive:Fpath.t ->

0 commit comments

Comments
 (0)