From d72313051b9b46a6eeaa909a11850b3d8fc75e81 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 18 Feb 2023 15:57:16 +0100 Subject: [PATCH] fix: with test changes --- ci/src/main.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++++--- src/main.rs | 1 + 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/ci/src/main.rs b/ci/src/main.rs index 36370b8..1363c29 100644 --- a/ci/src/main.rs +++ b/ci/src/main.rs @@ -8,14 +8,17 @@ fn main() -> eyre::Result<()> { let matches = clap::Command::new("ci") .subcommand_required(true) .subcommand(clap::Command::new("pr")) + .subcommand(clap::Command::new("release")) .get_matches(); let client = dagger_sdk::client::connect()?; - let base = select_base_image(client.clone()); - match matches.subcommand() { - Some(("pr", _)) => return validate_pr(client, base), + Some(("pr", _)) => { + let base = select_base_image(client.clone()); + return validate_pr(client, base); + } + Some(("release", subm)) => return release(client, subm), Some(_) => { panic!("invalid subcommand selected!") } @@ -25,6 +28,51 @@ fn main() -> eyre::Result<()> { } } +fn release(client: Arc, subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> { + let src_dir = client.host().directory( + ".".into(), + Some(HostDirectoryOpts { + exclude: Some(vec!["target/".into()]), + include: None, + }), + ); + let base_image = client + .container(None) + .from("rust:latest".into()) + .with_workdir("app".into()) + .with_mounted_directory("/app/".into(), src_dir.id()); + + let container = base_image + .with_exec( + vec![ + "cargo".into(), + "install".into(), + "cargo-smart-release".into(), + ], + None, + ) + .with_exec( + vec![ + "cargo".into(), + "smart-release".into(), + "--execute".into(), + "--allow-fully-generated-changelogs".into(), + "--no-changelog-preview".into(), + "dagger-rs".into(), + "dagger-sdk".into(), + ], + None, + ); + let exit = container.exit_code(); + if exit != 0 { + eyre::bail!("container failed with non-zero exit code"); + } + + println!("released pr succeeded!"); + + Ok(()) +} + fn get_dependencies(client: Arc) -> Container { let cargo_dir = client.host().directory( ".".into(), diff --git a/src/main.rs b/src/main.rs index a9cbd75..026d273 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ pub mod cli; mod cli_generate; fn main() -> eyre::Result<()> { + // test change color_eyre::install().unwrap(); let args = std::env::args();