feat: add rust actions
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:
45
crates/cuddle-please-actions/src/lib.rs
Normal file
45
crates/cuddle-please-actions/src/lib.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
pub(crate) mod actions;
|
||||
mod config;
|
||||
mod rust_action;
|
||||
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use catalog::RustAction;
|
||||
pub use config::ActionConfig;
|
||||
use semver::Version;
|
||||
pub mod catalog {
|
||||
pub use crate::rust_action::*;
|
||||
}
|
||||
|
||||
pub struct Action(Arc<dyn actions::Action>);
|
||||
|
||||
impl Deref for Action {
|
||||
type Target = Arc<dyn actions::Action>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Actions(Vec<Action>);
|
||||
|
||||
impl Actions {
|
||||
pub fn from_cuddle() -> anyhow::Result<Self> {
|
||||
let config = ActionConfig::parse()?;
|
||||
|
||||
Ok(Self(
|
||||
vec![Action(Arc::new(RustAction::new()))]
|
||||
.into_iter()
|
||||
.filter(|a| a.enabled(&config).unwrap_or_default())
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn execute(&self, version: &Version) -> anyhow::Result<()> {
|
||||
for action in &self.0 {
|
||||
action.execute(version)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user