feat: add optional publish
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-12-27 16:24:03 +01:00
parent 48b9e8ff1f
commit e342b3b04c
3 changed files with 41 additions and 29 deletions

10
Cargo.lock generated
View File

@ -302,7 +302,7 @@ dependencies = [
[[package]] [[package]]
name = "cuddle-ci" name = "cuddle-ci"
version = "0.3.0" version = "0.3.0"
source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#e1a2d03fbe7e158c597623670e5ae8e74b8f19c5" source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#80a34851a60976707170910f0d0908d9d1360dc6"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"chrono", "chrono",
@ -331,17 +331,19 @@ dependencies = [
"dagger-sdk", "dagger-sdk",
"eyre", "eyre",
"tokio", "tokio",
"tracing",
"tracing-subscriber",
] ]
[[package]] [[package]]
name = "dagger-components" name = "dagger-components"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#e1a2d03fbe7e158c597623670e5ae8e74b8f19c5" source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#80a34851a60976707170910f0d0908d9d1360dc6"
[[package]] [[package]]
name = "dagger-cuddle-please" name = "dagger-cuddle-please"
version = "0.3.0" version = "0.3.0"
source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#e1a2d03fbe7e158c597623670e5ae8e74b8f19c5" source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#80a34851a60976707170910f0d0908d9d1360dc6"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"dagger-sdk", "dagger-sdk",
@ -351,7 +353,7 @@ dependencies = [
[[package]] [[package]]
name = "dagger-rust" name = "dagger-rust"
version = "0.3.0" version = "0.3.0"
source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#e1a2d03fbe7e158c597623670e5ae8e74b8f19c5" source = "git+https://git.front.kjuulh.io/kjuulh/dagger-components?branch=main#80a34851a60976707170910f0d0908d9d1360dc6"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"dagger-sdk", "dagger-sdk",

View File

@ -13,3 +13,5 @@ dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-component
dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" } dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" } cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
async-trait = "0.1.80" async-trait = "0.1.80"
tracing.workspace = true
tracing-subscriber.workspace = true

View File

@ -8,6 +8,8 @@ use eyre::Context;
#[tokio::main] #[tokio::main]
async fn main() -> eyre::Result<()> { async fn main() -> eyre::Result<()> {
tracing_subscriber::fmt::init();
dagger_sdk::connect(|client| async move { dagger_sdk::connect(|client| async move {
let cuddle_file = CuddleFile::from_cuddle_file().await?; let cuddle_file = CuddleFile::from_cuddle_file().await?;
@ -60,6 +62,8 @@ impl cuddle_ci::ReleaseAction for RustReleaser {
let crates_token = std::env::var("CRATES_IO_TOKEN") let crates_token = std::env::var("CRATES_IO_TOKEN")
.context("failed to find crates.io token (env: CRATES_IO_TOKEN)")?; .context("failed to find crates.io token (env: CRATES_IO_TOKEN)")?;
if let Some(cuddle_publish) = &cuddle_file.vars.rust {
if cuddle_publish.publish {
let rust_image = self.client.container().from("rustlang/rust:nightly"); let rust_image = self.client.container().from("rustlang/rust:nightly");
let src = self.client.host().directory_opts( let src = self.client.host().directory_opts(
@ -91,6 +95,10 @@ token = "{}"
.with_exec(vec!["cargo", "publish", "-p", service, "--allow-dirty"]) .with_exec(vec!["cargo", "publish", "-p", service, "--allow-dirty"])
.sync() .sync()
.await?; .await?;
} else {
tracing::info!("publish disabled");
}
}
Ok(()) Ok(())
} }