diff --git a/Cargo.lock b/Cargo.lock index acab2ed..319bc1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,6 +183,7 @@ dependencies = [ "async-scoped", "clap", "color-eyre", + "dagger-cuddle-please", "dagger-sdk", "dotenv", "eyre", diff --git a/ci/Cargo.toml b/ci/Cargo.toml index 52e906e..882a8f0 100644 --- a/ci/Cargo.toml +++ b/ci/Cargo.toml @@ -6,6 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +dagger-cuddle-please.workspace = true + dagger-sdk = "*" eyre = "*" color-eyre = "*" diff --git a/ci/src/main.rs b/ci/src/main.rs index d10ef33..d990c4d 100644 --- a/ci/src/main.rs +++ b/ci/src/main.rs @@ -119,67 +119,24 @@ async fn main() -> eyre::Result<()> { mod please_release { use std::sync::Arc; + use dagger_cuddle_please::{models::CuddlePleaseSrcArgs, DaggerCuddlePleaseAction}; + use crate::GlobalArgs; pub async fn run_release_please( client: Arc, args: &GlobalArgs, ) -> eyre::Result<()> { - let build_image = client - .container() - .from("kasperhermansen/cuddle-please:main-1691504183"); - - let src = client - .git_opts( - "https://git.front.kjuulh.io/kjuulh/dagger-components", - dagger_sdk::QueryGitOpts { - experimental_service_host: None, - keep_git_dir: Some(true), + DaggerCuddlePleaseAction::dagger(client) + .execute_src(&CuddlePleaseSrcArgs { + cuddle_image: "kasperhermansen/cuddle-please:main-1691504183".into(), + server: dagger_cuddle_please::models::SrcServer::Gitea { + token: std::env::var("CUDDLE_PLEASE_TOKEN") + .expect("CUDDLE_PLEASE_TOKEN to be present"), }, - ) - .branch("main") - .tree(); - - let res = build_image - .with_secret_variable( - "CUDDLE_PLEASE_TOKEN", - client - .set_secret("CUDDLE_PLEASE_TOKEN", std::env::var("CUDDLE_PLEASE_TOKEN")?) - .id() - .await?, - ) - .with_workdir("/mnt/app") - .with_directory(".", src.id().await?) - .with_exec(vec![ - "git", - "remote", - "set-url", - "origin", - &format!( - "https://git:{}@git.front.kjuulh.io/kjuulh/dagger-components.git", - std::env::var("CUDDLE_PLEASE_TOKEN")? - ), - ]) - .with_exec(vec![ - "cuddle-please", - "release", - "--engine=gitea", - "--owner=kjuulh", - "--repo=dagger-components", - "--branch=main", - "--api-url=https://git.front.kjuulh.io", - "--log-level=debug", - ]); - - let exit_code = res.exit_code().await?; - if exit_code != 0 { - eyre::bail!("failed to run cuddle-please"); - } - - let please_out = res.stdout().await?; - println!("{please_out}"); - let please_out = res.stderr().await?; - println!("{please_out}"); + log_level: Some(dagger_cuddle_please::models::LogLevel::Debug), + }) + .await?; Ok(()) }