<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nishit Bakraniya on Medium]]></title>
        <description><![CDATA[Stories by Nishit Bakraniya on Medium]]></description>
        <link>https://medium.com/@starlord125?source=rss-ffd76a1b4e44------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*m6I0KQU0Z-2sbdUL.jpg</url>
            <title>Stories by Nishit Bakraniya on Medium</title>
            <link>https://medium.com/@starlord125?source=rss-ffd76a1b4e44------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 02:34:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@starlord125/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kotlin CI/CD Script Using GitHub Actions]]></title>
            <link>https://medium.com/@starlord125/kotlin-ci-cd-script-using-github-actions-302f9ea49874?source=rss-ffd76a1b4e44------2</link>
            <guid isPermaLink="false">https://medium.com/p/302f9ea49874</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Nishit Bakraniya]]></dc:creator>
            <pubDate>Wed, 18 Sep 2024 21:21:18 GMT</pubDate>
            <atom:updated>2024-09-19T07:24:43.903Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NLVpH_sfweNJUehUEXSlxg.jpeg" /></figure><p>In this article, I’ll walk you through a GitHub Actions workflow that automates the release process of your Android app, generating both the <strong>Release Android App Bundle (AAB) and APK files</strong>, and uploading them to <strong>Google Play’s internal test track</strong>. This automation significantly reduces manual work, making the release process quicker and more reliable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*E9Oo70socewCpNMh.gif" /></figure><p>This is gonna be a very simple article,<br>I know we can add a lot of stuff into the scripts but I feel this is enough script for anyone who is struggling with how to write or where to begin &amp; If I write everything in 1 article it will be a headache</p><h3>NOTE: Before directly copying paste read the limitations online for testing</h3><p><a href="https://docs.github.com/en/actions/administering-github-actions/usage-limits-billing-and-administration">https://docs.github.com/en/actions/administering-github-actions/usage-limits-billing-and-administration</a></p><pre>name: Release bundle for internal test with generating release APK<br><br>on:<br>  workflow_dispatch:<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br><br>    env:<br>      KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}<br>      KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}<br>      SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}<br>      SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}<br>      SERVICE_ACCOUNT_JSON: ${{ secrets.SERVICE_ACCOUNT_JSON }}<br><br>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v4<br><br>      - name: Set up JDK<br>        uses: actions/setup-java@v4<br>        with:<br>          distribution: &#39;adopt&#39;<br>          java-version: &#39;17&#39;<br><br>      - name: Grant execute permission for gradlew<br>        run: chmod +x gradlew<br><br>      - name: Restore playstore.keystore.jks<br>        run: echo $KEYSTORE_FILE | base64 -d &gt; app/playstore.keystore.jks<br><br>      - name: List project files<br>        run: |<br>          echo &quot;Listing contents of the project directory:&quot;<br>          ls -al /home/runner/work/your-project-name/your-project-name<br>          echo &quot;Listing contents of the app directory:&quot;<br>          ls -al /home/runner/work/your-project-name/your-project-name/app<br><br>      - name: Build release AAB<br>        run: ./gradlew bundleRelease -PSIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS -PKEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PKEYSTORE_FILE=app/playstore.keystore.jks -PSIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORD<br><br>      - name: Build release APK<br>        run: ./gradlew bundleRelease -PSIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS -PKEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PKEYSTORE_FILE=app/playstore.keystore.jks -PSIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORD<br><br>      - name: Upload Release AAB<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: release-aab<br>          path: app/build/outputs/bundle/release/app-release.aab<br><br>      - name: Upload Release APK<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: release-apk<br>          path: app/build/outputs/apk/release/app-release.apk<br>      - name: Deploy to Play Store<br>      <br>        uses: r0adkll/upload-google-play@v1.1.3<br>        with:<br>          serviceAccountJsonPlainText: $SERVICE_ACCOUNT_JSON<br>          packageName: your-application-package-name<br>          releaseFiles: app/build/outputs/bundle/release/app-release.aab<br>          track: internal</pre><h3>Why I’ve written the full script first instead of the last?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*kbP-CxHhho30Ypkb.gif" /></figure><p>I know some of you guys are talented &amp; Don’t have time 🧐 <br>Don’t worry I’m one of you who can figure out everything later🤣</p><h3>1. The GitHub Actions Workflow</h3><p>Here’s a breakdown of the key components in this workflow:</p><h4>Triggering the Workflow</h4><p>The workflow is triggered manually using the workflow_dispatch event. This allows you to initiate the release process from the GitHub Actions UI whenever needed:</p><pre>on:<br>  workflow_dispatch:</pre><h3>2. Setting up the Job</h3><p>The workflow runs on the latest version of Ubuntu with the environment variables required for signing the APK and AAB. These variables include keystore credentials and the Google Play service account for uploading to the Play Store:</p><pre>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    env:<br>      KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}<br>      KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}<br>      SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}<br>      SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}<br>      SERVICE_ACCOUNT_JSON: ${{ secrets.SERVICE_ACCOUNT_JSON }}</pre><h3>3. Step-by-Step Breakdown</h3><h4>a. Checkout the Repository</h4><p>The first step checks out the project repository, allowing the workflow to work with the codebase:</p><pre>- name: Checkout repository<br>  uses: actions/checkout@v4</pre><h4>b. Set Up JDK</h4><p>Next, we set up Java Development Kit (JDK) version 17 for building the app. Android uses JDK for compiling the project:</p><pre>- name: Set up JDK<br>  uses: actions/setup-java@v4<br>  with:<br>    distribution: &#39;adopt&#39;<br>    java-version: &#39;17&#39;</pre><h4>c. Grant Execute Permissions</h4><p>Make the gradlew script executable to run Gradle tasks:</p><pre>- name: Grant execute permission for gradlew<br>  run: chmod +x gradlew</pre><h4>d. Restore Keystore File</h4><p>Since the keystore file is stored as a Base64 encoded secret, it needs to be decoded and saved as a physical file in the app’s directory:</p><pre>- name: Restore playstore.keystore.jks<br>  run: echo $KEYSTORE_FILE | base64 -d &gt; app/playstore.keystore.jks</pre><h3>4. Building the Release Bundle (AAB) and APK</h3><h4>a. Build Release AAB</h4><p>This command compiles the project and generates the Android App Bundle:</p><pre>- name: Build release AAB<br>  run: ./gradlew bundleRelease -PSIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS -PKEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PKEYSTORE_FILE=app/playstore.keystore.jks -PSIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORDyaml</pre><h4>b. Build Release APK</h4><p>The APK is also built using the same Gradle command, but targeting APK output:</p><pre>- name: Build release APK<br>  run: ./gradlew bundleRelease -PSIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS -PKEYSTORE_PASSWORD=$KEYSTORE_PASSWORD -PKEYSTORE_FILE=app/playstore.keystore.jks -PSIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORD</pre><h3>5. Uploading the Build Artifacts</h3><h4>a. Upload Release AAB</h4><p>Once the AAB is generated, it’s uploaded as an artifact for further use:</p><pre>- name: Upload Release AAB<br>  uses: actions/upload-artifact@v4<br>  with:<br>    name: release-aab<br>    path: app/build/outputs/bundle/release/app-release.aab</pre><h4>b. Upload Release APK</h4><p>Similarly, the APK is uploaded:</p><pre>- name: Upload Release APK<br>  uses: actions/upload-artifact@v4<br>  with:<br>    name: release-apk<br>    path: app/build/outputs/apk/release/app-release.apk</pre><h3>6. Deploying to Google Play’s Internal Track</h3><p>The final step in this workflow uploads the AAB to Google Play’s internal test track. This is done using the upload-google-play action, which requires a service account JSON for authentication:</p><pre>- name: Deploy to Play Store<br>  uses: r0adkll/upload-google-play@v1.1.3<br>  with:<br>    serviceAccountJsonPlainText: $SERVICE_ACCOUNT_JSON<br>    packageName: your-package-name<br>    releaseFiles: app/build/outputs/bundle/release/app-release.aab<br>    track: internal</pre><h3>Where to store those SECRET variables?</h3><ul><li>Go to <strong>Settings</strong> &gt; <strong>Secrets and Variables </strong>&gt; <strong>Actions</strong>.</li><li>So basically you will get 3 options to upload those secrets I’ll just sum up for you all if you don’t want to go through the whole documentation</li><li><strong>Repository-Level</strong>: Secrets specific to a single repository.</li><li><strong>Environment-Level</strong>: Secrets specific to different environments (dev, staging, prod) in a repository.</li><li><strong>Organization-Level</strong>: Secrets shared across multiple repositories in the same organization.</li><li><a href="https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions">Goto GitHub settings and use the same name that I’ve written or you can name it whatever you want</a></li></ul><h3>Where to put this script file &amp; name?</h3><ul><li>On the root level of the project of your Android application in Android studio</li><li><strong>Name: release.yaml</strong></li><li>The reference image is below</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*fR2t-_iSSWig_ccaUsUR0g.png" /></figure><h3>Will it trigger automatically?</h3><ul><li>No, you have to go to GitHub and from the Actions tab, you can select the branch from where you want to run <strong>make sure to update the version code &amp; version name from Gradle</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/0*XJWkKjQj1eLP-SV9.gif" /></figure><p>This script has been tested multiple times so if you face any issues I&#39;ll be here for you to solve your doubts &amp; Yes any suggestions &amp; corrections are welcome 🥰</p><h3>IF YOU LIKE IT, SHARE IT</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=302f9ea49874" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>