From 1bd35fcf6f211b8496d8bf374c2cb5d55fa2d781 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:58:19 -0600 Subject: [PATCH] cross-platform github action --- src/template.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/template.rs b/src/template.rs index 6467f52..00e94f6 100644 --- a/src/template.rs +++ b/src/template.rs @@ -20,6 +20,7 @@ fn create_template( description: String, gd: String, strip: bool, + action: bool ) { if project_location.exists() { warn!("The provided location already exists."); @@ -73,6 +74,15 @@ fn create_template( .nice_unwrap("Unable to access template file main.cpp"); } + // Add cross-platform action + // Download the action from https://raw.githubusercontent.com/geode-sdk/build-geode-mod/main/examples/multi-platform.yml + if action { + let action_path = project_location.join(".github/workflows/multi-platform.yml"); + fs::create_dir_all(action_path.parent().unwrap()).nice_unwrap("Unable to create .github/workflows directory"); + let action = reqwest::blocking::get("https://raw.githubusercontent.com/geode-sdk/build-geode-mod/main/examples/multi-platform.yml").nice_unwrap("Unable to download action"); + fs::write(action_path, action.text().nice_unwrap("Unable to write action")).nice_unwrap("Unable to write action"); + } + // Default mod.json let mod_json = json!({ "geode": get_version().to_string(), @@ -162,6 +172,11 @@ pub fn build_template(config: &mut Config, location: Option) { final_name.to_lowercase().replace(' ', "_") ); + let action = ask_confirm( + "Do you want to add the cross-platform Github action?", + true, + ); + let strip = ask_confirm( "Do you want to remove comments from the default template?", false, @@ -178,5 +193,6 @@ pub fn build_template(config: &mut Config, location: Option) { final_description, gd, strip, + action ); }