feat: add optional publish
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
48b9e8ff1f
commit
e342b3b04c
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -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",
|
||||||
|
@ -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
|
||||||
|
@ -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,37 +62,43 @@ 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)")?;
|
||||||
|
|
||||||
let rust_image = self.client.container().from("rustlang/rust:nightly");
|
if let Some(cuddle_publish) = &cuddle_file.vars.rust {
|
||||||
|
if cuddle_publish.publish {
|
||||||
|
let rust_image = self.client.container().from("rustlang/rust:nightly");
|
||||||
|
|
||||||
let src = self.client.host().directory_opts(
|
let src = self.client.host().directory_opts(
|
||||||
".",
|
".",
|
||||||
HostDirectoryOptsBuilder::default()
|
HostDirectoryOptsBuilder::default()
|
||||||
.exclude([".git/", ".cuddle/", "target/"])
|
.exclude([".git/", ".cuddle/", "target/"])
|
||||||
.build()?,
|
.build()?,
|
||||||
);
|
);
|
||||||
|
|
||||||
let service = &cuddle_file.vars.service;
|
let service = &cuddle_file.vars.service;
|
||||||
|
|
||||||
rust_image
|
rust_image
|
||||||
.with_workdir("/mnt/src")
|
.with_workdir("/mnt/src")
|
||||||
.with_directory("/mnt/src", src)
|
.with_directory("/mnt/src", src)
|
||||||
.with_new_file(
|
.with_new_file(
|
||||||
"/root/.cargo/credentials",
|
"/root/.cargo/credentials",
|
||||||
format!(
|
format!(
|
||||||
r#"
|
r#"
|
||||||
[registry]
|
[registry]
|
||||||
token = "{}"
|
token = "{}"
|
||||||
"#,
|
"#,
|
||||||
crates_token
|
crates_token
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.with_secret_variable(
|
.with_secret_variable(
|
||||||
"CARGO_REGISTRY_TOKEN",
|
"CARGO_REGISTRY_TOKEN",
|
||||||
self.client.set_secret("CARGO_REGISTRY_TOKEN", crates_token),
|
self.client.set_secret("CARGO_REGISTRY_TOKEN", crates_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(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user