diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 51c8bc3..6e7bf54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,7 +153,8 @@ jobs: KEY_PASSWORD: ${{ secrets.AAB_PASSWORD }} STORE_PASSWORD: ${{ secrets.AAB_PASSWORD }} KEY_PATH: ${{ github.workspace }}/android/app/maroon-rides-release-key.jks - + GOOGLE_PLAY_KEY: ${{ secrets.GOOGLE_PLAY_KEY }} + - uses: actions/upload-artifact@v4 with: name: app-bundle.aab diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 90ae3c4..1332a1e 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -102,6 +102,22 @@ default_platform(:android) platform :android do desc "Build APK with Gradle" lane :build do + + # Fetch the latest version code from the Google Play Store for the 'internal' track + latest_version_code = google_play_track_version_codes( + track: 'internal', + json_key_data: Base64.decode64(ENV['GOOGLE_PLAY_KEY']) + ).max || 1 + + # Increment the version code + new_version_code = latest_version_code + 1 + UI.message("New Version Code: #{new_version_code}") + + # Update the versionCode in the build.gradle file + gradle_file = "./android/app/build.gradle" + new_gradle_content = File.read(gradle_file).gsub(/versionCode \d+/, "versionCode #{new_version_code}") + File.write(gradle_file, new_gradle_content) + gradle( task: "bundle", build_type: "Release",