print status of uploads
This commit is contained in:
parent
452a2ee738
commit
9003b6a3e7
@ -37,7 +37,7 @@ pub trait AssetUploader<A: Into<Body> = File> {
|
|||||||
release_id: usize,
|
release_id: usize,
|
||||||
mime: Mime,
|
mime: Mime,
|
||||||
asset: A,
|
asset: A,
|
||||||
) -> Result<(), Box<dyn Error>>;
|
) -> Result<StatusCode, Box<dyn Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Releaser for Client {
|
impl Releaser for Client {
|
||||||
@ -87,16 +87,17 @@ impl<A: Into<Body>> AssetUploader<A> for Client {
|
|||||||
release_id: usize,
|
release_id: usize,
|
||||||
mime: mime::Mime,
|
mime: mime::Mime,
|
||||||
asset: A,
|
asset: A,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<StatusCode, Box<dyn Error>> {
|
||||||
self.post(&format!(
|
Ok(self
|
||||||
"http://uploads.github.com/repos/{}/releases/{}",
|
.post(&format!(
|
||||||
github_repo, release_id
|
"http://uploads.github.com/repos/{}/releases/{}",
|
||||||
))
|
github_repo, release_id
|
||||||
.header("Authorization", format!("bearer {}", github_token))
|
))
|
||||||
.header("Content-Type", mime.to_string())
|
.header("Authorization", format!("bearer {}", github_token))
|
||||||
.body(asset)
|
.header("Content-Type", mime.to_string())
|
||||||
.send()?;
|
.body(asset)
|
||||||
Ok(())
|
.send()?
|
||||||
|
.status())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -87,24 +87,23 @@ fn run(
|
|||||||
conf.github_repository.as_str(),
|
conf.github_repository.as_str(),
|
||||||
release(&conf),
|
release(&conf),
|
||||||
)?;
|
)?;
|
||||||
println!("name {:#?}", conf.input_name);
|
|
||||||
println!("files {:#?}", conf.input_files);
|
|
||||||
|
|
||||||
if let Some(patterns) = conf.input_files {
|
if let Some(patterns) = conf.input_files {
|
||||||
for path in paths(patterns)? {
|
for path in paths(patterns)? {
|
||||||
println!("⬆️ Uploading asset {}", path.display());
|
println!("⬆️ Uploading asset {}", path.display());
|
||||||
uploader.upload(
|
let status = uploader.upload(
|
||||||
conf.github_token.as_str(),
|
conf.github_token.as_str(),
|
||||||
conf.github_repository.as_str(),
|
conf.github_repository.as_str(),
|
||||||
id,
|
id,
|
||||||
mime_or_default(&path),
|
mime_or_default(&path),
|
||||||
File::open(path)?,
|
File::open(path)?,
|
||||||
)?;
|
)?;
|
||||||
|
println!("uploaded with status {}", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("🎉 Release ready at {}", html_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("🎉 Release ready at {}", html_url);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +186,7 @@ mod tests {
|
|||||||
github_repository: "foo/bar".into(),
|
github_repository: "foo/bar".into(),
|
||||||
input_name: Some("test release".into()),
|
input_name: Some("test release".into()),
|
||||||
input_body: Some(":)".into()),
|
input_body: Some(":)".into()),
|
||||||
input_files: Some(vec!["*.md".into()])
|
input_files: Some(vec!["*.md".into()]),
|
||||||
},
|
},
|
||||||
)] {
|
)] {
|
||||||
assert_eq!(expect, envy::from_iter::<_, Config>(env)?)
|
assert_eq!(expect, envy::from_iter::<_, Config>(env)?)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user