cargo-governor 2.0.0

Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates
Documentation
//! Publish command.

use governor_application::release::{PublishInput, publish};

use crate::cli::{OutputFormat, PublishOpts};
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: PublishOpts,
    _format: OutputFormat,
    dry_run: bool,
) -> Result<CommandExitCode> {
    let started_at = std::time::Instant::now();
    let cargo = cargo_adapter();
    let git = git_adapter(workspace_path)?;
    let registry = registry_adapter();
    let output = publish(
        &cargo,
        &cargo,
        &git,
        &registry,
        PublishInput {
            workspace_path: workspace_path.to_string(),
            skip_checks: opts.skip_checks,
            only: opts.only,
            exclude: opts.exclude,
            delay: opts.delay,
            max_retries: opts.max_retries,
            on_error: opts.on_error,
            dry_run,
            allow_version_drift: opts.allow_version_drift,
            allow_dirty: opts.allow_dirty,
        },
    )
    .await?;
    let workspace = output.workspace.clone();
    let success = output.crates_failed.is_empty();
    print_json(
        "release.publish",
        Some(workspace),
        success,
        output,
        started_at,
        Vec::new(),
    )?;
    Ok(if success {
        CommandExitCode::Success
    } else {
        CommandExitCode::PartialSuccess
    })
}