How store signing keystore.

Kiolk - Aug 14 - - Dev Community

Today, I want to share with you how you can store the key for signing your android application. It is clear that we can't store by version control system, we should store it as secret. There is a problem in that in the most of the services for CI you can't store binaries just secrets as plain text. Base algorithm to solve this problem is converting binary to text representation and converting text to binary representation when we need keystore again.

One is the best candidates for this is Base64 format. Both operation, you can simply do by terminal. 

Encoding:

base64 -i key.jks -o key.b64
Enter fullscreen mode Exit fullscreen mode

Decoding:

base64 --decode key.b64 > key.jks
Enter fullscreen mode Exit fullscreen mode

How result, you only need to store text representation of your key in secrets and restore it during execution of pipeline. For instance, how it will be looked if you use GitHub action for this:

- name: Decode and save signing key  
  run: |  
    echo "${{ secrets.SIGNING_KEY_BASE64 }}" | base64 --decode > key.jks
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .