generated from PlexSheep/rs-base
github should maybe work
cargo devel CI / cargo CI (push) Successful in 3m4s
Details
cargo devel CI / cargo CI (push) Successful in 3m4s
Details
This commit is contained in:
parent
abe2e25071
commit
e66550f2ef
|
@ -13,13 +13,13 @@ uses:
|
|||
- cscherr
|
||||
|
||||
api:
|
||||
# github:
|
||||
# type: github
|
||||
# repository: autocrate
|
||||
# auth:
|
||||
# user: PlexSheep
|
||||
# pass:
|
||||
# !env TOKEN_GH
|
||||
github:
|
||||
type: github
|
||||
repository: autocrate
|
||||
auth:
|
||||
user: PlexSheep
|
||||
pass:
|
||||
!env TOKEN_GH
|
||||
cscherr:
|
||||
type: forgejo
|
||||
endpoint: https://git.cscherr.de
|
||||
|
|
|
@ -19,3 +19,4 @@ Cargo.lock
|
|||
# Added by cargo
|
||||
|
||||
/target
|
||||
.env
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "autocrate"
|
||||
version = "0.1.0-prealpha.4"
|
||||
version = "0.1.0-prealpha.5"
|
||||
edition = "2021"
|
||||
publish = true
|
||||
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
||||
|
@ -29,6 +29,7 @@ forgejo-api = "0.1.0"
|
|||
futures = "0.3.30"
|
||||
git2 = "0.18.1"
|
||||
libpt = { version = "0.4.2", features = ["log"] }
|
||||
octocrab = "0.38.0"
|
||||
reqwest = "0.11.24"
|
||||
serde = { version = "1.0.195", features = ["derive"] }
|
||||
serde_json = "1.0.116"
|
||||
|
|
|
@ -34,6 +34,8 @@ pub enum ServerApiError {
|
|||
ReqwestErr(#[from] reqwest::Error),
|
||||
#[error(transparent)]
|
||||
ForgejoApiError(#[from] forgejo_api::ForgejoError),
|
||||
#[error(transparent)]
|
||||
GithubApiError(#[from] octocrab::Error)
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
|
|
@ -7,7 +7,7 @@ use async_trait::async_trait;
|
|||
use forgejo_api;
|
||||
|
||||
pub struct Forgejo {
|
||||
cfg: Api,
|
||||
api: Api,
|
||||
api_wrapper: forgejo_api::Forgejo,
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ impl Forgejo {
|
|||
)
|
||||
.map_err(ServerApiError::from)?;
|
||||
Ok(Self {
|
||||
cfg: api.clone(),
|
||||
api: api.clone(),
|
||||
api_wrapper,
|
||||
})
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ impl ServerApi for Forgejo {
|
|||
todo!()
|
||||
}
|
||||
fn get_cfg(&self) -> &Api {
|
||||
&self.cfg
|
||||
&self.api
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use async_trait::async_trait;
|
||||
use octocrab;
|
||||
|
||||
use super::{PublishContext, ReleaseContext, ServerApi};
|
||||
use crate::{
|
||||
|
@ -6,16 +7,36 @@ use crate::{
|
|||
error::*,
|
||||
};
|
||||
pub struct Github {
|
||||
cfg: Api,
|
||||
api: Api,
|
||||
}
|
||||
|
||||
impl Github {
|
||||
pub async fn build(api: &Api) -> Result<Self> {
|
||||
Ok(Self {
|
||||
api: api.to_owned(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ServerApi for Github {
|
||||
async fn init(&mut self, _cfg: &Config) -> Result<()> {
|
||||
todo!()
|
||||
Ok(())
|
||||
}
|
||||
async fn push_release(&mut self, _rc: ReleaseContext) -> Result<()> {
|
||||
todo!()
|
||||
async fn push_release(&mut self, rc: ReleaseContext) -> Result<()> {
|
||||
let response = octocrab::instance()
|
||||
.repos(rc.username, rc.repository)
|
||||
.releases()
|
||||
.create(&rc.tag)
|
||||
.target_commitish(&rc.commit_sig)
|
||||
.name(&rc.tag)
|
||||
.body(&rc.text)
|
||||
.draft(rc.draft)
|
||||
.prerelease(rc.prerelease)
|
||||
.send()
|
||||
.await
|
||||
.map_err(ServerApiError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
async fn push_release_artifact(&mut self, _rc: ReleaseContext) -> Result<()> {
|
||||
todo!()
|
||||
|
@ -24,12 +45,6 @@ impl ServerApi for Github {
|
|||
todo!()
|
||||
}
|
||||
fn get_cfg(&self) -> &Api {
|
||||
&self.cfg
|
||||
}
|
||||
}
|
||||
|
||||
impl Github {
|
||||
pub async fn build(api: &Api) -> Result<Self> {
|
||||
Ok(Self { cfg: api.clone() })
|
||||
&self.api
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue