feat: with create pull request and release
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
0e876a25a6
commit
86eabad6fe
@ -371,6 +371,70 @@ impl GiteaClient {
|
||||
|
||||
Ok(commits.number)
|
||||
}
|
||||
|
||||
pub fn create_release(
|
||||
&self,
|
||||
owner: impl Into<String>,
|
||||
repo: impl Into<String>,
|
||||
version: impl Into<String>,
|
||||
body: impl Into<String>,
|
||||
prerelease: bool,
|
||||
) -> anyhow::Result<Release> {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct CreateReleaseOption {
|
||||
body: String,
|
||||
draft: bool,
|
||||
name: String,
|
||||
prerelease: bool,
|
||||
#[serde(alias = "tag_name")]
|
||||
tag_name: String,
|
||||
}
|
||||
|
||||
let client = self.create_client()?;
|
||||
|
||||
let owner = owner.into();
|
||||
let repo = repo.into();
|
||||
let version = version.into();
|
||||
let body = body.into();
|
||||
|
||||
let request = CreateReleaseOption {
|
||||
body,
|
||||
draft: false,
|
||||
name: version.clone(),
|
||||
prerelease,
|
||||
tag_name: version.clone(),
|
||||
};
|
||||
|
||||
tracing::trace!(
|
||||
owner = owner,
|
||||
repo = repo,
|
||||
version = version,
|
||||
"create release"
|
||||
);
|
||||
let request = client
|
||||
.post(format!(
|
||||
"{}/api/v1/repos/{}/{}/releases",
|
||||
&self.url.trim_end_matches("/"),
|
||||
owner,
|
||||
repo,
|
||||
))
|
||||
.json(&request)
|
||||
.build()?;
|
||||
let resp = client.execute(request)?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(anyhow::anyhow!(resp.error_for_status().unwrap_err()));
|
||||
}
|
||||
let release: Release = resp.json()?;
|
||||
|
||||
Ok(release)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct Release {
|
||||
id: usize,
|
||||
url: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
|
Loading…
Reference in New Issue
Block a user