use governor_application::release::{BumpInput, FullInput, PublishInput, full};
use crate::cli::OutputFormat;
use crate::cli::release::FullOpts;
use crate::error::{CommandExitCode, Result};
use crate::presenter::print_json;
use crate::runtime::{cargo_adapter, git_adapter, registry_adapter};
pub async fn execute(
workspace_path: &str,
opts: FullOpts,
_format: OutputFormat,
global_dry_run: bool,
) -> Result<CommandExitCode> {
let started_at = std::time::Instant::now();
let dry_run = global_dry_run || opts.dry_run;
let cargo = cargo_adapter();
let git = git_adapter(workspace_path)?;
let registry = registry_adapter();
let output = full(
&cargo,
&cargo,
&git,
®istry,
FullInput {
workspace_path: workspace_path.to_string(),
bump: BumpInput {
workspace_path: workspace_path.to_string(),
version: opts.version.clone(),
bump: opts.bump.clone(),
no_changelog: opts.no_changelog,
no_commit: opts.no_commit,
no_tag: opts.no_tag,
commit_template: None,
tag_template: None,
dry_run,
allow_version_drift: opts.allow_version_drift,
allow_dirty: opts.allow_dirty,
},
publish: PublishInput {
workspace_path: workspace_path.to_string(),
skip_checks: opts
.skip_checks
.then(|| "test,clippy,fmt,doc,build".to_string()),
only: opts.only.map(|values| values.join(",")),
exclude: opts.exclude.map(|values| values.join(",")),
delay: opts.delay,
max_retries: None,
on_error: None,
dry_run,
allow_version_drift: opts.allow_version_drift,
allow_dirty: opts.allow_dirty,
},
skip_checks: opts.skip_checks,
no_push: opts.no_push,
},
)
.await?;
let workspace = output.workspace.clone();
let success = output.publish.crates_failed.is_empty();
print_json(
"release.full",
Some(workspace),
success,
output,
started_at,
Vec::new(),
)?;
Ok(if success {
CommandExitCode::Success
} else {
CommandExitCode::PartialSuccess
})
}