use crate::{gitea::*, *}; use anyhow::{anyhow, Result}; pub(crate) async fn run( common: Common, description: Option, rm: ReleaseMeta, tag: String, ) -> Result<()> { let cli = client(&common)?; let release = get_release_by_tag(&cli, &common.server, &common.owner, &common.repo, &tag).await?; let mut cr = CreateRelease{ body: release.body, draft: release.draft, name: release.name, prerelease: release.prerelease, tag_name: release.tag_name, target_commitish: release.target_commitish, }; if let Some(description) = description { cr.body = description; } if let Some(name) = rm.name { cr.name = name; } cr.draft = rm.draft; cr.prerelease = rm.pre_release; let resp = cli.post(format!("{}/api/v1/repos/{}/{}/releases/{}", common.server, common.owner, common.repo, release.id).as_str()).json(&cr).send().await?; if !resp.status().is_success() { return Err(anyhow!("{:?}", resp.status())); } Ok(()) }