mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-10 18:44:19 +00:00
refactor asset path resolution
This commit is contained in:
parent
462a032917
commit
445ef7dd5c
1 changed files with 22 additions and 12 deletions
34
src/main.rs
34
src/main.rs
|
@ -3,7 +3,11 @@ mod github;
|
||||||
use github::{AssetUploader, Release, Releaser};
|
use github::{AssetUploader, Release, Releaser};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{error::Error, fs::File, path::Path};
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
fs::File,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -60,17 +64,23 @@ fn run(
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if let Some(patterns) = conf.input_files {
|
if let Some(patterns) = conf.input_files {
|
||||||
for pattern in patterns {
|
let paths: Result<Vec<PathBuf>, Box<dyn Error>> =
|
||||||
for path in glob::glob(pattern.as_str())? {
|
patterns
|
||||||
let resolved = path?;
|
.into_iter()
|
||||||
uploader.upload(
|
.try_fold(Vec::new(), |mut paths, pattern| {
|
||||||
conf.github_token.as_str(),
|
let matched = glob::glob(pattern.as_str())?.filter_map(Result::ok);
|
||||||
conf.github_repository.as_str(),
|
paths.extend(matched);
|
||||||
release_id,
|
Ok(paths)
|
||||||
mime_or_default(&resolved),
|
});
|
||||||
File::open(resolved)?,
|
for path in paths? {
|
||||||
)?;
|
log::info!("Uploading path {}", path.display());
|
||||||
}
|
uploader.upload(
|
||||||
|
conf.github_token.as_str(),
|
||||||
|
conf.github_repository.as_str(),
|
||||||
|
release_id,
|
||||||
|
mime_or_default(&path),
|
||||||
|
File::open(path)?,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue