From 05b78215c064c77e4e5f584b279ae357a060c457 Mon Sep 17 00:00:00 2001 From: Joseph Werle Date: Tue, 12 Nov 2024 14:44:26 -0500 Subject: [PATCH] refactor(cli): handle android keystore signing configs --- src/cli/cli.cc | 21 +++++++++++++++++++++ src/cli/templates.hh | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/src/cli/cli.cc b/src/cli/cli.cc index 4c203bd65b..6f84f8b0e6 100644 --- a/src/cli/cli.cc +++ b/src/cli/cli.cc @@ -3492,6 +3492,23 @@ int main (int argc, char* argv[]) { trim(tmpl(tmpl(gAndroidManifest, settings), manifestContext)) ); + settings["android_signingconfig_release"] = ""; + settings["android_buildtypes_release_config"] = ""; + + if ( + settings["android_codesign_keystore_file"].size() > 0 && + settings["android_codesign_keystore_password"].size() > 0 && + settings["android_codesign_key_alias"].size() > 0 && + settings["android_codesign_key_password"].size() + ) { + settings["android_signingconfig_release"] += " storeFile file('{{android_codesign_keystore_file}}')\n"; + settings["android_signingconfig_release"] += " storePassword '{{android_codesign_keystore_password}}'\n"; + settings["android_signingconfig_release"] += " keyAlias '{{android_codesign_key_alias}}'\n"; + settings["android_signingconfig_release"] += " keyPassword '{{android_codesign_key_password}}'\n"; + settings["android_buildtypes_release_config"] += " signingConfig signingConfigs.release\n"; + } + + writeFile(app / "proguard-rules.pro", trim(tmpl(gProGuardRules, settings))); writeFile(app / "build.gradle", trim(tmpl(gGradleBuildForSource, settings))); @@ -4077,6 +4094,10 @@ int main (int argc, char* argv[]) { "security cms -D -i " + pathToProfile.string() ); + if (Env::has("APPLE_KEYCHAIN")) { + command += " -k" + Env::get("APPLE_KEYCHAIN"); + } + auto r = exec(command); std::regex reUuid(R"(UUID<\/key>\n\s*(.*)<\/string>)"); std::smatch matchUuid; diff --git a/src/cli/templates.hh b/src/cli/templates.hh index a73e160a98..8268d97670 100644 --- a/src/cli/templates.hh +++ b/src/cli/templates.hh @@ -1399,6 +1399,14 @@ android { {{android_default_config_external_native_build}} } + signingConfigs { + release { +{{android_signingconfig_release}} + v1SigningEnabled = true + v2SigningEnabled = true + } + } + aaptOptions { {{android_aapt}} noCompress {{android_aapt_no_compress}} @@ -1422,6 +1430,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //productFlavors.dev productFlavors.live + {{android_buildtypes_release_config}} } debug {