From abe44e4e6d05b49d0c62abdca376d326d47f37b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 09:50:06 +0300 Subject: [PATCH 1/9] issue-635: Added build_apk lane for fastlane --- .github/workflows/latest.yml | 158 +++++++++++++++++++++++++++++++++++ android/fastlane/Fastfile | 16 +++- 2 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/latest.yml diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml new file mode 100644 index 00000000..d1522687 --- /dev/null +++ b/.github/workflows/latest.yml @@ -0,0 +1,158 @@ +# This is workflow to run tests, build Android app and supply it to Google Play Store. Version 1. + +name: The latest build from main-branch + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + # push: + # branches: [ "main" ] + # pull_request: + # branches: [ "main" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +# Build job needs test ! +jobs: + + # Run React Native Eslint and Jest tests + test: + if: ${{ false }} + name: Test + # Setup Ubuntu version + runs-on: ubuntu-latest + strategy: + # Node version matrix + matrix: + node-version: [20.11.1] + # Steps + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + # Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + # Install dependencies + - name: Install dependencies + run: yarn install + # Get defaultConfig + - name: Get defaultConfig + env: + defaultConfig: ${{ secrets.DEFAULTCONFIG }} + shell: bash + run: | + touch defaultConfig.ts + echo "$defaultConfig" >> defaultConfig.ts + + # Run lint -tests + - name: Run Eslint tests + if: ${{ false }} + run: yarn lint --fix + # Run Jest -tests + - name: Run Jest tests + if: ${{ false }} + run: yarn test + +# Decode, Build and sign Android application + build: + # needs: test + name: Android-build + # Set Ubuntu version + runs-on: ubuntu-latest + # Node version matrix + strategy: + matrix: + node-version: [20.11.1] + # Steps + steps: + - name: Checkout to git repository + uses: actions/checkout@v4 + # Setup Node + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - name: Install dependencies + run: | + yarn install + + # Get defaultConfig + - name: Get defaultConfig + env: + defaultConfig: ${{ secrets.DEFAULTCONFIG }} + shell: bash + run: | + touch defaultConfig.ts + echo "$defaultConfig" >> defaultConfig.ts + + # Set up Java 17 + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' # You can use 'adopt', 'zulu', or another distribution if needed + + # Install Ruby + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3.0' + + # Update bundler + - name: Update bundler + run: bundle update --bundler + working-directory: android + + # Bundle install + - name: Bundle install + run: gem install bundler && bundle install + working-directory: android + + # Decode upload keystore and Play Store json -key + - name: Decode Service Account Key JSON File + uses: timheuer/base64-to-file@v1 + id: service_account_json_file + with: + fileName: "serviceAccount.json" + encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }} + - name: Decode Keystore File + uses: timheuer/base64-to-file@v1 + id: android_keystore + with: + fileName: "android_keystore.keystore" + encodedString: ${{ secrets.KEYSTORE }} + + # Build and sign + - name: Build + env: + KEYSTORE: ${{ steps.android_keystore.outputs.filePath }} + SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} + SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + ANDROID_PACKAGE_NAME: ${{ secrets.ANDROID_PACKAGE_NAME }} + GPLAY_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }} + # SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }} + run: | + echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" > .env + chmod +x ./gradlew + bundle exec fastlane android build_apk + working-directory: android + + - name: Rename APK + run: + mv "./app/build/outputs/apk/release/app-release.apk" "./app/build/outputs/apk/release/latest.apk" + + # Upload artifact + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: latest.apk + path: | + ${{ github.workspace }}/android/app/build/outputs/bundle/release/* + retention-days: 7 + overwrite: true + diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 28549ed4..0944c8da 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -56,6 +56,20 @@ platform :android do push_to_git_remote if should_push end end + + # Build APK only + desc "Android build APK" + lane :build_apk do + # Gradle clean + gradle(task: 'clean', project_dir: './') + # Gradle sign aab -file + gradle(task: 'assemble', build_type: "Release", project_dir: './',properties: { + "android.injected.signing.store.file" => ENV["KEYSTORE"], + "android.injected.signing.store.password" => ENV["SIGNING_STORE_PASSWORD"], + "android.injected.signing.key.alias" => ENV["SIGNING_KEY_ALIAS"], + "android.injected.signing.key.password" => ENV["SIGNING_KEY_PASSWORD"] + }) + end # Sign, build and deploy to Google Play Store desc "Sign, build, and deploy to Google Play Store" @@ -91,7 +105,7 @@ platform :android do "android.injected.signing.key.password" => ENV["SIGNING_KEY_PASSWORD"] }) end - + # Deploy to Google Play Store desc "Deploy a new version to the Google Play" lane :deploy do From f1fff776e3299a4c00efe49b1633faa0a7a07c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 10:19:12 +0300 Subject: [PATCH 2/9] issue-635: Modified latest.yml to allow testing in feature branch --- .github/workflows/latest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index d1522687..2ec0dc8d 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -9,6 +9,7 @@ on: # branches: [ "main" ] # pull_request: # branches: [ "main" ] + pull_request: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 7e0273bf5eea5c5b0483530d10c2b39f0aff2dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 10:37:20 +0300 Subject: [PATCH 3/9] issue-635: Removed unnecessary steps and made some fixes to latest.yml --- .github/workflows/latest.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 2ec0dc8d..b66b769d 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -113,13 +113,7 @@ jobs: run: gem install bundler && bundle install working-directory: android - # Decode upload keystore and Play Store json -key - - name: Decode Service Account Key JSON File - uses: timheuer/base64-to-file@v1 - id: service_account_json_file - with: - fileName: "serviceAccount.json" - encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }} + # Decode upload keystore - name: Decode Keystore File uses: timheuer/base64-to-file@v1 id: android_keystore @@ -134,8 +128,6 @@ jobs: SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} - ANDROID_PACKAGE_NAME: ${{ secrets.ANDROID_PACKAGE_NAME }} - GPLAY_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }} # SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }} run: | echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" > .env From 832e81d3307e70de21445c0641fd52369d5563e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 10:59:47 +0300 Subject: [PATCH 4/9] issue-635: Added working directory to mv phase --- .github/workflows/latest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index b66b769d..0fa1df43 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -1,6 +1,6 @@ # This is workflow to run tests, build Android app and supply it to Google Play Store. Version 1. -name: The latest build from main-branch +name: The latest Android build from main-branch # Controls when the workflow will run on: @@ -138,6 +138,7 @@ jobs: - name: Rename APK run: mv "./app/build/outputs/apk/release/app-release.apk" "./app/build/outputs/apk/release/latest.apk" + working-directory: android # Upload artifact - name: Upload build artifacts From b2cee4fa4d4daee212f9060d3fd23c63d00fffb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 11:41:11 +0300 Subject: [PATCH 5/9] issue-635: Fixed artifact upload path --- .github/workflows/latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 0fa1df43..edaf9219 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -146,7 +146,7 @@ jobs: with: name: latest.apk path: | - ${{ github.workspace }}/android/app/build/outputs/bundle/release/* + ${{ github.workspace }}/android/app/build/outputs/apk/release/ retention-days: 7 overwrite: true From 685907c84f1bafc0b90982e4648fab271f00c8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 12:11:09 +0300 Subject: [PATCH 6/9] issue-635: Include only apk to uploaded zip-file --- .github/workflows/latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index edaf9219..010227ff 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -146,7 +146,7 @@ jobs: with: name: latest.apk path: | - ${{ github.workspace }}/android/app/build/outputs/apk/release/ + ${{ github.workspace }}/android/app/build/outputs/apk/release/latest.apk retention-days: 7 overwrite: true From f5aad9bcba7c13dcec4f2dbe61f77009cb835468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 13:27:45 +0300 Subject: [PATCH 7/9] issue-635: Modified latest.yml to trigger on push to main branch --- .github/workflows/latest.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 010227ff..54294f70 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -5,11 +5,8 @@ name: The latest Android build from main-branch # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the "main" branch - # push: - # branches: [ "main" ] - # pull_request: - # branches: [ "main" ] - pull_request: + push: + branches: [ "main" ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -149,4 +146,3 @@ jobs: ${{ github.workspace }}/android/app/build/outputs/apk/release/latest.apk retention-days: 7 overwrite: true - From 0edb1f03f1b062f1da92933001cf362b0263bb96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 13:38:32 +0300 Subject: [PATCH 8/9] issue-635: Improved latest.yml description comment --- .github/workflows/latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 54294f70..bba2dec9 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -1,4 +1,4 @@ -# This is workflow to run tests, build Android app and supply it to Google Play Store. Version 1. +# This is workflow to build Android app for testing name: The latest Android build from main-branch From f6ba97ffe4ac4ec3e477064f5c563a85b863e3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Ker=C3=A4nen?= Date: Tue, 22 Oct 2024 13:50:26 +0300 Subject: [PATCH 9/9] issue-635: Updated fastlane Readme --- android/fastlane/README.md | 67 +++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/android/fastlane/README.md b/android/fastlane/README.md index 1091d2a1..cd8daf13 100644 --- a/android/fastlane/README.md +++ b/android/fastlane/README.md @@ -1,29 +1,72 @@ fastlane documentation -================ +---- + # Installation Make sure you have the latest version of the Xcode command line tools installed: -``` +```sh xcode-select --install ``` -Install _fastlane_ using -``` -[sudo] gem install fastlane -NV -``` -or alternatively using `brew install fastlane` +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) # Available Actions + ## Android -### android increment_version -``` -fastlane android increment_version + +### android increment_android_version + +```sh +[bundle exec] fastlane android increment_android_version ``` + Increment build and version number and push to repository - Build number = version code, version number = version name +### android build_apk + +```sh +[bundle exec] fastlane android build_apk +``` + +Android build APK + +### android build_sign_and_deploy + +```sh +[bundle exec] fastlane android build_sign_and_deploy +``` + +Sign, build, and deploy to Google Play Store + +### android get_version_code_and_version_name + +```sh +[bundle exec] fastlane android get_version_code_and_version_name +``` + +Get version code and version name + +### android build_and_sign + +```sh +[bundle exec] fastlane android build_and_sign +``` + +Release for the Android beta + +### android deploy + +```sh +[bundle exec] fastlane android deploy +``` + +Deploy a new version to the Google Play + ---- This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. -More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). -The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).