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
|
- cscherr
|
||||||
|
|
||||||
api:
|
api:
|
||||||
# github:
|
github:
|
||||||
# type: github
|
type: github
|
||||||
# repository: autocrate
|
repository: autocrate
|
||||||
# auth:
|
auth:
|
||||||
# user: PlexSheep
|
user: PlexSheep
|
||||||
# pass:
|
pass:
|
||||||
# !env TOKEN_GH
|
!env TOKEN_GH
|
||||||
cscherr:
|
cscherr:
|
||||||
type: forgejo
|
type: forgejo
|
||||||
endpoint: https://git.cscherr.de
|
endpoint: https://git.cscherr.de
|
||||||
|
|
|
@ -19,3 +19,4 @@ Cargo.lock
|
||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
/target
|
/target
|
||||||
|
.env
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "autocrate"
|
name = "autocrate"
|
||||||
version = "0.1.0-prealpha.4"
|
version = "0.1.0-prealpha.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = true
|
publish = true
|
||||||
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
||||||
|
@ -29,6 +29,7 @@ forgejo-api = "0.1.0"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
git2 = "0.18.1"
|
git2 = "0.18.1"
|
||||||
libpt = { version = "0.4.2", features = ["log"] }
|
libpt = { version = "0.4.2", features = ["log"] }
|
||||||
|
octocrab = "0.38.0"
|
||||||
reqwest = "0.11.24"
|
reqwest = "0.11.24"
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
serde_json = "1.0.116"
|
serde_json = "1.0.116"
|
||||||
|
|
|
@ -34,6 +34,8 @@ pub enum ServerApiError {
|
||||||
ReqwestErr(#[from] reqwest::Error),
|
ReqwestErr(#[from] reqwest::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ForgejoApiError(#[from] forgejo_api::ForgejoError),
|
ForgejoApiError(#[from] forgejo_api::ForgejoError),
|
||||||
|
#[error(transparent)]
|
||||||
|
GithubApiError(#[from] octocrab::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|
|
@ -7,7 +7,7 @@ use async_trait::async_trait;
|
||||||
use forgejo_api;
|
use forgejo_api;
|
||||||
|
|
||||||
pub struct Forgejo {
|
pub struct Forgejo {
|
||||||
cfg: Api,
|
api: Api,
|
||||||
api_wrapper: forgejo_api::Forgejo,
|
api_wrapper: forgejo_api::Forgejo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ impl Forgejo {
|
||||||
)
|
)
|
||||||
.map_err(ServerApiError::from)?;
|
.map_err(ServerApiError::from)?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
cfg: api.clone(),
|
api: api.clone(),
|
||||||
api_wrapper,
|
api_wrapper,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,6 @@ impl ServerApi for Forgejo {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn get_cfg(&self) -> &Api {
|
fn get_cfg(&self) -> &Api {
|
||||||
&self.cfg
|
&self.api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use octocrab;
|
||||||
|
|
||||||
use super::{PublishContext, ReleaseContext, ServerApi};
|
use super::{PublishContext, ReleaseContext, ServerApi};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -6,16 +7,36 @@ use crate::{
|
||||||
error::*,
|
error::*,
|
||||||
};
|
};
|
||||||
pub struct Github {
|
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]
|
#[async_trait]
|
||||||
impl ServerApi for Github {
|
impl ServerApi for Github {
|
||||||
async fn init(&mut self, _cfg: &Config) -> Result<()> {
|
async fn init(&mut self, _cfg: &Config) -> Result<()> {
|
||||||
todo!()
|
Ok(())
|
||||||
}
|
}
|
||||||
async fn push_release(&mut self, _rc: ReleaseContext) -> Result<()> {
|
async fn push_release(&mut self, rc: ReleaseContext) -> Result<()> {
|
||||||
todo!()
|
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<()> {
|
async fn push_release_artifact(&mut self, _rc: ReleaseContext) -> Result<()> {
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -24,12 +45,6 @@ impl ServerApi for Github {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn get_cfg(&self) -> &Api {
|
fn get_cfg(&self) -> &Api {
|
||||||
&self.cfg
|
&self.api
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Github {
|
|
||||||
pub async fn build(api: &Api) -> Result<Self> {
|
|
||||||
Ok(Self { cfg: api.clone() })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue