How To Build, Sign And Publish Android Application Using Github Actions

<p>The main goal of this article is to provide a complete implementation of a&nbsp;<strong>Github Workflow</strong>&nbsp;capable of securely building, signing, and publishing Android apps.</p> <p>Follow these steps to create the&nbsp;<strong>Github Workflow</strong>:</p> <p>1. Generate a&nbsp;<strong>new signing keystore</strong></p> <p>2. Add the following secrets to your Github repository (you&rsquo;ll need to convert&nbsp;<strong>keystore.jks</strong>&nbsp;to&nbsp;<strong>base64</strong>&nbsp;string)</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:770/1*SGD7WaFT-VH9cZVUi9OYOw.png" style="height:298px; width:700px" /></p> <p>In Repository Settings Add The Following Secrets To&nbsp;<strong>Security -&gt; Secrets and variables -&gt; Actions -&gt; Repository secrets</strong></p> <p>3. Add a new signing configuration to your app&rsquo;s&nbsp;<strong>build.gradle</strong>&nbsp;file. Note that&nbsp;<strong>rootProject.name</strong>&nbsp;is defined in the&nbsp;<strong>settings.gradle&nbsp;</strong>file.</p> <pre> android { // ... defaultConfig { // ... versionName &quot;1.1&quot; // ... } signingConfigs { release { storeFile = file(&quot;keystore/android_keystore.jks&quot;) storePassword System.getenv(&quot;SIGNING_STORE_PASSWORD&quot;) keyAlias System.getenv(&quot;SIGNING_KEY_ALIAS&quot;) keyPassword System.getenv(&quot;SIGNING_KEY_PASSWORD&quot;) } } buildTypes { // ... release { // ... applicationVariants.all { variant -&gt; variant.outputs.all { outputFileName = &quot;${rootProject.name}_${versionName}.apk&quot; } } signingConfig signingConfigs.release } } }</pre> <p>4. Add&nbsp;<strong>Github Workflow</strong>&nbsp;to your repository in the&nbsp;<strong>.github/workflows</strong>&nbsp;folder. Here&nbsp;<strong>&lt;&lt;application name&gt;&gt;</strong>&nbsp;and&nbsp;<strong>&lt;&lt;project name&gt;&gt;</strong>&nbsp;are placeholders for&nbsp;<strong>rootProject.name</strong>&nbsp;and your Github repository&rsquo;s name respectively.</p> <p><a href="https://medium.com/geekculture/how-to-build-sign-and-publish-android-application-using-github-actions-aa6346679254">Click Here</a></p>