important changes

This commit is contained in:
Christoph J. Scherr 2024-02-19 22:07:51 +01:00
parent acc5381dd1
commit 77f0aabdfc
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
10 changed files with 84 additions and 7 deletions

View File

@ -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<Vec<String>>,
},
@ -60,6 +63,7 @@ pub enum Commands {
#[arg(short, long)]
message: Option<Vec<String>>,
},
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",
}
)
}

View File

@ -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<()> {

3
src/config/packages.rs Normal file
View File

@ -0,0 +1,3 @@
pub enum PackageType {
Cargo
}

View File

@ -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(())
}

View File

@ -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!()
}

27
src/serverapi/forgejo.rs Normal file
View File

@ -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<Self> {
todo!()
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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<Box<dyn ServerApi>>;
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<ApiCollection> {
@ -36,6 +40,9 @@ pub async fn init_servers(cfg: &Config) -> Result<ApiCollection> {
ApiType::Github => {
collection.push(Box::new(Github::build(cfg).await?));
}
ApiType::Forgejo => {
collection.push(Box::new(Forgejo::build(cfg).await?));
}
}
}
Ok(collection)