DEV Community

Cover image for Build and Sign Android Apps using GitHub Actions
Sumanth Perambuduri
Sumanth Perambuduri

Posted on • Updated on

Build and Sign Android Apps using GitHub Actions

GitHub actions is really amazing because you can literally build your apps with just a push of your code to GitHub. I’ve been playing with GitHub actions lately and I really really love it. I’ve used GitHub actions before to build Python packages and Electron apps and I thought that why not for Android as well.

Before getting started, complete the following steps:

  • Encode your KeyStore file (.jks) to base64.

openssl base64 -A -in keystore.jks -out base64.txt

  • Copy the content of base64.txt and store it as SIGNINGKEYBASE64 in GitHub secrets.
  • Store your alias as ALIAS in GitHub secrets.
  • Store your keystore password as KEYSTOREPASSWORD and key password as KEYPASSWORD in GitHub secrets.

Now in your project create a folder “.github” and inside this folder create a folder “workflows”. Inside workflows folder create a file “build.yml” and add the below content in build.yml.

You are now good to go. So anytime you create a tag and push the tag to GitHub, the actions is going to build apk and aab files, sign them, make artifacts, create a release with the tag, upload the files in the release as assets.

Here’s an example project of the above usage:
GitamTransit

Want to use GitHub secrets in your Android Apps? Check out this post.

Top comments (4)

Collapse
 
vitalykarasik profile image
Vitaly Karasik

Hi, many thanks!
Regarding 'signingKeyBase64' - is the key and keystore the same thing (format)?
I already have my android keystore into Github secrets and it works nice for signing 3D Unity apps, but when I tried to use it in r0adkll/sign-android-release@v1, I received "Failed to load signer "signer #1"
java.io.EOFException" exception.

Collapse
 
supersuman profile image
Sumanth Perambuduri

Hey @vitalykarasik , I've found out the solution in issues.
Check out this link for the solution.

Collapse
 
alinavaie profile image
Ali Navaie

Hi
I did exactly same but I got this error:

Execution failed for task ':app:validateSigningRelease'.

Keystore file '/home/runner/work/SampleApp/SampleApp/android/app/my-upload-key.keystore' not found for signing config 'release'

I know 'my-upload-key.keystore' is not uploaded to my repository, but the questions is why it needs this file while I've already import the key base64 content in the action secret?

Collapse
 
alinavaie profile image
Ali Navaie