lune-packaging/package/action/src/main.rs

37 lines
918 B
Rust
Raw Normal View History

use std::fs::File;
2023-09-30 10:41:01 +01:00
use actions_core as core;
2023-09-30 10:29:09 +01:00
use setup_lune::{
2023-09-30 10:53:42 +01:00
download::{download_release, install_lune},
fmt::LogFormatter,
};
2023-09-30 08:50:03 +01:00
use tracing::Level;
use tracing_unwrap::ResultExt;
fn main() {
2023-09-30 10:53:42 +01:00
let version = match core::input("version") {
Ok(val) => Some(val),
Err(_) => None,
};
2023-09-30 10:41:01 +01:00
2023-09-30 10:53:42 +01:00
if cfg!(debug_assertions) {
better_panic::install();
}
2023-09-30 10:53:42 +01:00
tracing_subscriber::fmt()
.with_max_level(match core::is_debug() || cfg!(debug_assertions) {
true => Level::DEBUG,
false => Level::INFO,
})
.event_format(LogFormatter)
.init();
2023-09-30 10:53:42 +01:00
let (zip_path, meta) = download_release(version).expect_or_log("failed to download latest lune release");
2023-09-30 10:53:42 +01:00
install_lune(
File::open(&zip_path).unwrap_or_else(|_| panic!("failed to open downloaded lune release zip file @ {}", zip_path.to_string_lossy())),
meta,
)
.expect_or_log("failed to install lune. did we not have perms to write to the required directories?");
}