mirror of
https://github.com/CompeyDev/lune-packaging.git
synced 2025-01-08 11:49:10 +00:00
feat: make use of actions inputs
This commit is contained in:
parent
aa688e693b
commit
1438be4231
5 changed files with 39 additions and 23 deletions
|
@ -68,19 +68,35 @@ fn parse_release_data(data: &LuneReleaseData) -> LuneReleaseFetched {
|
|||
version,
|
||||
download,
|
||||
artifact_name,
|
||||
raw: data.clone(),
|
||||
raw: Some(data.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn download_release() -> Result<(PathBuf, LuneReleaseFetched)> {
|
||||
pub fn download_release(version: Option<String>) -> Result<(PathBuf, LuneReleaseFetched)> {
|
||||
const TARGET: &str = "download::download_release";
|
||||
|
||||
tracing::info!(target: TARGET, "Initializing routine");
|
||||
|
||||
let parsed_release_data =
|
||||
parse_release_data(&GitHub::new(("filiptibell", "lune")).fetch_releases()?);
|
||||
let parsed_release_data: LuneReleaseFetched;
|
||||
|
||||
if let Some(ver) = version {
|
||||
let artifact_name = format!("lune-{ver}-{}-{}.zip", env::consts::OS, env::consts::ARCH);
|
||||
|
||||
parsed_release_data = LuneReleaseFetched {
|
||||
version: ver.to_string(),
|
||||
download: format!(
|
||||
"https://github.com/filiptibell/lune/releases/download/v{ver}/{artifact_name}"
|
||||
),
|
||||
artifact_name,
|
||||
raw: None,
|
||||
}
|
||||
} else {
|
||||
parsed_release_data =
|
||||
parse_release_data(&GitHub::new(("filiptibell", "lune")).fetch_releases()?);
|
||||
|
||||
tracing::info!(target: TARGET, "Received API resp and parsed release data");
|
||||
}
|
||||
|
||||
tracing::info!(target: TARGET, "Received API resp and parsed release data");
|
||||
tracing::info!(target: TARGET, "Got lune {}", parsed_release_data.version);
|
||||
|
||||
let fetcher = Fetcher::new();
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use colored::Colorize;
|
||||
use std::fmt;
|
||||
use tracing_core::{Subscriber, Event, Level};
|
||||
use tracing_core::{Event, Level, Subscriber};
|
||||
use tracing_subscriber::fmt::{
|
||||
format::{self, FormatEvent, FormatFields},
|
||||
FmtContext,
|
||||
FormattedFields,
|
||||
FmtContext, FormattedFields,
|
||||
};
|
||||
use tracing_subscriber::registry::LookupSpan;
|
||||
use colored::Colorize;
|
||||
|
||||
pub struct LogFormatter;
|
||||
|
||||
|
@ -21,7 +20,6 @@ where
|
|||
mut writer: format::Writer<'_>,
|
||||
event: &Event<'_>,
|
||||
) -> fmt::Result {
|
||||
|
||||
let meta = event.metadata();
|
||||
|
||||
let scope = match meta.level() {
|
||||
|
@ -47,10 +45,7 @@ where
|
|||
for span in scope.from_root() {
|
||||
write!(writer, "{}", span.name())?;
|
||||
let ext = span.extensions();
|
||||
let fields = &ext
|
||||
.get::<FormattedFields<N>>()
|
||||
.unwrap();
|
||||
|
||||
let fields = &ext.get::<FormattedFields<N>>().unwrap();
|
||||
|
||||
if !fields.is_empty() {
|
||||
write!(writer, "{{{}}}", fields)?;
|
||||
|
@ -63,4 +58,4 @@ where
|
|||
|
||||
writeln!(writer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod types;
|
||||
pub mod github;
|
||||
pub mod download;
|
||||
pub mod fmt;
|
||||
pub mod fmt;
|
||||
pub mod github;
|
||||
pub mod types;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
use std::fs::File;
|
||||
|
||||
use actions_core as core;
|
||||
use setup_lune::{
|
||||
download::{download_release, install_lune},
|
||||
fmt::LogFormatter,
|
||||
};
|
||||
use actions_core as core;
|
||||
use tracing::Level;
|
||||
use tracing_unwrap::ResultExt;
|
||||
|
||||
fn main() {
|
||||
let version = match core::input("version") {
|
||||
Ok(val) => Some(val),
|
||||
Err(_) => None,
|
||||
};
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
better_panic::install();
|
||||
}
|
||||
|
@ -22,7 +27,7 @@ fn main() {
|
|||
.init();
|
||||
|
||||
let (zip_path, meta) =
|
||||
download_release().expect_or_log("failed to download latest lune release");
|
||||
download_release(version).expect_or_log("failed to download latest lune release");
|
||||
|
||||
install_lune(
|
||||
File::open(&zip_path).expect(
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::Deserialize;
|
|||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct LuneReleaseData {
|
||||
pub name: String,
|
||||
pub assets: Vec<LuneAssetData>
|
||||
pub assets: Vec<LuneAssetData>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
|
@ -17,5 +17,5 @@ pub struct LuneReleaseFetched {
|
|||
pub version: String,
|
||||
pub download: String,
|
||||
pub artifact_name: String,
|
||||
pub raw: LuneReleaseData,
|
||||
}
|
||||
pub raw: Option<LuneReleaseData>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue