Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build playstore #2333

Merged
merged 21 commits into from
Dec 13, 2024
Merged

Android build playstore #2333

merged 21 commits into from
Dec 13, 2024

Conversation

Mozart299
Copy link
Contributor

@Mozart299 Mozart299 commented Dec 13, 2024

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Summary by CodeRabbit

  • New Features

    • Enhanced deployment process for Android applications, including automated changelog management and new deployment lanes for Play Store and Firebase App Distribution.
    • New Gemfile and Pluginfile for managing dependencies and plugins.
    • Support for multiple product flavors in the build configuration.
  • Bug Fixes

    • Improved handling of API keys and signing configurations to enhance security.
  • Documentation

    • Added README file for Fastlane setup with installation instructions and usage details.
  • Chores

    • Updated .gitignore to manage sensitive files and prevent tracking of unnecessary metadata.
    • Updated dependencies in pubspec.yaml.

Copy link

coderabbitai bot commented Dec 13, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications to the Android deployment workflow and project configuration. Key updates include changes to the deployment workflow file for the Play Store, enhancements to the .gitignore file, the introduction of a new Gemfile, and updates to the build.gradle file for API key management and product flavors. Additionally, new Fastlane configurations, including lanes for deployment and a README for guidance, have been created. These changes collectively improve the structure and management of the Android project and its deployment processes.

Changes

File Path Change Summary
.github/workflows/deploy-android-to-play-store.yml Updated working directory, Ruby version, and added steps for changelog management during deployment.
mobile-v3/.gitignore Added entries to ignore sensitive Android configuration files and Fastlane metadata directories.
mobile-v3/android/Gemfile Introduced a new Gemfile specifying the Fastlane gem and a mechanism for plugins.
mobile-v3/android/app/build.gradle Modified to handle API keys, defined product flavors, and updated signing configurations.
mobile-v3/android/fastlane/Appfile Added JSON key file path and application package name for Play Store deployment.
mobile-v3/android/fastlane/Fastfile Introduced deployment lanes for Play Store and Firebase App Distribution.
mobile-v3/android/fastlane/Pluginfile Added Firebase App Distribution plugin for enhanced deployment capabilities.
mobile-v3/android/fastlane/README.md Created a README file with installation instructions and usage for Fastlane actions.
mobile-v3/android/fastlane/report.xml Introduced a new XML file for standardized test result reporting.
mobile-v3/pubspec.yaml Updated dependency version and modified asset declarations for environment configuration.

Possibly related PRs

  • [Mobile] Update outdated Package to fix build #2174: The changes in this PR involve updating the pubspec.yaml file, which is related to dependency management in the mobile project, similar to the modifications in the main PR that also involve configuration changes for the Android deployment process.

Suggested labels

ready for review

Suggested reviewers

  • sserurich
  • Psalmz777
  • Baalmart

🌟 In the world of code, where changes abound,
New paths are forged, and solutions are found.
With Fastlane in hand, our apps take flight,
To the Play Store they go, shining so bright!
Changelogs and secrets now neatly in place,
Cheers to the updates, let's quicken the pace! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (7)
mobile-v3/android/app/build.gradle (2)

Line range hint 3-3: Consider specifying the Gradle plugin versions

While not mandatory, specifying plugin versions can help maintain build consistency and avoid unexpected issues due to plugin updates.

For example:

- id "com.android.application"
+ id "com.android.application" version "8.1.0"

Ensure to use the appropriate versions compatible with your project.


97-110: Review the flavor dimension configuration

Using the same name "airqo" for both the flavor dimension and one of the flavors might cause confusion. Consider renaming the flavor dimension to something more general, like "environment", to improve clarity.

Apply this diff to rename the flavor dimension:

- flavorDimensions "airqo"
+ flavorDimensions "environment"

- airqo {
-     dimension "airqo"
+ airqo {
+     dimension "environment"
mobile-v3/android/Gemfile (1)

3-3: Specify the version for the 'fastlane' gem

To ensure consistent builds and avoid potential issues with gem updates, it's advisable to specify a version for the fastlane gem.

Apply this diff to specify the version:

- gem "fastlane"
+ gem "fastlane", "~> 2.214.0"

Replace 2.214.0 with the desired version compatible with your project.

mobile-v3/android/fastlane/Fastfile (1)

18-26: Add validation for successful build before upload

The lane should verify that the build was successful before attempting to upload to Play Store.

 sh "flutter build appbundle --build-number #{_new_build_number} --flavor airqo"
+aab_path = "../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab"
+UI.user_error!("AAB file not found at #{aab_path}") unless File.exist?(aab_path)
 upload_to_play_store(
   release_status: "completed",
   json_key_data: ENV['MOBILE_ANDROID_PLAYSTORE_SA'],
   package_name:"com.airqo.app",
-  aab: "../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab",
+  aab: aab_path,
   skip_upload_metadata: true,
   skip_upload_images: true,
   skip_upload_screenshots: true
 )
🧰 Tools
🪛 rubocop (1.69.1)

[convention] 25-25: Avoid comma after the last parameter of a method call.

(Style/TrailingCommaInArguments)

.github/workflows/deploy-android-to-play-store.yml (1)

81-87: Improve changelog management logic

The current changelog management could be more robust:

  1. The hardcoded version in the default release notes
  2. No validation of the release notes content
 mkdir -p fastlane/metadata/android/en-US/changelogs
 touch fastlane/metadata/android/en-US/changelogs/default.txt

 if [ ! -f fastlane/release_notes.txt ]; then
-  echo "App release version 3.0.2" > fastlane/release_notes.txt
+  VERSION=$(grep 'version:' ../../pubspec.yaml | awk '{print $2}')
+  echo "App release version ${VERSION}" > fastlane/release_notes.txt
 fi

+# Validate release notes content
+if [ ! -s fastlane/release_notes.txt ]; then
+  echo "Error: Release notes file is empty"
+  exit 1
+fi
mobile-v3/pubspec.yaml (1)

Line range hint 19-19: Review version and build number strategy

The version number (3.0.2) follows semantic versioning, but the build number (+0) seems unusually low for a production Play Store release. Consider:

  1. Incrementing the build number based on your previous Play Store releases
  2. Documenting the versioning strategy in the project
mobile-v3/android/fastlane/README.md (1)

24-32: Enhance deployment documentation

The lane descriptions could be more detailed. Consider adding:

  1. Required environment variables
  2. Necessary credentials/keys
  3. Example usage with parameters
  4. Troubleshooting tips
-Deploy a new version to play store
+Deploy a new version to Play Store
+
+Required setup:
+- play-store-service-account.json in the fastlane directory
+- Properly configured version in build.gradle
+
+Example:
+```sh
+fastlane android play_store track:internal
+```

-Deploy to new version to Firebase App Distribution
+Deploy a new version to Firebase App Distribution
+
+Required setup:
+- Firebase CLI configuration
+- FIREBASE_APP_ID environment variable
+
+Example:
+```sh
+fastlane android app_distribution groups:"testers"
+```
🧰 Tools
🪛 Markdownlint (0.37.0)

26-26: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8847857 and 6db65ba.

⛔ Files ignored due to path filters (2)
  • mobile-v3/android/Gemfile.lock is excluded by !**/*.lock
  • mobile-v3/pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/workflows/deploy-android-to-play-store.yml (3 hunks)
  • mobile-v3/.gitignore (1 hunks)
  • mobile-v3/android/Gemfile (1 hunks)
  • mobile-v3/android/app/build.gradle (4 hunks)
  • mobile-v3/android/fastlane/Appfile (1 hunks)
  • mobile-v3/android/fastlane/Fastfile (1 hunks)
  • mobile-v3/android/fastlane/Pluginfile (1 hunks)
  • mobile-v3/android/fastlane/README.md (1 hunks)
  • mobile-v3/android/fastlane/report.xml (1 hunks)
  • mobile-v3/pubspec.yaml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • mobile-v3/android/fastlane/report.xml
🧰 Additional context used
🪛 rubocop (1.69.1)
mobile-v3/android/fastlane/Fastfile

[convention] 5-6: Extra empty line detected at block body beginning.

(Layout/EmptyLinesAroundBlockBody)


[convention] 25-25: Avoid comma after the last parameter of a method call.

(Style/TrailingCommaInArguments)


[convention] 40-40: Avoid comma after the last parameter of a method call.

(Style/TrailingCommaInArguments)

🪛 Markdownlint (0.37.0)
mobile-v3/android/fastlane/README.md

4-4: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)


14-14: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)


16-16: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)


18-18: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)


26-26: Expected: setext; Actual: atx
Heading style

(MD003, heading-style)

🔇 Additional comments (7)
mobile-v3/android/app/build.gradle (1)

112-119: Verify that all signing properties are available

In the signingConfigs.release block, the code assumes that all required properties are present in releaseKeystoreProperties. If prod-key.properties is missing or incomplete, this could lead to null values and runtime exceptions. Make sure to handle missing properties appropriately.

mobile-v3/android/fastlane/Pluginfile (1)

1-1: Addition of Firebase App Distribution plugin looks good

Including the fastlane-plugin-firebase_app_distribution gem enhances your app distribution workflow. This will streamline the process of distributing your app to testers.

mobile-v3/android/fastlane/Appfile (1)

1-2: Configuration settings are correctly implemented

The json_key_file and package_name are properly set, aligning with the deployment requirements for the Play Store.

.github/workflows/deploy-android-to-play-store.yml (2)

18-18: Validate working directory changes

The working directory has been updated from mobile to mobile-v3. Let's verify the directory structure.

Also applies to: 67-68


67-68: Verify Ruby version compatibility

The Ruby version has been updated to 3.1.0. Let's ensure all gems are compatible with this version.

✅ Verification successful

Ruby 3.1.0 is compatible with the current dependencies

The Gemfile.lock shows all dependencies are compatible with the Ruby platform being used. The key components:

  • fastlane (2.226.0) and its plugins are fully compatible with Ruby 3.1.0
  • All gem dependencies are using versions that support Ruby 3.1.0
  • The bundle is successfully locked with bundler 2.5.22, indicating successful dependency resolution

The setup appears stable and well-maintained with no version conflicts or compatibility issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any version constraints in Gemfile
cd mobile-v3/android
if [ -f Gemfile ]; then
  grep -A 5 "ruby '[0-9]" Gemfile
  grep "gem 'fastlane'" Gemfile
fi

Length of output: 118


Script:

#!/bin/bash
# Let's check if Gemfile exists in other directories
fd Gemfile

# Check for any fastlane related files
fd fastlane

# Look for ruby version specifications in any fastlane files
fd -t f -e rb | xargs grep -l "ruby.*version" 2>/dev/null || true

Length of output: 242


Script:

#!/bin/bash
# Let's check the content of the Gemfile in mobile-v3/android
cat mobile-v3/android/Gemfile

# Also check fastlane configuration
cat mobile-v3/android/fastlane/Fastfile 2>/dev/null || true

Length of output: 1764


Script:

#!/bin/bash
# Let's check the Gemfile.lock to see the actual dependencies and their versions
cat mobile-v3/android/Gemfile.lock

# Also check if there's a Pluginfile with additional dependencies
cat mobile-v3/android/fastlane/Pluginfile 2>/dev/null || true

Length of output: 6633

mobile-v3/pubspec.yaml (2)

92-93: Ensure proper environment file security

Good separation of development and production environments. However, please ensure:

  1. Both .env files are added to .gitignore
  2. A template file (.env.example) is provided for documentation
  3. CI/CD pipeline is configured to use the correct environment file
✅ Verification successful

Environment files are properly secured in .gitignore

The verification confirms that environment files are properly secured:

  • .env, .env.*, and *.env patterns are present in .gitignore
  • However, an .env.example template file is missing, which would be helpful for documentation

Consider adding an .env.example file with placeholder values to help other developers set up their environment.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if env files are properly gitignored
cat mobile-v3/.gitignore | grep -E "\.env\.|\.env$"

# Check for presence of example template
fd -t f ".env.example" mobile-v3/

Length of output: 105


50-50: Verify flutter_sticky_header upgrade compatibility

The upgrade from ^0.6.5 to ^0.7.0 is a major version change that might introduce breaking changes. Please ensure:

  1. All existing sticky header implementations have been tested
  2. Any breaking changes have been addressed
✅ Verification successful

Limited impact upgrade - only basic SliverStickyHeader usage found

The codebase only uses the basic SliverStickyHeader widget with simple header configuration in dashboard_page.dart. The upgrade from ^0.6.5 to ^0.7.0 should be safe as:

  • Only one file uses the package
  • Implementation uses basic sticky header functionality
  • No complex customizations or deprecated features detected
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all uses of flutter_sticky_header to identify potential impact
rg -l "flutter_sticky_header" --type dart

Length of output: 99


Script:

#!/bin/bash
# Check the actual usage of flutter_sticky_header in the dashboard page
rg "flutter_sticky_header" mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart -B 2 -A 2

Length of output: 322


Script:

#!/bin/bash
# Let's check how StickyHeader is actually used in the implementation
ast-grep --pattern 'StickyHeader' mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart

Length of output: 91


Script:

#!/bin/bash
# Let's try a different pattern to find StickyHeaderBuilder usage
ast-grep --pattern 'StickyHeaderBuilder' mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart

# Also search for any sticky header related content
rg "Sticky" mobile-v3/lib/src/app/dashboard/pages/dashboard_page.dart -B 2 -A 5

Length of output: 430

Comment on lines +47 to +50
def googleMapApiKeyDev = appProperties.getProperty('google.maps.key.dev')
if (googleMapApiKeyDev == null) {
throw new GradleException("Google Maps Key not found. Define google.maps.key_dev in the key.properties file.")
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the property key name in the exception message

There's an inconsistency between the property key you're accessing and the one mentioned in the exception message. The property key is 'google.maps.key.dev', but the exception message refers to 'google.maps.key_dev'. Ensure both use the same key name for clarity and correctness.

Apply this diff to correct the exception message:

- throw new GradleException("Google Maps Key not found. Define google.maps.key_dev in the key.properties file.")
+ throw new GradleException("Google Maps Key not found. Define google.maps.key.dev in the key.properties file.")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def googleMapApiKeyDev = appProperties.getProperty('google.maps.key.dev')
if (googleMapApiKeyDev == null) {
throw new GradleException("Google Maps Key not found. Define google.maps.key_dev in the key.properties file.")
}
def googleMapApiKeyDev = appProperties.getProperty('google.maps.key.dev')
if (googleMapApiKeyDev == null) {
throw new GradleException("Google Maps Key not found. Define google.maps.key.dev in the key.properties file.")
}

Comment on lines +65 to +66
releaseKeystoreProperties.load(new FileInputStream(releaseKeystorePropertiesFile))
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure proper resource management when loading properties

The FileInputStream used to load releaseKeystoreProperties isn't closed, which can lead to resource leaks. Consider using withInputStream to automatically manage the resource.

Apply this diff to use withInputStream:

- releaseKeystoreProperties.load(new FileInputStream(releaseKeystorePropertiesFile))
+ releaseKeystorePropertiesFile.withInputStream { stream ->
+     releaseKeystoreProperties.load(stream)
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
releaseKeystoreProperties.load(new FileInputStream(releaseKeystorePropertiesFile))
}
releaseKeystorePropertiesFile.withInputStream { stream ->
releaseKeystoreProperties.load(stream)
}
}

Comment on lines +74 to +76
/android/google-services.json
/android/play-store-service-account.json
/android/fastlane/metadata
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Additional sensitive files need to be ignored

Found an exposed Google Maps API key in iOS configuration and several configuration files that should be considered for gitignore:

  • Add /ios/Runner/AppDelegate.swift to gitignore as it contains an exposed API key
  • Consider adding the following configuration files:
    • /ios/Flutter/*.xcconfig
    • /android/app/src/main/res/xml/network_security_config.xml

While the current additions are good, these additional sensitive files should also be protected to prevent accidental commits of credentials or configuration.

🔗 Analysis chain

Good security practice! Properly ignoring sensitive configuration files.

The additions to .gitignore for google-services.json, play-store-service-account.json, and Fastlane metadata are essential for security. However, let's verify if we're catching all sensitive files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any potentially sensitive files that might have been committed
rg -l "AIza[0-9A-Za-z-_]{35}" # Search for Google API keys
rg -l "BEGIN PRIVATE KEY" # Search for private key files

Length of output: 95


Script:

#!/bin/bash
# Let's check the content of the file that might contain sensitive information
cat mobile/ios/Runner/AppDelegate.swift

# Also check for any other potential sensitive files in the mobile directories
fd -t f "(google-services|credentials|key|secret|auth|config)" mobile/

Length of output: 1479

Comment on lines +10 to +17
_google_play_track_version_codes = google_play_track_version_codes(
package_name: 'com.airqo.app',
track: 'production',
json_key_data: ENV['MOBILE_ANDROID_PLAYSTORE_SA']
)
_previous_build_number = _google_play_track_version_codes[0]
_new_build_number = _previous_build_number + 1
sh "flutter build appbundle --build-number #{_new_build_number} --flavor airqo"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding error handling for version code retrieval

The version code management logic could benefit from error handling in case the Play Store API call fails or returns unexpected results.

 _google_play_track_version_codes = google_play_track_version_codes(
   package_name: 'com.airqo.app',
   track: 'production',
   json_key_data: ENV['MOBILE_ANDROID_PLAYSTORE_SA']
 )
+if _google_play_track_version_codes.nil? || _google_play_track_version_codes.empty?
+  UI.user_error!("Failed to retrieve version codes from Play Store")
+end
 _previous_build_number = _google_play_track_version_codes[0]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_google_play_track_version_codes = google_play_track_version_codes(
package_name: 'com.airqo.app',
track: 'production',
json_key_data: ENV['MOBILE_ANDROID_PLAYSTORE_SA']
)
_previous_build_number = _google_play_track_version_codes[0]
_new_build_number = _previous_build_number + 1
sh "flutter build appbundle --build-number #{_new_build_number} --flavor airqo"
_google_play_track_version_codes = google_play_track_version_codes(
package_name: 'com.airqo.app',
track: 'production',
json_key_data: ENV['MOBILE_ANDROID_PLAYSTORE_SA']
)
if _google_play_track_version_codes.nil? || _google_play_track_version_codes.empty?
UI.user_error!("Failed to retrieve version codes from Play Store")
end
_previous_build_number = _google_play_track_version_codes[0]
_new_build_number = _previous_build_number + 1
sh "flutter build appbundle --build-number #{_new_build_number} --flavor airqo"

Comment on lines +33 to +41
sh "flutter build appbundle --flavor airqo"
firebase_app_distribution(
app: ENV['MOBILE_ANDROID_ID_FIREBASE'],
android_artifact_path:"../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab",
release_notes_file: "fastlane/release_notes.txt",
service_credentials_file: "fastlane/firebase-app-distribution.json",
android_artifact_type: "AAB",
groups: "airqo-team",
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for Firebase App Distribution

The app_distribution lane should include error handling for the build and upload process.

 sh "flutter build appbundle --flavor airqo" 
+unless $?.success?
+  UI.user_error!("Flutter build failed")
+end
+
+release_notes_path = "fastlane/release_notes.txt"
+service_credentials_path = "fastlane/firebase-app-distribution.json"
+
+UI.user_error!("Release notes not found") unless File.exist?(release_notes_path)
+UI.user_error!("Firebase credentials not found") unless File.exist?(service_credentials_path)
+
 firebase_app_distribution(
   app: ENV['MOBILE_ANDROID_ID_FIREBASE'],
   android_artifact_path:"../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab",
-  release_notes_file: "fastlane/release_notes.txt",
-  service_credentials_file: "fastlane/firebase-app-distribution.json",
+  release_notes_file: release_notes_path,
+  service_credentials_file: service_credentials_path,
   android_artifact_type: "AAB",
   groups: "airqo-team"
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sh "flutter build appbundle --flavor airqo"
firebase_app_distribution(
app: ENV['MOBILE_ANDROID_ID_FIREBASE'],
android_artifact_path:"../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab",
release_notes_file: "fastlane/release_notes.txt",
service_credentials_file: "fastlane/firebase-app-distribution.json",
android_artifact_type: "AAB",
groups: "airqo-team",
)
sh "flutter build appbundle --flavor airqo"
unless $?.success?
UI.user_error!("Flutter build failed")
end
release_notes_path = "fastlane/release_notes.txt"
service_credentials_path = "fastlane/firebase-app-distribution.json"
UI.user_error!("Release notes not found") unless File.exist?(release_notes_path)
UI.user_error!("Firebase credentials not found") unless File.exist?(service_credentials_path)
firebase_app_distribution(
app: ENV['MOBILE_ANDROID_ID_FIREBASE'],
android_artifact_path:"../build/app/outputs/bundle/airqoRelease/app-airqo-release.aab",
release_notes_file: release_notes_path,
service_credentials_file: service_credentials_path,
android_artifact_type: "AAB",
groups: "airqo-team"
)
🧰 Tools
🪛 rubocop (1.69.1)

[convention] 40-40: Avoid comma after the last parameter of a method call.

(Style/TrailingCommaInArguments)

Comment on lines +6 to +10
Make sure you have the latest version of the Xcode command line tools installed:

```sh
xcode-select --install
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unnecessary Xcode requirement for Android deployment

The README includes Xcode command line tools installation, which isn't necessary for Android deployment. Consider:

  1. Removing the Xcode-specific instructions
  2. Adding Android-specific prerequisites (Java, Android SDK)
-Make sure you have the latest version of the Xcode command line tools installed:
-
-```sh
-xcode-select --install
-```
+Make sure you have the following prerequisites installed:
+- Java Development Kit (JDK)
+- Android SDK
+- Ruby (for Fastlane)

@Baalmart Baalmart merged commit 75ddcd8 into staging Dec 13, 2024
32 checks passed
@Baalmart Baalmart deleted the android-build-playstore branch December 13, 2024 13:59
@Baalmart Baalmart mentioned this pull request Dec 13, 2024
1 task
@coderabbitai coderabbitai bot mentioned this pull request Dec 23, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants