├── .github └── workflows │ ├── base-image.yaml │ ├── lint-and-tests.yaml │ ├── production.yaml │ └── staging.yaml ├── .gitignore ├── .gitlab-ci.yml ├── Dockerfile ├── Gemfile ├── LICENSE.md ├── README.md ├── app ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ └── codepath │ │ └── demos │ │ └── helloworlddemo │ │ └── HelloWorldActivity.kt │ └── res │ ├── layout │ └── activity_hello_world.xml │ ├── menu │ └── activity_hello_world.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ └── values │ ├── ic_launcher_background.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── docs ├── README_GOOGLE_PLAY.md ├── README_RU.md ├── android-ci-cd-CI-CD-flow.drawio.svg ├── android-ci-cd-tools.drawio.svg ├── android-ci-cd.drawio ├── badge_prod.png ├── badge_staging.png ├── gcp1.jpeg ├── gcp2.jpeg ├── gcp3.jpeg ├── gcp4.jpeg ├── gcp5.jpeg ├── gcp6.jpeg ├── gcp7.jpeg ├── googleplay1.jpeg ├── googleplay2.jpeg ├── googleplay3.jpeg ├── gp1.jpeg ├── gp2.jpeg ├── gp3.jpeg ├── gp4.jpeg ├── gp5.jpeg └── gp6.jpeg ├── fastlane ├── Appfile ├── Fastfile └── Pluginfile ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── project.properties └── settings.gradle /.github/workflows/base-image.yaml: -------------------------------------------------------------------------------- 1 | name: 'build and push base image' 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'Dockerfile' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: docker/metadata-action@v3 16 | with: 17 | images: ghcr.io/${{ github.repository }} 18 | - uses: docker/login-action@v1 19 | with: 20 | registry: ghcr.io 21 | username: ${{ github.actor }} 22 | password: ${{ secrets.GITHUB_TOKEN }} 23 | - uses: int128/kaniko-action@v1 24 | with: 25 | push: true 26 | tags: ghcr.io/${{ github.repository }}:latest 27 | cache: true 28 | cache-repository: ghcr.io/${{ github.repository }}/cache 29 | 30 | -------------------------------------------------------------------------------- /.github/workflows/lint-and-tests.yaml: -------------------------------------------------------------------------------- 1 | name: 'lint and tests' 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened, synchronize] 6 | branches: 7 | - main 8 | push: 9 | branches: 10 | - main 11 | 12 | env: 13 | GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} 14 | APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }} 15 | 16 | jobs: 17 | lint: 18 | runs-on: ubuntu-latest 19 | container: 20 | image: ghcr.io/${{ github.repository }}:latest 21 | credentials: 22 | username: ${{ github.actor }} 23 | password: ${{ secrets.github_token }} 24 | steps: 25 | - uses: actions/checkout@v3 26 | - uses: actions/cache@v2 27 | with: 28 | path: | 29 | ~/.gradle/caches 30 | ~/.gradle/wrapper 31 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 32 | restore-keys: | 33 | ${{ runner.os }}-gradle- 34 | - run: | 35 | echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 36 | bundle exec fastlane lint 37 | 38 | unit_tests: 39 | runs-on: ubuntu-latest 40 | container: 41 | image: ghcr.io/${{ github.repository }}:latest 42 | credentials: 43 | username: ${{ github.actor }} 44 | password: ${{ secrets.github_token }} 45 | steps: 46 | - uses: actions/checkout@v3 47 | - uses: actions/cache@v2 48 | with: 49 | path: | 50 | ~/.gradle/caches 51 | ~/.gradle/wrapper 52 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 53 | restore-keys: | 54 | ${{ runner.os }}-gradle- 55 | - run: | 56 | echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 57 | bundle exec fastlane unit_test 58 | -------------------------------------------------------------------------------- /.github/workflows/production.yaml: -------------------------------------------------------------------------------- 1 | name: 'production' 2 | 3 | on: 4 | workflow_run: 5 | workflows: ['staging'] 6 | branches: [main] 7 | types: 8 | - completed 9 | 10 | env: 11 | KEYSTORE_PW: ${{ secrets.KEYSTORE_PW }} 12 | KEYSTORE: ${{ secrets.KEYSTORE }} 13 | SA_JSON_KEY: ${{ secrets.SA_JSON_KEY }} 14 | ALIAS: ${{ secrets.ALIAS }} 15 | ALIAS_PW: ${{ secrets.ALIAS_PW }} 16 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 17 | GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} 18 | APP_VERSION_NAME: ${{ secrets.APP_VERSION_NAME }} 19 | FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID_PROD }} 20 | CI_PIPELINE_ID: ${{ github.run_number }} 21 | CI_COMMIT_BEFORE_SHA: ${{ github.event.before }} 22 | APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }} 23 | CI_ENVIRONMENT_NAME: ${{ github.workflow }} 24 | 25 | jobs: 26 | prod_firebase: 27 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 28 | runs-on: ubuntu-latest 29 | container: 30 | image: ghcr.io/${{ github.repository }}:latest 31 | credentials: 32 | username: ${{ github.actor }} 33 | password: ${{ secrets.github_token }} 34 | steps: 35 | - uses: actions/checkout@v3 36 | - uses: actions/cache@v2 37 | with: 38 | path: | 39 | ~/.gradle/caches 40 | ~/.gradle/wrapper 41 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 42 | restore-keys: | 43 | ${{ runner.os }}-gradle- 44 | - run: | 45 | echo $KEYSTORE | base64 -d -i > /tmp/my-release-key.keystore 46 | echo $SA_JSON_KEY | base64 -d -i > key_firebase.json 47 | echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 48 | bundle exec fastlane firebase_distribution 49 | env: 50 | FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID_PROD }} 51 | BUILD_TASK: "assemble" # Change to bundle if you need aab application 52 | BUILD_TYPE: "release" 53 | 54 | google_play: 55 | if: ${{ github.event.workflow_run.conclusion == 'success' }} 56 | needs: [prod_firebase] 57 | runs-on: ubuntu-latest 58 | container: 59 | image: ghcr.io/${{ github.repository }}:latest 60 | credentials: 61 | username: ${{ github.actor }} 62 | password: ${{ secrets.github_token }} 63 | steps: 64 | - uses: trstringer/manual-approval@v1 65 | with: 66 | secret: ${{ github.TOKEN }} 67 | approvers: ${{ secrets.APPROVERS }} 68 | - uses: actions/checkout@v3 69 | - run: | 70 | echo $SA_JSON_GP_KEY | base64 -d -i > /tmp/key_gp.json 71 | echo $KEYSTORE | base64 -d -i > /tmp/my-release-key.keystore 72 | echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 73 | bundle exec fastlane google_beta 74 | env: 75 | BUILD_TASK: "bundle" 76 | BUILD_TYPE: "release" 77 | SA_JSON_GP_KEY: ${{ secrets.SA_JSON_GP_KEY }} 78 | -------------------------------------------------------------------------------- /.github/workflows/staging.yaml: -------------------------------------------------------------------------------- 1 | name: 'staging' 2 | 3 | on: 4 | workflow_run: 5 | workflows: ['lint and tests'] 6 | branches: [main] 7 | types: 8 | - completed 9 | workflow_dispatch: 10 | 11 | env: 12 | KEYSTORE_PW: ${{ secrets.KEYSTORE_PW }} 13 | KEYSTORE: ${{ secrets.KEYSTORE }} 14 | SA_JSON_KEY: ${{ secrets.SA_JSON_KEY }} 15 | ALIAS: ${{ secrets.ALIAS }} 16 | ALIAS_PW: ${{ secrets.ALIAS_PW }} 17 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 18 | GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} 19 | APP_VERSION_NAME: ${{ secrets.APP_VERSION_NAME }} 20 | FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID_STG }} 21 | CI_PIPELINE_ID: ${{ github.run_number }} 22 | CI_COMMIT_BEFORE_SHA: ${{ github.event.before }} 23 | APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }} 24 | BUILD_TASK: "assemble" 25 | BUILD_TYPE: "debug" 26 | CI_ENVIRONMENT_NAME: ${{ github.workflow }} 27 | 28 | jobs: 29 | staging_firebase: 30 | if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch' && github.event.workflow_run.conclusion != 'success') }} 31 | runs-on: ubuntu-latest 32 | container: 33 | image: ghcr.io/${{ github.repository }}:latest 34 | credentials: 35 | username: ${{ github.actor }} 36 | password: ${{ secrets.github_token }} 37 | steps: 38 | - uses: actions/checkout@v3 39 | - uses: actions/cache@v2 40 | with: 41 | path: | 42 | ~/.gradle/caches 43 | ~/.gradle/wrapper 44 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 45 | restore-keys: | 46 | ${{ runner.os }}-gradle- 47 | - run: | 48 | echo $KEYSTORE | base64 -d -i > /tmp/my-release-key.keystore 49 | echo $SA_JSON_KEY | base64 -d -i > key_firebase.json 50 | echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 51 | bundle exec fastlane firebase_distribution 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | build/ 4 | local.properties -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | default: 2 | image: $CI_REGISTRY_IMAGE:latest 3 | # tags: 4 | # - my-tag 5 | 6 | before_script: 7 | - export GRADLE_USER_HOME=cache/.gradle 8 | - echo $KEYSTORE | base64 -d -i > /tmp/my-release-key.keystore 9 | - echo $SA_JSON_KEY | base64 -d -i > key_firebase.json 10 | - echo $GOOGLE_SERVICES_JSON | base64 -d -i > app/google-services.json 11 | 12 | cache: 13 | key: 14 | files: 15 | - gradle/wrapper/gradle-wrapper.properties 16 | paths: 17 | - $PWD/cache/.gradle/ 18 | 19 | stages: 20 | - build_base_image 21 | - tests 22 | - deploy_staging 23 | - deploy_prod 24 | 25 | build_base_image: 26 | rules: 27 | - if: $CI_COMMIT_REF_NAME == "main" 28 | changes: 29 | - Dockerfile 30 | stage: build_base_image 31 | image: 32 | name: gcr.io/kaniko-project/debug:769 33 | entrypoint: [""] 34 | before_script: 35 | - mkdir -p /kaniko/.docker 36 | - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json 37 | script: 38 | - >- 39 | /kaniko/executor 40 | --context "${CI_PROJECT_DIR}" 41 | --dockerfile "${CI_PROJECT_DIR}/Dockerfile" 42 | --destination $CI_REGISTRY_IMAGE:latest 43 | 44 | 45 | lints: 46 | rules: 47 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" 48 | - if: $CI_COMMIT_REF_NAME == "main" 49 | stage: tests 50 | script: 51 | - bundle exec fastlane lint 52 | 53 | unit_test: 54 | rules: 55 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" 56 | - if: $CI_COMMIT_REF_NAME == "main" 57 | stage: tests 58 | script: 59 | - bundle exec fastlane unit_test 60 | 61 | staging_firebase: 62 | rules: 63 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" 64 | when: manual 65 | - if: $CI_COMMIT_REF_NAME == "main" 66 | stage: deploy_staging 67 | script: 68 | - bundle exec fastlane firebase_distribution 69 | environment: 70 | name: staging 71 | 72 | prod_firebase: 73 | rules: 74 | - if: $CI_COMMIT_REF_NAME == "main" 75 | stage: deploy_prod 76 | script: 77 | - bundle exec fastlane firebase_distribution 78 | artifacts: 79 | paths: 80 | - app/build/outputs/bundle/release/app-release.aab 81 | expire_in: 1 day 82 | environment: 83 | name: prod 84 | 85 | google_play: 86 | rules: 87 | - if: $CI_COMMIT_REF_NAME == "main" 88 | when: manual 89 | stage: deploy_prod 90 | script: 91 | - echo $SA_JSON_GP_KEY | base64 -d -i > /tmp/key_gp.json 92 | - bundle exec fastlane google_beta 93 | dependencies: 94 | - prod_firebase 95 | environment: 96 | name: prod-gp 97 | when: manual 98 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:11-jdk-slim-buster 2 | 3 | # Just matched `app/build.gradle` 4 | ENV ANDROID_COMPILE_SDK "30" 5 | 6 | # Just matched `app/build.gradle` 7 | ENV ANDROID_BUILD_TOOLS "30.0.2" 8 | 9 | # Version from https://developer.android.com/studio/releases/sdk-tools 10 | ENV ANDROID_SDK_TOOLS "7583922" 11 | ENV ANDROID_HOME /android-sdk-linux 12 | ENV PATH="${PATH}:/android-sdk-linux/platform-tools/" 13 | 14 | # Install OS packages 15 | RUN apt-get --quiet update --yes && \ 16 | apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 build-essential ruby ruby-dev graphicsmagick 17 | 18 | # Install Android SDK 19 | RUN wget --quiet --output-document=android-sdk.zip "https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip" && \ 20 | unzip -d ${ANDROID_HOME} android-sdk.zip && \ 21 | yes | ./android-sdk-linux/cmdline-tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" --sdk_root=android-sdk-linux/ && \ 22 | yes | ./android-sdk-linux/cmdline-tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" --sdk_root=android-sdk-linux && \ 23 | # Clean cache 24 | apt-get clean autoclean && \ 25 | apt-get autoremove --yes && \ 26 | rm -rf /var/lib/{apt,dpkg,cache,log}/ android-sdk.zip 27 | 28 | # Install Fastlane 29 | COPY Gemfile . 30 | RUN gem install bundler && \ 31 | bundle install && \ 32 | gem install fastlane-plugin-firebase_app_distribution fastlane-plugin-badge 33 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "fastlane" 4 | 5 | plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') 6 | eval_gemfile(plugins_path) if File.exist?(plugins_path) 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boilerplate to Prepare a CI/CD for Android Applications 2 | 3 | [![Developed by Mad Devs](https://maddevs.io/badge-dark.svg)](https://maddevs.io?utm_source=github&utm_medium=madboiler) 4 | [![License](https://img.shields.io/github/license/maddevsio/android-ci-cd)](https://github.com/maddevsio/android-ci-cd/blob/main/LICENSE.md) 5 | 6 | #### README Languages 7 | * [Russian](docs/README_RU.md) 8 | 9 | Stop publishing your Android apps manually and start doing this in a fully automated fashion to any stage (test, beta, and prod). 10 | 11 | 👇 Watch this 5 min explanation video to get a deeper understanding of the approach and benefits 👇 12 | [![Android CI CD](https://img.youtube.com/vi/poSugKUtBPU/0.jpg)](https://youtu.be/poSugKUtBPU) 13 | 14 | --- 15 | 16 | ## Advantages of this boilerplate 17 | 18 | * **Quick start CI/CD**: With this boilerplate, you can easily build the CI/CD for your android app based on Fastlane. 19 | * **Easy adaptation to external CI/CD tools**: We use GitLab-ci or GitHub actions as the executor of Fastlane commands and the construction of the workflow. 20 | * **Notification**: Pipeline operation Slack notifications, notifications about successful operations or errors in the pipeline process. 21 | * **No special build machine setup is required**: We build the application inside a docker container with all the dependencies installed; this provides portability and the ability to use standard GitHub agents or GitLab runners. 22 | 23 | ## CI/CD 24 | 25 | * Let's try to answer some questions: 26 | * [What is CI/CD](https://en.wikipedia.org/wiki/CI/CD)? 27 | * Above all, CI/CD allows you to increase productivity through automation. As in the manufacturing industry, 28 | you can automate the repetitive assembly process (application assembly) with automated workers, allowing developers to focus on value-added design and development processes. 29 | * What are the benefits of using CI/CD in mobile development? 30 | 1. `Faster release cycles` 31 | * With CI/CD, developers get used to make even the smallest code changes, as they will be built and delivered automatically in the background. This automated flow ensures that there is always an alpha or beta release ready for testing with the latest code. 32 | 2. `Faster feedback/response with "continuous integration"` 33 | * With a faster release cycle with fewer changes, it becomes possible to pinpoint the source of a bug when a problem is identified. This is especially important for large teams where code conflicts can cause significant problems. 34 | 3. `Improve coding discipline with query-based assembly and automated tests` 35 | * With a pull request commit, the build occurs before the merge, followed by automatic unit testing and code verification after each merge; the code itself is tested more thoroughly before it becomes part of the release. 36 | 4. `Early warning and increased testing with "continuous deployment"` 37 | * By testing each individual change with multiple steps in the testing workflow, problems can be identified faster. 38 | 5. `Isolation from the complexities associated with application delivery` 39 | * Every development discipline has its own set of complexities, and mobile apps are no exception. Android has completely independent and different processes for creating, signing, distributing, and installing apps. CI/CD helps to automate this process. 40 | 41 | ### CI/CD description 42 | 43 | * This diagram describes the flow which we use 44 | 45 | ![flow](docs/android-ci-cd-CI-CD-flow.drawio.svg) 46 | 47 | * Step descriptions 48 | 49 | ``` 50 | - build base image - Step for build base image which used for build application. 51 | - tests and lints - Step for run tests and lints. 52 | - build and deploy to firebase - Step for build and deploy application to Firebase. 53 | - build and deploy to google play - Step for build and deploy application and Google Play. 54 | ``` 55 | 56 | * It is worth explaining what several builds are used for. 57 | 58 | Terms and conditions: 59 | * Applications in `apk` format cannot be uploaded to Google Play 60 | * Applications in `aab` format can be uploaded in Firebase and Google Play 61 | 62 | Because of it, we have to build several builds. 63 | 64 | * For the convenience of testing, at the stage of `Merge Request`, we give the opportunity to build the application on demand and send it to `Firebase`. 65 | * It is convenient to check your application without merging code to the main branch. 66 | * The application in `apk` format upload to the Firebase. 67 | 68 | ### Feature 69 | 70 | * GitLab: 71 | * We have a manual step to deploy an application to Google Play. 72 | * We have a manual step for building and deploying an application to staging `Firebase`; this step is available on `Merge Request1`. 73 | * GitHub: 74 | * We use [trstringer/manual-approval](https://trstringer.com/github-actions-manual-approval/) action, which helps to create manual approval in the deployment to Google Play. 75 | * We use a manual job - `workflow_dispatcher` for building and deploying an application from any branch. 76 | * Fastlane plugin badge 77 | * This gem helps to add a badge to your Android app icon. 78 | * More info [here](https://docs.fastlane.tools/actions/badge/) 79 | * You can always configure it for your project, but here are examples of how we did it. 80 | 81 | ![staging](docs/badge_staging.png) ![prod](docs/badge_prod.png) 82 | 83 | ### Tools and services 84 | 85 | * [Fastlane](https://fastlane.tools/) - Fastlane is a tool for iOS and Android developers to automate tedious tasks like generating screenshots, dealing with provisioning profiles, and releasing your application. 86 | * [GitLab-ci](https://docs.gitlab.com/ee/ci/) or [GitHub Actions](https://docs.github.com/en/actions) - CI/CD systems are used to build the pipeline logic and to execute Fastlane lanes. 87 | * [docker](https://www.docker.com/) - Docker is used as the build environment for the application. 88 | * [CGP](https://cloud.google.com/) 89 | * [Firebase](https://firebase.google.com/docs/app-distribution) - Testing environment for the application. 90 | * [Google Play](https://play.google.com/console/about/) - Production environment for the application. 91 | 92 | ### Description of main components 93 | 94 | ![main](docs/android-ci-cd-tools.drawio.svg) 95 | 96 | ### Repository structure 97 | 98 | ```commandline 99 | . 100 | ├── app - Folder which contains example application 101 | │   ├── build.gradle - File for android project configuration 102 | │   └── src 103 | ├── build.gradle 104 | ├── Dockerfile - Dockerfile for base image which used in build step 105 | ├── docs - Folder for documentation 106 | ├── fastlane - Folder with fastlane configuration 107 | │   ├── Appfile - File for main fastlane configuration 108 | │   ├── Fastfile - File for configuration fastlane actions 109 | │   └── Pluginfile - File for configuration fastlane dependencies 110 | ├── Gemfile 111 | ├── gradle - Folder for gradle build tool 112 | ├── gradle.properties - File for gradle configuration 113 | ├── gradlew 114 | ├── gradlew.bat 115 | ├── ic_launcher-web.png 116 | ├── libs 117 | ├── proguard-project.txt 118 | ├── project.properties 119 | ├── README.md 120 | └── settings.gradle - File for graddle setting 121 | ``` 122 | 123 | ### From scratch 124 | 125 | 1. [Create an account in the Google cloud platform](https://cloud.google.com/) 126 | 2. [Create a Google cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects) 127 | 3. [Create a Firebase project and activate app distribution](https://cloud.google.com/firestore/docs/client/get-firebase) 128 | 4. [Create a Google Play developer account](https://play.google.com/console/about/) 129 | 130 | #### Preparation keys and environment variables 131 | 132 | 1. Json file with configuration for Firebase 133 | * You must add a json file with the Firebase project settings encoded to base64 to the environment variable. 134 | > https://firebase.google.com/docs/android/setup - Step 3 135 | ```bash 136 | base64 google-services.json > firebase_setting 137 | ``` 138 | 139 | 2. Service account with access to Firebase 140 | * Create Service Account for the release application to Firebase 141 | > Choose your Firebase account --> Project Overview --> Project setting --> Service Account --> create service account 142 | * Add SA key encoded to base64 to an environment variable. 143 | ```bash 144 | base64 sa.json > key_firebase 145 | ``` 146 | 147 | 3. Service account with access to Google Play 148 | * Create Service Account for release application to [Google Play](docs/README_GOOGLE_PLAY.md) 149 | * Add SA key encoded to base64 to an environment variable 150 | ```bash 151 | base64 google_play.json > google_play 152 | ``` 153 | 154 | 4. Keystore for signing an application 155 | * To sign an application, you need a key, which can be generated with the command. 156 | ```bash 157 | keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 158 | ``` 159 | * Add signing keystore encoded to base64 to an environment variable. 160 | ```bash 161 | base64 my-release-key.keystore > keystore 162 | ``` 163 | 164 | ##### GitLab CI/CD 165 | 166 | * We use `Environments` in our pipeline to divide our variables by environments; before you start please create 3 environments in `gitlab-ci-cd`: 167 | 168 | ``` 169 | GitLab --> Deployments --> Environment --> New Environment 170 | ``` 171 | 172 | * We need to create three environments: 173 | * staging 174 | * prod 175 | * prod-gp 176 | 177 | ##### GitHub Actions 178 | 179 | * We can use environments in GitHub Actions, but the environments are available only in public repositories or in corporate subscriptions. 180 | * In this boilerplate, we don't use environments in GitHub Actions. 181 | 182 | ##### Prepare environment variables 183 | 184 | 1. Copy content of this file `firebase_setting`: 185 | ``` 186 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 187 | ``` 188 | or 189 | ``` 190 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 191 | ``` 192 | 193 | > In the key field paste `GOOGLE_SERVICES_JSON` in the value field paste your `google-services.json` encoded to base64. 194 | 195 | 2. Copy content of this file `key_firebase`: 196 | ``` 197 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 198 | ``` 199 | or 200 | ``` 201 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 202 | ``` 203 | 204 | > In the key field paste `SA_JSON_KEY` in the value field paste your `sa.key` encoded to base64. 205 | 206 | 3. Copy content of this file `google_play`: 207 | 208 | ``` 209 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 210 | ``` 211 | or 212 | ``` 213 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 214 | ``` 215 | 216 | > In the key field paste `SA_JSON_GP_KEY` in the value field paste your `google_play.json` encoded to base64. 217 | 218 | 4. Copy content of this file `keystore`: 219 | 220 | ``` 221 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 222 | ``` 223 | or 224 | ``` 225 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 226 | ``` 227 | > In the key field paste `KEYSTORE` in the value field paste your `my-release-key.keystore` encoded to base64. 228 | 229 | ##### Environment variables 230 | 231 | | NAME | ENVIRONMENT | DESCRIPTION | 232 | |-----------------------------|:--------------------:|-----------------------------------------------------------------------------------------------------------------------------------------------:| 233 | | KEYSTORE | ALL | Encoded to base64 signing keystore (base64) | 234 | | KEYSTORE_PW | ALL | Password for signing keystore | 235 | | ALIAS | ALL | Keystore alias | 236 | | ALIAS_PW | ALL | Password for keystore alias | 237 | | SA_JSON_KEY | STAGING/PROD | Service Account key for Firebase (base64) | 238 | | SA_JSON_GP_KEY | PROD-GP | Service account key for Google Play Console (base64) | 239 | | GOOGLE_SERVICES_JSON | ALL | Main configuration file for Firebase | 240 | | APP_VERSION_NAME | STAGING/PROD/PROD-GP | Application version | 241 | | FIREBASE_APP_ID | STAGING/PROD | Application ID in Firebase | 242 | | BUILD_TASK | STAGING/PROD/PROD-GP | Task name in gradle (assemble, bundle, test) | 243 | | BUILD_TYPE | STAGING/PROD/PROD-GP | Build type (assemble, release) | 244 | | SLACK_WEBHOOK_URL | ALL | Slack webhook | 245 | | FIREBASE_TESTER_GROUP_NAME | STAGING/PROD | Name of testers group in Firebase | 246 | | APPROVERS | ALL | List of approvers for Google Play release, used only in GitHub Actions | 247 | | CI_PIPELINE_ID | ALL | Pipeline ID used for `versionCode`, by default declared in the GitLab, in the GitHub Actions used github.run_number | 248 | | CI_COMMIT_BEFORE_SHA | ALL | Previous commit, used for build changelog, by default declared in the GitLab, in the GitHub Actions used github.event.before | 249 | | FIREBASE_ARTIFACT_TYPE | STAGING/PROD | Artifact type for Firebase distribution | 250 | | PROJECT_DIR | ALL | If the project is not in the main directory, you can specify the path to the project directory through the `PROJECT_DIR` variable in Fastfile. | 251 | | APP_PACKAGE_NAME | ALL | The default android package name for example we use `com.boiler.android.hello` | 252 | | CI_ENVIRONMENT_NAME | STAGING/PROD | Used in fastlane badge, to display env in icon. | 253 | 254 | * When you complete all this preparation, you can start to build and release the application to Firebase 255 | 256 | ### Additional configuration 257 | 258 | #### Configuration plugins for Fastlane 259 | 260 | * We have `Pluginfile` in this file we can configure plugins for Fastlane, by default we use [fastlane-plugin-firebase_app_distribution](https://github.com/fastlane/fastlane-plugin-firebase_app_distribution) and [fastlane-plugin-badge](https://github.com/HazAT/fastlane-plugin-badge) 261 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | id 'com.google.gms.google-services' 5 | } 6 | 7 | def getVersionCode = { -> 8 | def code = project.hasProperty('versionCode') ? versionCode.toInteger() : Integer.MAX_VALUE 9 | println "VersionCode is set to $code" 10 | return code 11 | } 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | android { 18 | compileSdk 32 19 | 20 | defaultConfig { 21 | applicationId System.env.APP_PACKAGE_NAME 22 | minSdk 24 23 | targetSdk 32 24 | versionCode getVersionCode() 25 | versionName System.env.APP_VERSION_NAME 26 | 27 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 28 | 29 | } 30 | 31 | buildTypes { 32 | 33 | release { 34 | debuggable false 35 | minifyEnabled true 36 | 37 | resValue "string", "app_name", "boiler" 38 | } 39 | 40 | debug { 41 | debuggable true 42 | minifyEnabled false 43 | 44 | resValue "string", "app_name", "staging boiler" 45 | 46 | applicationIdSuffix ".staging" 47 | versionNameSuffix "-S" 48 | } 49 | } 50 | 51 | buildFeatures { 52 | viewBinding true 53 | } 54 | 55 | compileOptions { 56 | sourceCompatibility JavaVersion.VERSION_1_8 57 | targetCompatibility JavaVersion.VERSION_1_8 58 | } 59 | 60 | 61 | flavorDimensions 'app' 62 | 63 | } 64 | 65 | dependencies { 66 | implementation "androidx.core:core-ktx:1.8.0" 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/codepath/demos/helloworlddemo/HelloWorldActivity.kt: -------------------------------------------------------------------------------- 1 | package codepath.demos.helloworlddemo 2 | 3 | import android.app.Activity 4 | import android.os.Bundle 5 | import android.view.Menu 6 | 7 | class HelloWorldActivity : Activity() { 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_hello_world) 11 | } 12 | 13 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 14 | // Inflate the menu; this adds items to the action bar if it is present. 15 | menuInflater.inflate(R.menu.activity_hello_world, menu) 16 | return true 17 | } 18 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_hello_world.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_hello_world.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #111213 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello world! 4 | Settings 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.0' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | gradlePluginPortal() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.2.2' 10 | classpath 'com.google.gms:google-services:4.3.12' 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | gradlePluginPortal() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/README_GOOGLE_PLAY.md: -------------------------------------------------------------------------------- 1 | # Create Service Account for release application to google play 2 | 3 | 1. Enable API access on Google Play Console 4 | 1.1 Go to the Google Play console and go to Settings > Developer account > API access 5 | 6 | ![googleplay1](googleplay1.jpeg) 7 | 8 | 1.2 Choose a project to link and agree to the terms and conditions. 9 | 10 | 1.3 Click on the link to create a service account 11 | 12 | ![googleplay2](googleplay2.jpeg) 13 | 14 | 1.4. Click on the link to go to the Google Cloud Platform 15 | 16 | ![googleplay3](googleplay3.jpeg) 17 | 18 | 2. Configure Google Cloud Platform 19 | 20 | 2.1. Click on the link to create a service account 21 | 22 | ![gcp1](gcp1.jpeg) 23 | 24 | 2.2. Enter service account name and description and click on the create button 25 | 26 | ![gcp2](gcp2.jpeg) 27 | 28 | 2.3. Select Owner role and click on the done 29 | 30 | ![gcp3](gcp3.jpeg) 31 | 32 | 2.4. Open the actions menu and click on Manage keys 33 | 34 | ![gcp4](gcp4.jpeg) 35 | 36 | 2.5. Click on Add Key and then click on Create new key 37 | 38 | ![gcp5](gcp5.jpeg) 39 | 40 | 2.6. Select JSON and click on Create 41 | 42 | ![gcp6](gcp6.jpeg) 43 | 44 | 2.7. A JSON file should be downloaded, it gives access to the service account. 45 | 46 | ![gcp7](gcp7.jpeg) 47 | 48 | 3. Configure API access on Google Play Console 49 | 50 | 3.1. Go back to the API access page of the Google Play Console, your service account should appear, click on Grant access 51 | 52 | ![gp1](gp1.jpeg) 53 | 54 | 3.2. Enable the 3 permissions bellow and click on Invite user 55 | 56 | ![gp2](gp2.jpeg) 57 | 58 | 3.3. A modal should appear, click on Invite user 59 | 60 | ![gp3](gp3.jpeg) 61 | 62 | 3.4. You should be redirected to the Users and permissions page, click on your service account 63 | 64 | ![gp4](gp4.jpeg) 65 | 66 | 3.5. Click on Add app, select your app and click on Apply 67 | 68 | ![gp5](gp5.jpeg) 69 | 70 | 3.6. A modal should appear, click on Apply 71 | 72 | ![gp6](gp6.jpeg) 73 | -------------------------------------------------------------------------------- /docs/README_RU.md: -------------------------------------------------------------------------------- 1 | # Бойлер для подготовки CI/CD для Android приложений 2 | 3 | [![Developed by Mad Devs](https://maddevs.io/badge-dark.svg)](https://maddevs.io?utm_source=github&utm_medium=madboiler) 4 | [![License](https://img.shields.io/github/license/maddevsio/android-ci-cd)](https://github.com/maddevsio/android-ci-cd/blob/main/LICENSE.md) 5 | 6 | Больше нет необходимости публиковать Android-приложения вручную. Начните делать это полностью автоматически на любом этапе (test, beta и prod). 7 | 8 | 👇 Посмотрите этот 5-минутный видеоролик, чтобы лучше понять подход и преимущества.👇 9 | [![Android CI CD](https://img.youtube.com/vi/poSugKUtBPU/0.jpg)](https://youtu.be/poSugKUtBPU) 10 | 11 | --- 12 | 13 | ## Преимущества бойлера 14 | 15 | * **Быстрый запуск CI/CD**: С помощью этого бойлера вы сможете легко создать CI/CD для вашего android-приложения на основе платформы [Fastlane](https://fastlane.tools/). 16 | * **Простая адаптация к внешним инструментам CI/CD**: Мы используем GitLab-ci или GitHub actions в качестве исполнителя команд Fastlane и построения процесса сборки и поставки. 17 | * **Уведомления**: Получение уведомления в Slack об успешных операциях или ошибках в процессе выполнения пайплайна. 18 | * **Нет необходимости в настройке специальной машины для сборки**: Мы собираем приложение внутри docker контейнера со всеми установленными зависимостями; это обеспечивает переносимость и возможность использования стандартных GitHub agents или GitLab runners. 19 | 20 | ## CI/CD 21 | 22 | * Давайте прежде всего ответим на некоторые вопросы: 23 | * [Что такое CI/CD?](https://ru.wikipedia.org/wiki/CI/CD) 24 | * CI/CD позволяет повысить производительность за счет автоматизации. Как и в производственной промышленности, вы можете автоматизировать повторяющийся процесс сборки (в нашем случае сборку приложений) с помощью автоматизированных задач, позволяя разработчикам сосредоточиться на процессах проектирования и разработки. 25 | * Какие есть преимущества использования CI/CD в мобильной разработке? 26 | 1. `Быстрые циклы выпуска релизов` 27 | * Благодаря CI/CD разработчики могут вносить даже самые незначительные изменения в код, поскольку они будут собираться и доставляться автоматически в фоновом режиме. Этот автоматизированный процесс гарантирует, что всегда есть альфа или бета релиз, готовый к тестированию с актуальным кодом. 28 | 2. `"Непрерывная интеграция(CI)" позволяет получать быстрый фидбек` 29 | * При более быстром цикле выпуска релизов с меньшим количеством изменений становится проще определить источник ошибки. Это особенно важно для больших команд, где конфликты кода могут вызвать значительные проблемы. 30 | 3. `Повышение дисциплины написания кода с помощью сборки на основе запросов и автоматизированных тестов` 31 | * С коммитом “pull request-а” сборка происходит до слияния кода в главную ветку и после каждого слияния проводятся автоматические unit-тесты и проверка кода; сам код тестируется более тщательно, прежде чем он становится частью релиза. 32 | 4. `"Непрерывное развертывание(CD)" позволяет предупреждать ошибки и тщательнее тестировать` 33 | * Благодаря тестированию каждого отдельного изменения с помощью нескольких этапов процесса тестирования, проблемы в коде могут быть выявлены быстрее. 34 | 5. `Упрощение сложностей, связанных с доставкой приложений` 35 | * Каждая дисциплина разработки имеет свой набор сложностей, и мобильные приложения не являются исключением. В Android существуют совершенно независимые и различные процессы создания, подписания, распространения и установки приложений. CI/CD помогает автоматизировать этот процесс. 36 | 37 | ### Описание CI/CD 38 | 39 | * Эта диаграмма описывает процесс, который мы используем 40 | 41 | ![flow](./android-ci-cd-CI-CD-flow.drawio.svg) 42 | 43 | * Описание этапов 44 | 45 | ``` 46 | - build base image - Этап сборки базового образа, который используется для сборки приложения. 47 | - tests and lints - Этап для прогона тестов и линтов. 48 | - build and deploy to firebase - Этап сборки и загрузки приложения в Firebase. 49 | - build and deploy to google play - Этап сборки и загрузки приложения в Google Play. 50 | ``` 51 | 52 | * Стоит пояснить, для чего используются несколько билдов. 53 | 54 | Условия и положения: 55 | * Приложения в формате `apk` не могут быть загружены в Google Play 56 | * Приложения в формате `aab` могут быть загружены в Firebase и Google Play 57 | 58 | Поэтому нам нужно создать несколько билдов. 59 | 60 | * Для удобства тестирования, на этапе `Merge Request` мы даем возможность собрать приложение по запросу и отправить его в `Firebase`. 61 | * Это удобно для проверки приложения без слияния кода в основную ветку. 62 | * Приложение в формате `apk` загружается в Firebase. 63 | 64 | ### Особенности 65 | 66 | * GitLab: 67 | * У нас есть ручной этап по загрузке приложения в Google Play. 68 | * У нас есть ручной этап по созданию и загрузке приложения в staging `Firebase`; этот шаг доступен в `Merge Request`. 69 | * GitHub: 70 | * Мы используем [trstringer/manual-approval](https://trstringer.com/github-actions-manual-approval/) action, который помогает создать ручной шаг approve(одобрения) при загрузке в Google Play. 71 | * Мы используем ручной шаг - `workflow_dispatcher` для сборки и загрузки приложения из любой ветки. 72 | * Плагин Fastlane для создания значка. 73 | * Этот плагин поможет добавить значок к иконке вашего приложения для Android. 74 | * Более подробная информация [здесь](https://docs.fastlane.tools/actions/badge/) 75 | * Вы всегда можете настроить его для своего проекта, вот примеры того, как это используем мы 76 | 77 | ![staging](./badge_staging.png) ![prod](./badge_prod.png) 78 | 79 | ### Инструменты и сервисы 80 | 81 | * [Fastlane](https://fastlane.tools/) - это инструмент для разработчиков IOS и Android, позволяющий автоматизировать такие рутинные задачи, как создание скриншотов, работа с профилями инициализации, сборка и загрузка приложения. 82 | * [GitLab-ci](https://docs.gitlab.com/ee/ci/) или [GitHub Actions](https://docs.github.com/en/actions) - Системы CI/CD используются для построения логики пайплайна и выполнения команд Fastlane. 83 | * [Docker](https://www.docker.com/) - Docker используется в качестве среды сборки для приложения. 84 | * [CGP](https://cloud.google.com/) 85 | * [Firebase](https://firebase.google.com/docs/app-distribution) - Тестовая среда для приложения. 86 | * [Google Play](https://play.google.com/console/about/) - Продуктовая среда для приложения. 87 | 88 | ### Описание основных компонентов 89 | 90 | ![main](./android-ci-cd-tools.drawio.svg) 91 | 92 | ### Структура репозитория 93 | 94 | ```commandline 95 | . 96 | ├── app - Папка, содержащая пример приложения 97 | │ ├── build.gradle - Файл для конфигурации Android проекта 98 | │ └── src 99 | ├── build.gradle 100 | ├── Dockerfile - Dockerfile для базового образа, который используется на этапе сборки 101 | ├── docs - Папка для документации 102 | ├── fastlane - Папка с конфигурацией Fastlane 103 | │ ├── Appfile - Файл для основной конфигурации Fastlane 104 | │ ├── Fastfile - Файл для конфигурации команд Fastlane 105 | │ └── Pluginfile - Файл для конфигурации дополнительных плагинов или зависимостей Fastlane 106 | ├── Gemfile 107 | ├── gradle - Папка для сборки Gradle 108 | ├── gradle.properties - Файл для конфигурации Gradle 109 | ├── gradlew 110 | ├── gradlew.bat 111 | ├── ic_launcher-web.png 112 | ├── libs 113 | ├── proguard-project.txt 114 | ├── project.properties 115 | ├── README.md 116 | └── settings.gradle - Файл для настроек Gradle 117 | ``` 118 | 119 | ### Для начала: 120 | 1. [Создайте аккаунт в Google Cloud Platform](https://cloud.google.com/) 121 | 2. [Создайте проект Google](https://cloud.google.com/resource-manager/docs/creating-managing-projects) 122 | 3. [Создайте проект Firebase и активируйте "App Distribution"](https://cloud.google.com/firestore/docs/client/get-firebase) 123 | 4. [Создайте аккаунт разработчика Google Play](https://play.google.com/console/about/) 124 | 125 | #### Подготовка ключей и переменных окружения 126 | 1. Json-файл с конфигурацией для Firebase 127 | * Вы должны добавить json-файл с настройками проекта Firebase, закодированными в base64, в переменную окружения. 128 | > https://firebase.google.com/docs/android/setup - Этап 3 129 | ```bash 130 | base64 google-services.json > firebase_setting 131 | ``` 132 | 133 | 2. Сервис аккаунт с доступом к Firebase 134 | * Создайте сервис аккаунт для загрузки приложения на Firebase 135 | > Choose your Firebase account --> Project Overview --> Project setting --> Service Account --> create service account 136 | * Добавьте ключ сервис аккаунта(SA), закодированный в base64, в переменную окружения. 137 | ```bash 138 | base64 sa.json > key_firebase 139 | ``` 140 | 141 | 3. Сервис аккаунт с доступом к Google Play 142 | * Создайте сервис аккаунт для загрузки приложения в [Google Play](./README_GOOGLE_PLAY.md) 143 | * Добавьте ключ сервис аккаунта(SA), закодированный в base64, в переменную окружения 144 | ```bash 145 | base64 google_play.json > google_play 146 | ``` 147 | 148 | 4. Хранилище ключей для подписи приложения 149 | * Чтобы зарегистрировать приложение, необходим ключ, который можно сгенерировать с помощью команды. 150 | ```bash 151 | keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 152 | ``` 153 | * Добавьте хранилище ключей, закодированное в base64, в переменную окружения. 154 | ```bash 155 | base64 my-release-key.keystore > keystore 156 | ``` 157 | 158 | ##### GitLab CI/CD 159 | 160 | * Мы используем окружения `Environments` в нашем пайплайне, чтобы разделить наши переменные по окружениям; перед началом работы создайте 3 окружения в `gitlab-ci-cd`: 161 | 162 | ``` 163 | GitLab --> Deployments --> Environment --> New Environment 164 | ``` 165 | 166 | * Нам необходимо создать три окружения: 167 | * staging 168 | * prod 169 | * prod-gp 170 | 171 | ##### GitHub Actions 172 | 173 | * Мы можем использовать окружения в GitHub Actions, но этот функционал доступен только в публичных репозиториях или в корпоративных подписках. 174 | * В этом бойлерплейте мы не используем окружения в GitHub Actions. 175 | 176 | ##### Подготовьте переменные окружения 177 | 1. Скопируйте содержимое этого файла `firebase_setting`: 178 | ``` 179 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 180 | ``` 181 | или 182 | ``` 183 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 184 | ``` 185 | 186 | > В поле key вставьте `GOOGLE_SERVICES_JSON`, в поле value вставьте ваш `google-services.json`, закодированный в base64. 187 | 188 | 2. Скопируйте содержимое этого файла `key_firebase`: 189 | ``` 190 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 191 | ``` 192 | или 193 | ``` 194 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 195 | ``` 196 | 197 | > В поле key вставьте `SA_JSON_KEY`, в поле value вставьте ваш `sa.key`, закодированный в base64. 198 | 199 | 3. Скопируйте содержимое этого файла `google_play`: 200 | ``` 201 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 202 | ``` 203 | или 204 | ``` 205 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 206 | ``` 207 | > В поле key вставьте `SA_JSON_GP_KEY`, в поле value вставьте ваш `google_play.json`, закодированный в base64. 208 | 209 | 4. Скопируйте содержимое этого файла `keystore`: 210 | 211 | ``` 212 | GitLab --> Settings --> CI/CD --> Variables --> Add variable 213 | ``` 214 | или 215 | ``` 216 | GitHub --> Settings --> Secrets --> Actions --> New repository secret 217 | ``` 218 | > В поле key вставьте `KEYSTORE`, в поле value вставьте ваш `my-release-key.keystore`, закодированный в base64. 219 | 220 | ##### Переменные окружения 221 | 222 | | Название | Окружение | Описание | 223 | |-----------------------------|:--------------------:|-----------------------------------------------------------------------------------------------------------------------------------------------:| 224 | | KEYSTORE | Все | Кодировка в base64 для подписи хранилища ключей (base64) | 225 | | KEYSTORE_PW | Все | Пароль для подписи хранилища ключей | 226 | | ALIAS | Все | Alias хранилища ключей | 227 | | ALIAS_PW | Все | Пароль для Alias-а хранилища ключей | 228 | | SA_JSON_KEY | STAGING/PROD | Ключ учетной записи для Firebase (base64) | 229 | | SA_JSON_GP_KEY | PROD-GP | Ключ сервис аккаунта для Google Play Console (base64) | 230 | | GOOGLE_SERVICES_JSON | Все | Основной файл конфигурации для Firebase | 231 | | APP_VERSION_NAME | STAGING/PROD/PROD-GP | Версия приложения | 232 | | FIREBASE_APP_ID | STAGING/PROD | Идентификатор приложения в Firebase | 233 | | BUILD_TASK | STAGING/PROD/PROD-GP | Имя задачи в gradle (assemble, bundle, test) | 234 | | BUILD_TYPE | STAGING/PROD/PROD-GP | Тип сборки (assemble, release) | 235 | | SLACK_WEBHOOK_URL | Все | Вебхук Slack | 236 | | FIREBASE_TESTER_GROUP_NAME | STAGING/PROD | Название группы тестировщиков в Firebase | 237 | | APPROVERS | Все | Список одобряющих для релиза Google Play, используется только в GitHub Actions | 238 | | CI_PIPELINE_ID | Все | ID пайплайн, используемый для `versionCode`, по умолчанию указывается в GitLab, в GitHub Actions используется github.run_number | 239 | | CI_COMMIT_BEFORE_SHA | Все | Предыдущий коммит, используется для changelog-а сборки, по умолчанию объявляется в GitLab, в GitHub Actions используется github.event.before | 240 | | FIREBASE_ARTIFACT_TYPE | STAGING/PROD | Тип артефакта для загрузки в Firebase | 241 | | PROJECT_DIR | Все | Если проект находится не в основном каталоге, вы можете указать путь к каталогу проекта через переменную `PROJECT_DIR` в Fastfile. | 242 | | APP_PACKAGE_NAME | Все | Имя приложения Android по умолчанию, например, мы используем `com.boiler.android.hello` | 243 | | CI_ENVIRONMENT_NAME | STAGING/PROD | Используется в значке Fastlane, для отображения окружения в значке | 244 | 245 | * Когда вы завершите всю эту подготовку, вы можете приступить к сборке и загрузке приложения в Firebase 246 | 247 | ### Дополнительная конфигурация 248 | 249 | #### Плагины конфигурации для Fastlane 250 | 251 | * У нас есть `Pluginfile` в этом файле мы можем настроить плагины для Fastlane, по умолчанию мы используем [fastlane-plugin-firebase_app_distribution](https://github.com/fastlane/fastlane-plugin-firebase_app_distribution) и [fastlane-plugin-badge](https://github.com/HazAT/fastlane-plugin-badge) 252 | -------------------------------------------------------------------------------- /docs/android-ci-cd-CI-CD-flow.drawio.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
build type
build t...
feature/branch
feature/branch
merge request
merge request
lints and tests
lints and tests
 build and deploy
to firebase
APK
build and deploy...
manual
manual
automatic
automatic
lints and tests
lints and tests
 build and deploy
to firebase
APK

build and deploy...
 build and deploy
to firebase
AAB
build and deploy...
deploy
 to google play
AAB
deploy...
main
main
automatic
automatic
automatic
automatic
automatic
automatic
manual
manual
staging
staging
stages
stages
environment
environment
job type
job ty...
staging
staging
production
producti...
debug
debug
release
release
release
release
flow
flow
pipeline artifacts
pipeline artifa...
aab
aab
aab
aab
Text is not SVG - cannot display
-------------------------------------------------------------------------------- /docs/android-ci-cd-tools.drawio.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
build_android_app
build_android_app
gitlab ci/cd
gitlab ci/cd
github actions
github actions
OR
OR
Pipeline logic,
fastlane action executor
Pipeline logic,...
Firebase
Firebase
Fastlane actions
Fastlane actions
Services
Services
Google play
Google play
firebase_app_distribution
firebase_app_distribution
upload_to_play_store
upload_to_play_store
Text is not SVG - cannot display
-------------------------------------------------------------------------------- /docs/android-ci-cd.drawio: -------------------------------------------------------------------------------- 1 | 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 -------------------------------------------------------------------------------- /docs/badge_prod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/badge_prod.png -------------------------------------------------------------------------------- /docs/badge_staging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/badge_staging.png -------------------------------------------------------------------------------- /docs/gcp1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp1.jpeg -------------------------------------------------------------------------------- /docs/gcp2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp2.jpeg -------------------------------------------------------------------------------- /docs/gcp3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp3.jpeg -------------------------------------------------------------------------------- /docs/gcp4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp4.jpeg -------------------------------------------------------------------------------- /docs/gcp5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp5.jpeg -------------------------------------------------------------------------------- /docs/gcp6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp6.jpeg -------------------------------------------------------------------------------- /docs/gcp7.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gcp7.jpeg -------------------------------------------------------------------------------- /docs/googleplay1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/googleplay1.jpeg -------------------------------------------------------------------------------- /docs/googleplay2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/googleplay2.jpeg -------------------------------------------------------------------------------- /docs/googleplay3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/googleplay3.jpeg -------------------------------------------------------------------------------- /docs/gp1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp1.jpeg -------------------------------------------------------------------------------- /docs/gp2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp2.jpeg -------------------------------------------------------------------------------- /docs/gp3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp3.jpeg -------------------------------------------------------------------------------- /docs/gp4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp4.jpeg -------------------------------------------------------------------------------- /docs/gp5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp5.jpeg -------------------------------------------------------------------------------- /docs/gp6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/docs/gp6.jpeg -------------------------------------------------------------------------------- /fastlane/Appfile: -------------------------------------------------------------------------------- 1 | json_key_file("key_firebase.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one 2 | package_name(ENV["APP_PACKAGE_NAME"]) 3 | -------------------------------------------------------------------------------- /fastlane/Fastfile: -------------------------------------------------------------------------------- 1 | default_platform(:android) 2 | platform :android do 3 | before_all do |lane, options| 4 | ENV["APP_FLAVOR"] = options[:flavor] 5 | ENV["PROJECT_DIR"] = "./" 6 | puts "Flavor environment #{options[:flavor]}" 7 | end 8 | def on_error(exception) 9 | slack( 10 | message: "Something goes wrong!", 11 | success: false, 12 | slack_url: ENV["SLACK_WEBHOOK_URL"], 13 | attachment_properties: { 14 | fields: [ 15 | { 16 | title: "Error message", 17 | value: exception 18 | } 19 | ] 20 | } 21 | ) 22 | end 23 | def success(line) 24 | slack( 25 | message: "App successfully released #{line}", 26 | success: true, 27 | slack_url: ENV["SLACK_WEBHOOK_URL"] 28 | ) 29 | end 30 | 31 | desc "Build android" 32 | lane :build_release do |options| 33 | build_android_app( 34 | task: ENV["BUILD_TASK"], 35 | build_type: ENV["BUILD_TYPE"], 36 | flavor: ENV["APP_FLAVOR"], 37 | project_dir: "#{ENV["PROJECT_DIR"]}", 38 | properties: { 39 | "android.injected.signing.store.file" => "/tmp/my-release-key.keystore", 40 | "android.injected.signing.store.password" => "#{ENV["KEYSTORE_PW"]}", 41 | "android.injected.signing.key.alias" => "#{ENV["ALIAS"]}", 42 | "android.injected.signing.key.password" => "#{ENV["ALIAS_PW"]}", 43 | "versionCode" => ENV["CI_PIPELINE_ID"], 44 | } 45 | ) 46 | end 47 | 48 | desc "lint" 49 | lane :lint do 50 | gradle(task: "lintDebug") 51 | end 52 | 53 | desc "unit test" 54 | lane :unit_test do 55 | gradle(task: "testDebugUnitTest") 56 | end 57 | 58 | desc "Submit a new build to Firebase App Distribution" 59 | lane :firebase_distribution do |options| 60 | begin 61 | add_badge_to_icon(environment: ENV["CI_ENVIRONMENT_NAME"]) 62 | build_release() 63 | 64 | changes = changelog_from_git_commits( 65 | #commits_count: 10, 66 | between: [ENV["CI_COMMIT_BEFORE_SHA"], "HEAD"], 67 | pretty: "- (%ae) %s", 68 | date_format: "short", 69 | match_lightweight_tag: false, 70 | merge_commit_filtering: "exclude_merges" 71 | ) 72 | 73 | puts "Uploading new version(#{ENV["CI_PIPELINE_ID"]}) to Firebase" 74 | 75 | firebase_app_distribution( 76 | app: ENV["FIREBASE_APP_ID"], 77 | groups: ENV["FIREBASE_TESTER_GROUP_NAME"], 78 | android_artifact_type: ENV["FIREBASE_ARTIFACT_TYPE"] = "APK", 79 | service_credentials_file: "./key_firebase.json", 80 | release_notes: changes, 81 | debug: true, 82 | ) 83 | success("Firebase") 84 | rescue => exception 85 | on_error(exception) 86 | UI.user_error!(exception) 87 | end 88 | end 89 | 90 | desc "Deploy a new version to the Google Play" 91 | lane :google_beta do |options| 92 | begin 93 | track = 'internal' 94 | build_release() 95 | 96 | upload_to_play_store( 97 | track: track, 98 | release_status: 'draft', 99 | version_code: ENV["CI_PIPELINE_ID"], 100 | json_key: "/tmp/key_gp.json", 101 | track_promote_to: track, 102 | skip_upload_metadata: true, 103 | skip_upload_changelogs: true, 104 | skip_upload_images: true, 105 | skip_upload_screenshots: true 106 | ) 107 | success("Google Play") 108 | rescue => exception 109 | on_error(exception) 110 | UI.user_error!(exception) 111 | end 112 | end 113 | 114 | end 115 | 116 | private_lane :add_badge_to_icon do |options| 117 | if options[:environment] == "staging" 118 | add_badge( 119 | glob: "/app/src/main/res/mipmap-*/ic_launcher*.png", 120 | shield: "STAGING-#{ENV["CI_PIPELINE_ID"]}-green", 121 | no_badge: true, 122 | dark: true, 123 | shield_scale: "0.55", 124 | shield_gravity: "Center", 125 | ) 126 | elsif options[:environment] =~ /prod/ 127 | add_badge( 128 | glob: "/app/src/main/res/mipmap-*/ic_launcher*.png", 129 | shield: "PROD-#{ENV["CI_PIPELINE_ID"]}-blue", 130 | no_badge: true, 131 | dark: true, 132 | shield_scale: "0.55", 133 | shield_gravity: "Center", 134 | ) 135 | end 136 | end 137 | -------------------------------------------------------------------------------- /fastlane/Pluginfile: -------------------------------------------------------------------------------- 1 | # Autogenerated by fastlane 2 | # 3 | # Ensure this file is checked in to source control! 4 | gem 'fastlane-plugin-firebase_app_distribution' 5 | gem 'fastlane-plugin-badge' 6 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | android.useAndroidX=true 2 | android.enableJetifier=true 3 | org.gradle.caching=true 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/android-ci-cd/3c5cd425cc4230ca1efe6454c43fcfe9812659eb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Tue May 09 20:47:20 CDT 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------