46 lines
1.8 KiB
JavaScript
46 lines
1.8 KiB
JavaScript
const { withAppBuildGradle } = require('@expo/config-plugins');
|
|
|
|
module.exports = function withAndroidSigning(config) {
|
|
return withAppBuildGradle(config, (config) => {
|
|
if (config.modResults.language === 'groovy') {
|
|
let buildGradle = config.modResults.contents;
|
|
|
|
const signingConfig = `
|
|
release {
|
|
storeFile file("../../schnappix-upload-key.keystore")
|
|
def localProperties = new Properties()
|
|
def localPropertiesFile = rootProject.file("local.properties")
|
|
if (!localPropertiesFile.exists()) {
|
|
localPropertiesFile = rootProject.file("../local.properties")
|
|
}
|
|
if (localPropertiesFile.exists()) {
|
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
|
localProperties.load(reader)
|
|
}
|
|
}
|
|
storePassword localProperties.getProperty("RELEASE_STORE_PASSWORD") ?: System.getenv("RELEASE_STORE_PASSWORD") ?: ""
|
|
keyAlias "schnappix-alias"
|
|
keyPassword localProperties.getProperty("RELEASE_KEY_PASSWORD") ?: System.getenv("RELEASE_KEY_PASSWORD") ?: ""
|
|
}
|
|
`;
|
|
|
|
if (!buildGradle.includes('schnappix-upload-key.keystore')) {
|
|
// Find the closing brace of the debug signing block and insert our release block
|
|
buildGradle = buildGradle.replace(
|
|
/(signingConfigs\s*\{[\s\S]*?debug\s*\{[\s\S]*?\})\s*\}/,
|
|
`$1\n${signingConfig}\n }`
|
|
);
|
|
|
|
// Find the release buildType and update its signingConfig
|
|
buildGradle = buildGradle.replace(
|
|
/(buildTypes\s*\{[\s\S]*?release\s*\{[\s\S]*?)signingConfig signingConfigs\.debug/g,
|
|
`$1signingConfig signingConfigs.release`
|
|
);
|
|
}
|
|
|
|
config.modResults.contents = buildGradle;
|
|
}
|
|
return config;
|
|
});
|
|
};
|