Skip to content

Commit

Permalink
refactor(cli): handle android keystore signing configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Nov 12, 2024
1 parent a78c8f5 commit 05b7821
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down Expand Up @@ -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"(<key>UUID<\/key>\n\s*<string>(.*)<\/string>)");
std::smatch matchUuid;
Expand Down
9 changes: 9 additions & 0 deletions src/cli/templates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -1422,6 +1430,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//productFlavors.dev
productFlavors.live
{{android_buildtypes_release_config}}
}
debug {
Expand Down

0 comments on commit 05b7821

Please sign in to comment.