Skip to content

Commit 6f54d45

Browse files
ci (fastlane): refactor android build pipeline
1 parent e01d114 commit 6f54d45

File tree

2 files changed

+87
-21
lines changed

2 files changed

+87
-21
lines changed

fastlane/Fastfile

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ end
9595
# Get a unique build number using timestamp
9696
# This avoids race conditions with TestFlight API returning stale data
9797
def 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
102105
end
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

fastlane/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,43 @@ Upload to App Store
4949

5050
----
5151

52+
53+
## Android
54+
55+
### android build
56+
57+
```sh
58+
[bundle exec] fastlane android build
59+
```
60+
61+
Build Android release (AAB and APK)
62+
63+
### android beta
64+
65+
```sh
66+
[bundle exec] fastlane android beta
67+
```
68+
69+
Build and upload to Google Play Store beta track
70+
71+
### android internal
72+
73+
```sh
74+
[bundle exec] fastlane android internal
75+
```
76+
77+
Build and upload to Google Play Store internal testing track
78+
79+
### android release
80+
81+
```sh
82+
[bundle exec] fastlane android release
83+
```
84+
85+
Upload to Google Play Store production
86+
87+
----
88+
5289
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
5390

5491
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).

0 commit comments

Comments
 (0)