mirror of
https://github.com/CompeyDev/lune-packaging.git
synced 2025-01-09 12:19:09 +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,
|
version,
|
||||||
download,
|
download,
|
||||||
artifact_name,
|
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";
|
const TARGET: &str = "download::download_release";
|
||||||
|
|
||||||
tracing::info!(target: TARGET, "Initializing routine");
|
tracing::info!(target: TARGET, "Initializing routine");
|
||||||
|
|
||||||
let parsed_release_data =
|
let parsed_release_data: LuneReleaseFetched;
|
||||||
parse_release_data(&GitHub::new(("filiptibell", "lune")).fetch_releases()?);
|
|
||||||
|
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);
|
tracing::info!(target: TARGET, "Got lune {}", parsed_release_data.version);
|
||||||
|
|
||||||
let fetcher = Fetcher::new();
|
let fetcher = Fetcher::new();
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
|
use colored::Colorize;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use tracing_core::{Subscriber, Event, Level};
|
use tracing_core::{Event, Level, Subscriber};
|
||||||
use tracing_subscriber::fmt::{
|
use tracing_subscriber::fmt::{
|
||||||
format::{self, FormatEvent, FormatFields},
|
format::{self, FormatEvent, FormatFields},
|
||||||
FmtContext,
|
FmtContext, FormattedFields,
|
||||||
FormattedFields,
|
|
||||||
};
|
};
|
||||||
use tracing_subscriber::registry::LookupSpan;
|
use tracing_subscriber::registry::LookupSpan;
|
||||||
use colored::Colorize;
|
|
||||||
|
|
||||||
pub struct LogFormatter;
|
pub struct LogFormatter;
|
||||||
|
|
||||||
|
@ -21,7 +20,6 @@ where
|
||||||
mut writer: format::Writer<'_>,
|
mut writer: format::Writer<'_>,
|
||||||
event: &Event<'_>,
|
event: &Event<'_>,
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
|
|
||||||
let meta = event.metadata();
|
let meta = event.metadata();
|
||||||
|
|
||||||
let scope = match meta.level() {
|
let scope = match meta.level() {
|
||||||
|
@ -47,10 +45,7 @@ where
|
||||||
for span in scope.from_root() {
|
for span in scope.from_root() {
|
||||||
write!(writer, "{}", span.name())?;
|
write!(writer, "{}", span.name())?;
|
||||||
let ext = span.extensions();
|
let ext = span.extensions();
|
||||||
let fields = &ext
|
let fields = &ext.get::<FormattedFields<N>>().unwrap();
|
||||||
.get::<FormattedFields<N>>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
if !fields.is_empty() {
|
if !fields.is_empty() {
|
||||||
write!(writer, "{{{}}}", fields)?;
|
write!(writer, "{{{}}}", fields)?;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub mod types;
|
|
||||||
pub mod github;
|
|
||||||
pub mod download;
|
pub mod download;
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
|
pub mod github;
|
||||||
|
pub mod types;
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
|
use actions_core as core;
|
||||||
use setup_lune::{
|
use setup_lune::{
|
||||||
download::{download_release, install_lune},
|
download::{download_release, install_lune},
|
||||||
fmt::LogFormatter,
|
fmt::LogFormatter,
|
||||||
};
|
};
|
||||||
use actions_core as core;
|
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_unwrap::ResultExt;
|
use tracing_unwrap::ResultExt;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let version = match core::input("version") {
|
||||||
|
Ok(val) => Some(val),
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
better_panic::install();
|
better_panic::install();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +27,7 @@ fn main() {
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let (zip_path, meta) =
|
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(
|
install_lune(
|
||||||
File::open(&zip_path).expect(
|
File::open(&zip_path).expect(
|
||||||
|
|
|
@ -3,7 +3,7 @@ use serde::Deserialize;
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct LuneReleaseData {
|
pub struct LuneReleaseData {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub assets: Vec<LuneAssetData>
|
pub assets: Vec<LuneAssetData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
@ -17,5 +17,5 @@ pub struct LuneReleaseFetched {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub download: String,
|
pub download: String,
|
||||||
pub artifact_name: String,
|
pub artifact_name: String,
|
||||||
pub raw: LuneReleaseData,
|
pub raw: Option<LuneReleaseData>,
|
||||||
}
|
}
|
Loading…
Reference in a new issue