Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should gradle.properties be in gitignore for a react native project to hide release password?

I'm working on a react native app on windows. To be able to generate a signed release apk I've added MYAPP_RELEASE_STORE_PASSWORD=*** and MYAPP_RELEASE_KEY_PASSWORD=*** to my /projectname/android/gradle.properties file (Like it says so here). Now I wonder if I should add the file to gitignore to prevent it from being uploaded to github, or is there a way to store the password in a different file?

like image 339
Niels Avatar asked Feb 08 '17 14:02

Niels


People also ask

Should gradle properties be committed?

properties and SCM. As far as I understood, the best practice for the gradle. properties is to keep it outside of version control, because team members may use it to customize builds, and it is not desirable to have them accidentally commit changes to that file.

Which Gitignore template to choose for react native?

If you are using npm it should be package-lock. json and if you are using yarn it should be yarn.


1 Answers

I found the solution for storing the passwords in a separate file here: Sign APK without putting keystore info in build.gradle

In build.gradle add:

// Load keystore
def keystorePropertiesFile = rootProject.file("keystores/release.keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

And a bit further down:

signingConfigs { 
    release { 
        storeFile file(keystoreProperties['MYAPP_RELEASE_STORE_FILE'])
        storePassword keystoreProperties['MYAPP_RELEASE_STORE_PASSWORD']
        keyAlias keystoreProperties['MYAPP_RELEASE_KEY_ALIAS']
        keyPassword keystoreProperties['MYAPP_RELEASE_KEY_PASSWORD']
    }
}

And then add release.keystore.properties to the .gitignore file defined like so:

MYAPP_RELEASE_STORE_FILE=x
MYAPP_RELEASE_STORE_PASSWORD=y
MYAPP_RELEASE_KEY_ALIAS=z
MYAPP_RELEASE_KEY_PASSWORD=t

(Sorry for answering my own question, I hate doing that..)

like image 82
Niels Avatar answered Oct 02 '22 03:10

Niels