diff --git a/bin/bistro.ml b/bin/bistro.ml index 53d0b962..e13acc26 100644 --- a/bin/bistro.ml +++ b/bin/bistro.ml @@ -14,14 +14,14 @@ let bistro () (`Dry_run dry_run) (`Package_names pkg_names) (`Include_submodules include_submodules) (`Draft draft) (`Keep_build_dir keep_dir) (`Skip_lint skip_lint) (`Skip_build skip_build) (`Skip_tests skip_tests) (`Local_repo local_repo) (`Remote_repo remote_repo) - (`Opam_repo opam_repo) (`No_auto_open no_auto_open) = + (`Opam_repo opam_repo) (`No_auto_open no_auto_open) (`Dev_repo dev_repo) = Cli.handle_error ( Dune_release.Config.token ~token ~dry_run () >>= fun token -> let token = Dune_release.Config.Cli.make token in Distrib.distrib ~dry_run ~pkg_names ~version ~tag ~keep_v ~keep_dir ~skip_lint ~skip_build ~skip_tests ~include_submodules () >! fun () -> - Publish.publish ~token ~pkg_names ~version ~tag ~keep_v ~dry_run + Publish.publish ~token ~pkg_names ~version ~tag ~keep_v ~dry_run ?dev_repo ~publish_artefacts:[] ~yes:false ~draft () >! fun () -> Opam.get_pkgs ~dry_run ~keep_v ~tag ~pkg_names ~version () >>= fun pkgs -> @@ -55,7 +55,8 @@ let term = const bistro $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v $ Cli.token $ Cli.include_submodules $ Cli.draft $ Cli.keep_build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests - $ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo $ Cli.no_auto_open) + $ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo $ Cli.no_auto_open + $ Cli.dev_repo) let info = Cmd.info "bistro" ~doc ~sdocs ~exits ~man ~man_xrefs let cmd = Cmd.v info term diff --git a/bin/cli.ml b/bin/cli.ml index d912ba1c..49567a87 100644 --- a/bin/cli.ml +++ b/bin/cli.ml @@ -227,6 +227,15 @@ let remote_repo = in named (fun x -> `Remote_repo x) (config_opt arg) +let dev_repo = + let doc = "Location of the dev repo of the current package" in + let env = Cmd.Env.info "DUNE_RELEASE_DEV_REPO" in + let arg = + Arg.( + value & opt (some string) None & info ~env [ "dev-repo" ] ~doc ~docv:"URI") + in + named (fun x -> `Dev_repo x) arg + let opam_repo = let doc = "The Github opam-repository to which packages should be released. Use this \ diff --git a/bin/cli.mli b/bin/cli.mli index 7ce4b5c3..0a4e3981 100644 --- a/bin/cli.mli +++ b/bin/cli.mli @@ -87,13 +87,17 @@ val local_repo : (** A [--local-repo] option to define the location of the local fork of opam-repository. *) +val dev_repo : [ `Dev_repo of string option ] Term.t +(** A [--dev-repo] option to define the Github opam-repository to which packages + should be released. *) + val remote_repo : [ `Remote_repo of string Dune_release.Config.Cli.t option ] Term.t (** A [--remote-repo] option to define the location of the remote fork of opam-repository. *) val opam_repo : [ `Opam_repo of (string * string) option ] Term.t -(** A [--opam_repo] option to define the Github opam-repository to which +(** A [--opam-repo] option to define the Github opam-repository to which packages should be released. *) val skip_lint : [> `Skip_lint of bool ] Term.t diff --git a/bin/publish.ml b/bin/publish.ml index 11dc43cf..e6fb3fd0 100644 --- a/bin/publish.ml +++ b/bin/publish.ml @@ -51,20 +51,20 @@ let publish_doc ~specific ~dry_run ~yes pkg_names pkg = Ok () | Ok _ -> publish_doc ~dry_run ~yes pkg_names pkg -let publish_distrib ?token ~dry_run ~yes ~draft pkg = +let publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg = App_log.status (fun l -> l "Publishing distribution"); Pkg.distrib_file ~dry_run pkg >>= fun archive -> Pkg.publish_msg pkg >>= fun msg -> 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 + Github.publish_distrib ~token ~dry_run ~yes ~msg ~archive ~draft ?dev_repo pkg >>= fun url -> Pkg.archive_url_path pkg >>= fun url_file -> Sos.write_file ~dry_run url_file url >>= fun () -> Ok () let publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token - ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft () - = + ?dev_repo ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes + ~draft () = let specific_doc = List.exists (function `Doc -> true | _ -> false) publish_artefacts in @@ -80,7 +80,7 @@ let publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token acc >>= fun () -> match artefact with | `Doc -> publish_doc ~specific:specific_doc ~dry_run ~yes pkg_names pkg - | `Distrib -> publish_distrib ?token ~dry_run ~yes ~draft pkg + | `Distrib -> publish_distrib ?token ~dry_run ~yes ~draft ?dev_repo pkg in List.fold_left publish_artefact (Ok ()) publish_artefacts >>= fun () -> Ok 0 @@ -89,9 +89,10 @@ let publish_cli () (`Build_dir build_dir) (`Package_names pkg_names) (`Dist_opam opam) (`Change_log change_log) (`Dist_file distrib_file) (`Publish_msg publish_msg) (`Dry_run dry_run) (`Publish_artefacts publish_artefacts) (`Yes yes) (`Token token) - (`Draft draft) = + (`Draft draft) (`Dev_repo dev_repo) = publish ?build_dir ?opam ?change_log ?distrib_file ?publish_msg ?token - ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft () + ~pkg_names ~version ~tag ~keep_v ~dry_run ~publish_artefacts ~yes ~draft + ?dev_repo () |> Cli.handle_error (* Command line interface *) @@ -149,7 +150,7 @@ let term = const publish_cli $ Cli.setup $ Cli.build_dir $ Cli.pkg_names $ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v $ Cli.dist_opam $ Cli.change_log $ Cli.dist_file $ Cli.publish_msg $ Cli.dry_run $ artefacts - $ Cli.yes $ Cli.token $ Cli.draft) + $ Cli.yes $ Cli.token $ Cli.draft $ Cli.dev_repo) let info = Cmd.info "publish" ~doc ~sdocs ~exits ~man ~man_xrefs let cmd = Cmd.v info term diff --git a/bin/publish.mli b/bin/publish.mli index 1b10938f..c027f0ce 100644 --- a/bin/publish.mli +++ b/bin/publish.mli @@ -13,6 +13,7 @@ val publish : ?distrib_file:Fpath.t -> ?publish_msg:string -> ?token:string Dune_release.Config.Cli.t -> + ?dev_repo:string -> pkg_names:string list -> version:Dune_release.Version.t option -> tag:Dune_release.Vcs.Tag.t option -> diff --git a/lib/github.ml b/lib/github.ml index f41e4bb8..9121641b 100644 --- a/lib/github.ml +++ b/lib/github.ml @@ -283,7 +283,7 @@ let undraft_pr ~token ~dry_run ~opam_repo:(user, repo) ~pr_id = run_with_auth ~dry_run ~default_body curl_t >>= Github_v4_api.Pull_request.Response.url -let dev_repo p = +let pkg_dev_repo p = Pkg.dev_repo p >>= function | Some r -> Ok r | None -> @@ -432,13 +432,16 @@ let create_release ~dry_run ~yes ~dev_repo ~token ~msg ~tag ~version ~user ~repo App_log.status (fun l -> l "Release with id %d already exists" id); Ok id -let publish_distrib ~token ~dry_run ~msg ~archive ~yes ~draft p = +let publish_distrib ~token ?dev_repo ~dry_run ~msg ~archive ~yes ~draft p = Pkg.infer_github_repo p >>= fun { owner; repo } -> Pkg.tag p >>= fun tag -> assert_tag_exists ~dry_run tag >>= fun () -> Vcs.get () >>= fun vcs -> check_tag ~dry_run vcs tag >>= fun () -> - dev_repo p >>= fun dev_repo -> + let dev_repo = + match dev_repo with Some d -> Ok d | None -> pkg_dev_repo p + in + dev_repo >>= fun dev_repo -> Pkg.build_dir p >>= fun build_dir -> Pkg.name p >>= fun name -> Pkg.version p >>= fun version -> diff --git a/lib/github.mli b/lib/github.mli index f19f3a24..82a9f332 100644 --- a/lib/github.mli +++ b/lib/github.mli @@ -17,6 +17,7 @@ end val publish_distrib : token:string -> + ?dev_repo:string -> dry_run:bool -> msg:string -> archive:Fpath.t ->