@@ -97,6 +97,11 @@ def enableSeparateBuildPerCPUArchitecture = false
9797 */
9898def enableProguardInReleaseBuilds = false
9999
100+ /**
101+ * Fetch the keystore file's path from the environment
102+ */
103+ String keystorePath = System . getenv(" KEYSTORE_FILE" )
104+
100105android {
101106 compileSdkVersion rootProject. ext. compileSdkVersion
102107
@@ -122,8 +127,31 @@ android {
122127 }
123128
124129 signingConfigs {
125- // the signingConfig is configured below
126- release
130+ // originally derived from https://gist.github.com/gabrielemariotti/6856974
131+ if (keystorePath == null ) {
132+ logger. warn " env['KEYSTORE_FILE'] not set"
133+ release
134+ return
135+ } else {
136+ logger. warn " env['KEYSTORE_FILE'] = ${ keystorePath} "
137+ }
138+
139+ def propFile = new File (keystorePath)
140+ if (! propFile. canRead()) {
141+ logger. warn " ${ keystorePath} is not readable"
142+ release
143+ return
144+ }
145+
146+ def props = new Properties ()
147+ props. load(new FileInputStream (propFile))
148+
149+ release {
150+ storeFile file(props[' STORE_FILE' ])
151+ storePassword props[' STORE_PASSWORD' ]
152+ keyAlias props[' KEY_ALIAS' ]
153+ keyPassword props[' KEY_PASSWORD' ]
154+ }
127155 }
128156
129157 splits {
@@ -145,7 +173,9 @@ android {
145173
146174 minifyEnabled enableProguardInReleaseBuilds
147175 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
148- signingConfig signingConfigs. release
176+ if (keystorePath != null ) {
177+ signingConfig signingConfigs. release
178+ }
149179 }
150180 }
151181
@@ -186,41 +216,6 @@ android {
186216 }
187217}
188218
189- // borrowed from https://gist.github.com/gabrielemariotti/6856974
190- def propFile = new File (' android/app/signing.properties' )
191- if (propFile. canRead()) {
192- Properties props = new Properties ()
193- props. load(new FileInputStream (propFile))
194-
195- bool hasFile = props != null && props. containsKey(' STORE_FILE' );
196- bool hasPassword = props != null && props. containsKey(' STORE_PASSWORD' );
197- bool hasAlias = props != null && props. containsKey(' KEY_ALIAS' );
198- bool hasKeyPass = props != null && props. containsKey(' KEY_PASSWORD' );
199-
200- if (hasFile && hasPassword && hasAlias && hasKeyPass) {
201- logger. info ' android/app/signing.properties is fully functional.'
202- android. signingConfigs. release. storeFile = file(props[' STORE_FILE' ])
203- android. signingConfigs. release. storePassword = props[' STORE_PASSWORD' ]
204- android. signingConfigs. release. keyAlias = props[' KEY_ALIAS' ]
205- android. signingConfigs. release. keyPassword = props[' KEY_PASSWORD' ]
206- } else {
207- println ' android/app/signing.properties found, but some entries are missing.'
208- if (props == null ) {
209- logger. warn ' `props` was null'
210- } else {
211- logger. warn " has STORE_FILE [y/n]: ${ props.containsKey('STORE_FILE')} "
212- logger. warn " has STORE_PASSWORD [y/n]: ${ props.containsKey('STORE_PASSWORD')} "
213- logger. warn " has KEY_ALIAS [y/n]: ${ props.containsKey('KEY_ALIAS')} "
214- logger. warn " has KEY_PASSWORD [y/n]: ${ props.containsKey('KEY_PASSWORD')} "
215- }
216- android. buildTypes. release. signingConfig = null
217- }
218- } else {
219- logger. warn ' android/app/signing.properties not found.'
220- logger. warn " cwd: ${ new File(".").absolutePath} "
221- android. buildTypes. release. signingConfig = null
222- }
223-
224219dependencies {
225220 // please keep this list sorted
226221 implementation project(' :bugsnag-react-native' )
0 commit comments