From 73faf32b293f2d00f49f8644cc408d58b4ef1f20 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Fri, 1 Mar 2024 13:00:31 +0100 Subject: [PATCH] automatically create gitbutler-ui/build --- .github/actions/init-env-rust/action.yaml | 4 ---- gitbutler-app/build.rs | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/actions/init-env-rust/action.yaml b/.github/actions/init-env-rust/action.yaml index 23c45cac3..f0fc5dd78 100644 --- a/.github/actions/init-env-rust/action.yaml +++ b/.github/actions/init-env-rust/action.yaml @@ -10,10 +10,6 @@ runs: prefix-key: gitbutler-client shared-key: rust - - name: Placeholder for ui assets - shell: bash - run: mkdir gitbutler-ui/build - - name: Check versions shell: bash run: | diff --git a/gitbutler-app/build.rs b/gitbutler-app/build.rs index 261851f6b..42a736b04 100644 --- a/gitbutler-app/build.rs +++ b/gitbutler-app/build.rs @@ -1,3 +1,23 @@ fn main() { + // Make the UI build directory if it doesn't already exist. + // We do this here because the tauri context macro expects it to + // exist at build time, and it's otherwise manually required to create + // it before building. + let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); + assert_eq!(manifest_dir.file_name().unwrap(), "gitbutler-app"); + let build_dir = manifest_dir.parent().unwrap().join("gitbutler-ui/build"); + if !build_dir.exists() { + // NOTE(qix-): Do not use `create_dir_all` here - the parent directory + // NOTE(qix-): already exists, and we want to fail if not (for some reason). + #[allow(clippy::expect_fun_call, clippy::create_dir)] + std::fs::create_dir(&build_dir).expect( + format!( + "failed to create gitbutler-ui build directory: {:?}", + build_dir + ) + .as_str(), + ); + } + tauri_build::build(); }