{"id":3127,"date":"2025-06-21T06:45:33","date_gmt":"2025-06-21T06:45:33","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=3127"},"modified":"2025-06-21T06:52:14","modified_gmt":"2025-06-21T06:52:14","slug":"exploring-and-creating-a-proof-of-concept-poc-to-upload-apk-directly-from-github-package","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/exploring-and-creating-a-proof-of-concept-poc-to-upload-apk-directly-from-github-package\/","title":{"rendered":"Exploring and Creating a Proof of Concept (POC) to Upload APK Directly from GitHub Package"},"content":{"rendered":"\n<p>Automating the process of uploading an APK (or AAB) to the Google Play Store from GitHub can significantly speed up your CI\/CD pipeline. By integrating Google Play\u2019s <strong>Internal Testing<\/strong> or <strong>Beta Testing<\/strong> environments with GitHub, you can automatically trigger a deployment of your Android app whenever you make changes or release a new version on GitHub.<\/p>\n\n\n\n<p>In this post, we&#8217;ll explore how to set up a <strong>Proof of Concept (POC)<\/strong> to upload an APK from GitHub (from GitHub Actions&#8217; package or release section) directly to the <strong>Google Play Store Test Environment<\/strong> (using Fastlane).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What You\u2019ll Need<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Google Play Console Account<\/strong>: Access to Google Play Developer API and permissions to upload APKs.<\/li>\n\n\n\n<li><strong>GitHub Repository<\/strong>: A repository with an Android app (APK or AAB).<\/li>\n\n\n\n<li><strong>GitHub Actions<\/strong>: We&#8217;ll use GitHub Actions to automate the upload process.<\/li>\n\n\n\n<li><strong>Fastlane<\/strong>: Fastlane is an open-source tool that automates app deployment tasks, including uploading APKs or AABs to Google Play.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step-by-Step Guide to Automate APK Upload from GitHub to Google Play Store Test Environment<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step1 : Set Up Google Play Developer API Access<\/strong><\/h4>\n\n\n\n<p>To upload your APK automatically from GitHub to the Google Play Store, you\u2019ll need to use the <strong>Google Play Developer API<\/strong>. This API allows you to automate the management of your app on the Google Play Console.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a Service Account in Google Cloud:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to the <a>Google Cloud Console<\/a>.<\/li>\n\n\n\n<li>In the <strong>IAM &amp; Admin<\/strong> section, create a new service account.<\/li>\n\n\n\n<li>Assign the <strong>Editor<\/strong> role or appropriate permissions for managing apps in the Google Play Console.<\/li>\n\n\n\n<li>Download the JSON key file for your service account.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Enable Google Play Developer API:<\/strong>\n<ul class=\"wp-block-list\">\n<li>In your Google Cloud project, search for <strong>Google Play Developer API<\/strong> and enable it.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Grant the Service Account Access to Google Play Console:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Go to your <a>Google Play Console<\/a>.<\/li>\n\n\n\n<li>Under <strong>Settings > API Access<\/strong>, link your Google Cloud project.<\/li>\n\n\n\n<li>In the <strong>API Access<\/strong> section, add the service account and grant it the <strong>Release Manager<\/strong> role.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step2 : Set Up Fastlane for Google Play Store Deployment<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Fastlane<\/strong>:<br>You can install Fastlane on your local machine or directly in the GitHub Actions workflow using the following commands:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Fastlane using RubyGems\ngem install fastlane\n<\/code><\/pre>\n\n\n\n<p><strong>Configure Fastlane for Google Play<\/strong>:<br>In your Android project, initialize Fastlane by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fastlane init\n<\/code><\/pre>\n\n\n\n<p>During the setup, choose <strong>&#8220;Google Play&#8221;<\/strong> as the platform, and Fastlane will generate the necessary configuration files.<\/p>\n\n\n\n<p><strong>Add Google Play API JSON Key to GitHub Secrets<\/strong>:<br>For security, store your <strong>Google Play Developer API JSON key<\/strong> in your GitHub repository\u2019s <strong>Secrets<\/strong>. In your GitHub repository:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Settings > Secrets<\/strong>.<\/li>\n\n\n\n<li>Add a new secret with the name <code>GOOGLE_PLAY_JSON_KEY<\/code> and paste the contents of your service account JSON key.<\/li>\n<\/ul>\n\n\n\n<p><strong>Fastlane Configuration<\/strong>:<br>Inside the <strong>fastlane<\/strong> directory of your Android project, configure the <code>Fastfile<\/code>. This file will define how Fastlane uploads the APK\/AAB to the Google Play Store.<\/p>\n\n\n\n<p><strong>Fastfile example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lane :deploy do\n  # Authenticate using the service account JSON key\n  json_key_file = ENV&#91;\"GOOGLE_PLAY_JSON_KEY\"]\n  credentials = JSON.parse(json_key_file)\n  google_play_service = google_play_credentials({\n    json_key: credentials,\n  })\n\n  # Upload APK or AAB to Google Play\n  upload_to_play_store(\n    track: \"beta\",  # Can be 'alpha', 'beta', 'production', etc.\n    aab: \".\/build\/outputs\/bundle\/release\/app-release.aab\",  # Path to your AAB\n    json_key_file: credentials,\n  )\nend\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>This configuration will upload the generated APK or AAB to the <strong>beta<\/strong> track in Google Play\u2019s internal testing environment.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step3 : Set Up GitHub Actions to Automate the Upload<\/strong><\/h4>\n\n\n\n<p>Now that Fastlane is set up, let&#8217;s create a GitHub Actions workflow to automate the process of building and uploading your APK from GitHub\u2019s release section to Google Play.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a GitHub Actions Workflow File<\/strong>:<br>Inside your repository, create the workflow file at <code>.github\/workflows\/deploy.yml<\/code>. <strong>Example GitHub Actions Workflow (deploy.yml):<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>name: Upload APK to Google Play\n\non:\n  push:\n    tags:\n      - 'v*'  # This will trigger the action on version tags, e.g., v1.0.0\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    - name: Checkout code\n      uses: actions\/checkout@v2\n\n    - name: Set up JDK 11\n      uses: actions\/setup-java@v2\n      with:\n        java-version: '11'\n\n    - name: Set up Gradle\n      uses: gradle\/wrapper-validation-action@v1\n\n    - name: Build APK\n      run: .\/gradlew assembleRelease  # Adjust this if you are using AAB or another flavor\n\n    - name: Set up Fastlane\n      uses: fastlane\/fastlane-action@v2\n      with:\n        lane: deploy\n      env:\n        GOOGLE_PLAY_JSON_KEY: ${{ secrets.GOOGLE_PLAY_JSON_KEY }}\n\n    - name: Upload to Google Play Store\n      run: fastlane deploy\n      env:\n        GOOGLE_PLAY_JSON_KEY: ${{ secrets.GOOGLE_PLAY_JSON_KEY }}\n<\/code><\/pre>\n\n\n\n<p><strong>Explanation of Workflow<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This workflow listens for <code>push<\/code> events on tags that start with <code>v<\/code>, such as <code>v1.0.0<\/code>.<\/li>\n\n\n\n<li>The workflow sets up the environment by installing JDK 11 and Gradle, builds the APK or AAB, and then uses Fastlane to upload the APK\/AAB to the <strong>Google Play Test Environment<\/strong> (beta).<\/li>\n\n\n\n<li>The <code>GOOGLE_PLAY_JSON_KEY<\/code> secret is used to authenticate with Google Play.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step4 : Trigger the Workflow<\/strong><\/h4>\n\n\n\n<p>Once the workflow is set up, you can trigger it by pushing a tag to your repository. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git tag v1.0.0\ngit push origin v1.0.0\n<\/code><\/pre>\n\n\n\n<p>This will automatically trigger the GitHub Actions workflow, which will build your APK and upload it to the Google Play <strong>beta<\/strong> track.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 5: Test the APK in the Google Play Test Environment<\/strong><\/h4>\n\n\n\n<p>After the upload completes, testers you\u2019ve added to the <strong>Google Play Console\u2019s beta track<\/strong> will receive an email with a link to download the app. They can start testing the APK or AAB in a real-world environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automating the process of uploading an APK (or AAB) to the Google Play Store from GitHub can significantly speed up your CI\/CD pipeline. By integrating Google Play\u2019s&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2655,2654,981,1581,2661,2657,1592,1876,1591,1957,2650,2656,2645,2658,2646,2631,2659,1583,2632,2660],"class_list":["post-3127","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-aab-upload","tag-android-app-deployment","tag-android-development","tag-apk-upload","tag-app-release-automation","tag-automated-deployment","tag-ci-cd","tag-continuous-deployment","tag-continuous-integration","tag-devops-automation","tag-fastlane","tag-fastlane-google-play","tag-github-actions","tag-github-actions-ci-cd","tag-github-workflow","tag-google-play-console","tag-google-play-developer-api","tag-google-play-store","tag-mobile-app-testing","tag-test-environment-deployment"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=3127"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3127\/revisions"}],"predecessor-version":[{"id":3128,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/3127\/revisions\/3128"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=3127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=3127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=3127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}