diff --git a/src/config/cli.rs b/src/config/cli.rs index 8a81077..554b911 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -52,6 +52,9 @@ pub enum Commands { // // TODO: // find a way to make this a global option but only usable with specific subcommands + // + // TODO: + // integrate a CHANGELOG.md file #[arg(short, long)] message: Option>, }, @@ -60,6 +63,7 @@ pub enum Commands { #[arg(short, long)] message: Option>, }, + Version {}, } impl Display for Commands { @@ -71,6 +75,7 @@ impl Display for Commands { Self::Changelog { .. } => "Changelog", Self::Release { .. } => "Release", Self::Publish { .. } => "Publish", + Self::Version { .. } => "Version", } ) } diff --git a/src/config/mod.rs b/src/config/mod.rs index d2e5d09..6f8bb45 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -8,6 +8,8 @@ use url::Url; use crate::error::*; pub mod cli; +pub mod packages; +use packages::*; use cli::Cli; pub trait YamlConfigSection: Debug + Clone + for<'a> Deserialize<'a> { @@ -101,6 +103,8 @@ pub enum ApiType { Gitlab, #[serde(alias = "github", alias = "GitHub")] Github, + #[serde(alias = "forgejo")] + Forgejo, } impl YamlConfigSection for ApiType { fn check(&self) -> Result<()> { diff --git a/src/config/packages.rs b/src/config/packages.rs new file mode 100644 index 0000000..bcbf9b6 --- /dev/null +++ b/src/config/packages.rs @@ -0,0 +1,3 @@ +pub enum PackageType { + Cargo +} diff --git a/src/main.rs b/src/main.rs index 014f3d9..98641ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,12 @@ async fn main() -> Result<()> { Commands::Publish { .. } => { publish(&cfg).await?; } + Commands::Version {} => { + // TODO: version bump + // TODO: version select interactive + // TODO: version select automated + todo!() + } }; Ok(()) } diff --git a/src/release/mod.rs b/src/release/mod.rs index 758e89e..9c8eee9 100644 --- a/src/release/mod.rs +++ b/src/release/mod.rs @@ -2,10 +2,26 @@ use crate::{config::Config, error::*, serverapi::ApiCollection}; pub async fn release(cfg: &Config, apis: &mut ApiCollection) -> Result<()> { // TODO: git tag - // TODO: version bump - // TODO: version select interactive - // TODO: version select automated // TODO: push to each server + // TODO: release to each server + tag(cfg).await?; + for api in apis.iter_mut() { + api.push_release().await?; + } + + for api in apis.iter_mut() { + api.push_release().await?; + } + + // TODO: check that the release is made + // TODO: generate artifacts + // TODO: upload artifacts + // TODO: upload artifact signatures + + Ok(()) +} + +async fn tag(cfg: &Config) -> Result<()> { todo!() } diff --git a/src/serverapi/forgejo.rs b/src/serverapi/forgejo.rs new file mode 100644 index 0000000..e854a04 --- /dev/null +++ b/src/serverapi/forgejo.rs @@ -0,0 +1,27 @@ +use async_trait::async_trait; + +use super::ServerApi; +use crate::{ + config::{packages::PackageType, ApiType, Config}, + error::*, +}; +pub struct Forgejo; + +#[async_trait] +impl ServerApi for Forgejo { + async fn init(&mut self, cfg: &Config) -> Result<()> { + todo!() + } + async fn push_release(&mut self) -> Result<()> { + todo!() + } + async fn push_pkg(&mut self, pkg_type: PackageType) -> Result<()> { + todo!() + } +} + +impl Forgejo { + pub async fn build(cfg: &Config) -> Result { + todo!() + } +} diff --git a/src/serverapi/gitea.rs b/src/serverapi/gitea.rs index f831ba5..7c74584 100644 --- a/src/serverapi/gitea.rs +++ b/src/serverapi/gitea.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use super::ServerApi; use crate::{ - config::{ApiType, Config}, + config::{packages::PackageType, ApiType, Config}, error::*, }; pub struct Gitea; @@ -15,6 +15,9 @@ impl ServerApi for Gitea { async fn push_release(&mut self) -> Result<()> { todo!() } + async fn push_pkg(&mut self, pkg_type: PackageType) -> Result<()> { + todo!() + } } impl Gitea { diff --git a/src/serverapi/github.rs b/src/serverapi/github.rs index 6475e08..a7be38a 100644 --- a/src/serverapi/github.rs +++ b/src/serverapi/github.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use super::ServerApi; use crate::{ - config::{ApiType, Config}, + config::{packages::PackageType, ApiType, Config}, error::*, }; pub struct Github; @@ -15,6 +15,9 @@ impl ServerApi for Github { async fn push_release(&mut self) -> Result<()> { todo!() } + async fn push_pkg(&mut self, pkg_type: PackageType) -> Result<()> { + todo!() + } } impl Github { diff --git a/src/serverapi/gitlab.rs b/src/serverapi/gitlab.rs index c0d8bfc..2d47f34 100644 --- a/src/serverapi/gitlab.rs +++ b/src/serverapi/gitlab.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use super::ServerApi; use crate::{ - config::{ApiType, Config}, + config::{packages::PackageType, ApiType, Config}, error::*, }; pub struct Gitlab; @@ -15,6 +15,9 @@ impl ServerApi for Gitlab { async fn push_release(&mut self) -> Result<()> { todo!() } + async fn push_pkg(&mut self, pkg_type: PackageType) -> Result<()> { + todo!() + } } impl Gitlab { diff --git a/src/serverapi/mod.rs b/src/serverapi/mod.rs index c4c7d4c..3fb5bb0 100644 --- a/src/serverapi/mod.rs +++ b/src/serverapi/mod.rs @@ -1,13 +1,15 @@ use async_trait::async_trait; use crate::{ - config::{ApiType, Config}, + config::{packages::PackageType, ApiType, Config}, error::*, }; +pub mod forgejo; pub mod gitea; pub mod github; pub mod gitlab; +use forgejo::*; use gitea::*; use github::*; use gitlab::*; @@ -21,6 +23,8 @@ pub type ApiCollection = Vec>; pub trait ServerApi { async fn init(&mut self, cfg: &Config) -> Result<()>; async fn push_release(&mut self) -> Result<()>; + async fn push_release_artifact(&mut self) -> Result<()>; + async fn push_pkg(&mut self, pkg_type: PackageType) -> Result<()>; } pub async fn init_servers(cfg: &Config) -> Result { @@ -36,6 +40,9 @@ pub async fn init_servers(cfg: &Config) -> Result { ApiType::Github => { collection.push(Box::new(Github::build(cfg).await?)); } + ApiType::Forgejo => { + collection.push(Box::new(Forgejo::build(cfg).await?)); + } } } Ok(collection)