9595# Get a unique build number using timestamp
9696# This avoids race conditions with TestFlight API returning stale data
9797def get_next_build_number
98- # Format: YYMMDDHHMM (fits in 32-bit integer, always increasing)
99- build_number = Time . now . utc . strftime ( "%y%m%d%H%M" ) . to_i
100- UI . message ( "Build number (timestamp): #{ build_number } " )
98+ # Use seconds since Jan 1, 2024 00:00:00 UTC
99+ # Max Android versionCode is 2,100,000,000
100+ # This gives us ~66 years of headroom (2024-2090)
101+ epoch = Time . utc ( 2024 , 1 , 1 , 0 , 0 , 0 )
102+ build_number = ( Time . now . utc - epoch ) . to_i
103+ UI . message ( "Build number (seconds since 2024): #{ build_number } " )
101104 build_number
102105end
103106
@@ -453,19 +456,14 @@ platform :android do
453456
454457 UI . success ( "Updated tauri.conf.json: v#{ app_version } (build #{ build_number } )" )
455458
456- # Build Android app bundle using Gradle
457- gradle (
458- task : "bundle" ,
459- build_type : "Release" ,
460- project_dir : "#{ ROOT_DIR } /src-tauri/gen/android"
461- )
459+ # Build Android app bundle using Tauri CLI
460+ sh ( "cd #{ ROOT_DIR } /src-tauri && npx tauri android build --aab true" )
462461
463462 # Upload to Play Store beta track
464- # Requires Google Play Console API credentials set up
465- # Set SUPPLY_JSON_KEY_DATA or SUPPLY_JSON_KEY environment variable
466463 upload_to_play_store (
464+ package_name : "com.lunch.app" ,
467465 track : "beta" ,
468- aab : "#{ ROOT_DIR } /src-tauri/gen/android/app/build/outputs/bundle/release /app-release.aab" ,
466+ aab : "#{ ROOT_DIR } /src-tauri/gen/android/app/build/outputs/bundle/universalRelease /app-universal -release.aab" ,
469467 skip_upload_metadata : true ,
470468 skip_upload_images : true ,
471469 skip_upload_screenshots : true
@@ -474,6 +472,42 @@ platform :android do
474472 UI . success ( "Uploaded to Google Play Store beta track!" )
475473 end
476474
475+ desc "Build and upload to Google Play Store internal testing track"
476+ lane :internal do
477+ # Set ANDROID_HOME for this session
478+ ENV [ 'ANDROID_HOME' ] = "/opt/homebrew/share/android-commandlinetools"
479+ ENV [ 'ANDROID_NDK_HOME' ] = "#{ ENV [ 'ANDROID_HOME' ] } /ndk/28.2.13676358"
480+
481+ # Update tauri.conf.json with version from Cargo.toml
482+ app_version = get_app_version
483+ build_number = get_next_build_number
484+
485+ tauri_conf_path = "#{ ROOT_DIR } /src-tauri/tauri.conf.json"
486+ tauri_conf = JSON . parse ( File . read ( tauri_conf_path ) )
487+ tauri_conf [ "version" ] = app_version
488+ tauri_conf [ "bundle" ] ||= { }
489+ tauri_conf [ "bundle" ] [ "android" ] ||= { }
490+ tauri_conf [ "bundle" ] [ "android" ] [ "versionCode" ] = build_number
491+ File . write ( tauri_conf_path , JSON . pretty_generate ( tauri_conf ) )
492+
493+ UI . success ( "Updated tauri.conf.json: v#{ app_version } (build #{ build_number } )" )
494+
495+ # Build Android app bundle using Tauri CLI
496+ sh ( "cd #{ ROOT_DIR } /src-tauri && npx tauri android build --aab true" )
497+
498+ # Upload to Play Store internal testing track
499+ upload_to_play_store (
500+ package_name : "com.lunch.app" ,
501+ track : "internal" ,
502+ aab : "#{ ROOT_DIR } /src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab" ,
503+ skip_upload_metadata : true ,
504+ skip_upload_images : true ,
505+ skip_upload_screenshots : true
506+ )
507+
508+ UI . success ( "Uploaded to Google Play Store internal testing track!" )
509+ end
510+
477511 desc "Upload to Google Play Store production"
478512 lane :release do
479513 # Set ANDROID_HOME for this session
@@ -494,19 +528,14 @@ platform :android do
494528
495529 UI . success ( "Updated tauri.conf.json: v#{ app_version } (build #{ build_number } )" )
496530
497- # Build Android app bundle using Gradle
498- gradle (
499- task : "bundle" ,
500- build_type : "Release" ,
501- project_dir : "#{ ROOT_DIR } /src-tauri/gen/android"
502- )
531+ # Build Android app bundle using Tauri CLI
532+ sh ( "cd #{ ROOT_DIR } /src-tauri && npx tauri android build --aab true" )
503533
504534 # Upload to Play Store production track
505- # Requires Google Play Console API credentials set up
506- # Set SUPPLY_JSON_KEY_DATA or SUPPLY_JSON_KEY environment variable
507535 upload_to_play_store (
536+ package_name : "com.lunch.app" ,
508537 track : "production" ,
509- aab : "#{ ROOT_DIR } /src-tauri/gen/android/app/build/outputs/bundle/release /app-release.aab" ,
538+ aab : "#{ ROOT_DIR } /src-tauri/gen/android/app/build/outputs/bundle/universalRelease /app-universal -release.aab" ,
510539 skip_upload_metadata : true ,
511540 skip_upload_images : true ,
512541 skip_upload_screenshots : true
0 commit comments