Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/commands/connect/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,41 @@ impl ConnectClient {
Ok(resp.data)
}

/// Publish a draft runtime (draft → published).
pub async fn publish_runtime(
&self,
org: &str,
project_id: &str,
runtime_id: &str,
) -> Result<RuntimeSummary> {
let url = format!(
"{}/api/orgs/{}/projects/{}/runtimes/{}",
self.api_url, org, project_id, runtime_id
);

let body = serde_json::json!({
"runtime": { "status": "published" }
});

let res = self
.http
.put(&url)
.header("authorization", format!("Bearer {}", self.token))
.json(&body)
.send()
.await
.context("Failed to publish runtime")?;

let status = res.status();
if !status.is_success() {
let body = res.text().await.unwrap_or_default();
anyhow::bail!("Failed to publish runtime (HTTP {status}): {body}");
}

let resp: CompleteRuntimeResponse = res.json().await?;
Ok(resp.data)
}

/// Re-fetch presigned URLs for an artifact (crash recovery).
#[allow(dead_code)]
pub async fn get_upload_urls(
Expand Down
32 changes: 31 additions & 1 deletion src/commands/connect/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct ConnectUploadCommand {
pub target: Option<String>,
pub file: Option<String>,
pub profile: Option<String>,
pub publish: bool,
pub deploy_cohort: Option<String>,
pub deploy_name: Option<String>,
pub deploy_tags: Vec<String>,
Expand Down Expand Up @@ -164,6 +165,20 @@ impl ConnectUploadCommand {
OutputLevel::Normal,
);

if self.publish {
print_info("Publishing runtime...", OutputLevel::Normal);
let published = connect
.publish_runtime(&self.org, &self.project, &runtime.id)
.await?;
print_success(
&format!(
"Runtime {} published (status: {})",
published.version, published.status
),
OutputLevel::Normal,
);
}

if let Some(ref cohort_id) = self.deploy_cohort {
super::deploy::deploy_after_upload(&super::deploy::DeployAfterUploadParams {
client: &connect,
Expand Down Expand Up @@ -210,7 +225,22 @@ impl ConnectUploadCommand {
OutputLevel::Normal,
);

// 10. Deploy after upload if --deploy-cohort was specified
// 10. Publish if --publish was specified
if self.publish {
print_info("Publishing runtime...", OutputLevel::Normal);
let published = connect
.publish_runtime(&self.org, &self.project, &runtime.id)
.await?;
print_success(
&format!(
"Runtime {} published (status: {})",
published.version, published.status
),
OutputLevel::Normal,
);
}

// 11. Deploy after upload if --deploy-cohort was specified
if let Some(ref cohort_id) = self.deploy_cohort {
super::deploy::deploy_after_upload(&super::deploy::DeployAfterUploadParams {
client: &connect,
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ enum ConnectCommands {
/// Profile name (defaults to the active default profile)
#[arg(long)]
profile: Option<String>,
/// Publish the runtime immediately after upload (draft → published)
#[arg(long)]
publish: bool,
/// Deploy after upload: cohort ID to target
#[arg(long)]
deploy_cohort: Option<String>,
Expand Down Expand Up @@ -2865,6 +2868,7 @@ async fn main() -> Result<()> {
target,
file,
profile,
publish,
deploy_cohort,
deploy_name,
deploy_tag,
Expand All @@ -2886,6 +2890,7 @@ async fn main() -> Result<()> {
target: target.or(cli.target),
file,
profile: profile.clone(),
publish,
deploy_cohort,
deploy_name,
deploy_tags: deploy_tag,
Expand Down
Loading