Skip to content

Commit

Permalink
cross-platform github action
Browse files Browse the repository at this point in the history
  • Loading branch information
camila314 committed Feb 11, 2024
1 parent 594a995 commit 1bd35fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -162,6 +172,11 @@ pub fn build_template(config: &mut Config, location: Option<PathBuf>) {
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,
Expand All @@ -178,5 +193,6 @@ pub fn build_template(config: &mut Config, location: Option<PathBuf>) {
final_description,
gd,
strip,
action
);
}

0 comments on commit 1bd35fc

Please sign in to comment.