feat: add release action
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 15:58:57 +01:00
parent 2d48b523c3
commit e1a2d03fbe

View File

@ -7,7 +7,7 @@ use futures::{stream, StreamExt};
use crate::{ use crate::{
dagger_middleware::{DaggerMiddleware, DynMiddleware}, dagger_middleware::{DaggerMiddleware, DynMiddleware},
Context, MainAction, PullRequestAction, Context, MainAction, PullRequestAction, ReleaseAction,
}; };
use self::architecture::{Architecture, Os}; use self::architecture::{Architecture, Os};
@ -348,6 +348,32 @@ impl PullRequestAction for RustService {
} }
} }
#[async_trait]
impl ReleaseAction for RustService {
async fn execute_release(&self, ctx: &mut Context) -> eyre::Result<()> {
self.build_test().await?;
let container = self.build_release().await?;
let tag = {
if let Ok(tag) = std::env::var("RELEASE_TAG") {
tag
} else if let Ok(tag) = std::env::var("DRONE_TAG") {
tag
} else {
eyre::bail!("failed to find a valid tag");
}
};
let tag = format!("docker.io/kasperhermansen/{}:{}", self.bin_name, tag);
container.publish(&tag).await?;
ctx.set_image_tag(tag)?;
Ok(())
}
}
const IMAGE_TAG: &str = "RUST_SERVICE_IMAGE_TAG"; const IMAGE_TAG: &str = "RUST_SERVICE_IMAGE_TAG";
pub trait RustServiceContext { pub trait RustServiceContext {
@ -488,8 +514,6 @@ pub mod extensions {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[tokio::test] #[tokio::test]
#[cfg(any(feature = "dagger", feature = "integration"))] #[cfg(any(feature = "dagger", feature = "integration"))]
async fn test_can_build_rust() -> eyre::Result<()> { async fn test_can_build_rust() -> eyre::Result<()> {