Skip to content

Commit ceb23e2

Browse files
AmyLGallesclaude
andcommitted
Add getLivePlayStoreVersion lane
This lane checks for actually published (status 'completed') versions on Google Play rather than just approved versions. With managed publishing enabled, versions can be approved but not yet published to users. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 36c892e commit ceb23e2

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

fastlane/Fastfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,83 @@ platform :android do
335335
UI.message("version_number: #{latest_version_number}")
336336
end
337337

338+
desc "Get the version that's actually live/published to users on Google Play"
339+
lane :getLivePlayStoreVersion do |options|
340+
package_name = options[:package_name]
341+
track = options[:track]
342+
343+
# Determine credentials file based on package name
344+
case package_name
345+
when "com.x8bit.bitwarden", "com.x8bit.bitwarden.beta"
346+
json_key = "secrets/play_creds.json"
347+
when "com.bitwarden.authenticator"
348+
json_key = "secrets/authenticator_play_store-creds.json"
349+
else
350+
UI.important "Unexpected package name: #{package_name}, using default play store json key"
351+
json_key = "secrets/play_creds.json"
352+
end
353+
354+
# Get release information for the track
355+
releases = google_play_track_release_names(
356+
package_name: package_name,
357+
track: track,
358+
json_key: json_key,
359+
)
360+
361+
version_codes = google_play_track_version_codes(
362+
package_name: package_name,
363+
track: track,
364+
json_key: json_key,
365+
)
366+
367+
# Use supply to get detailed release status
368+
require 'supply'
369+
require 'supply/options'
370+
371+
Supply.config = FastlaneCore::Configuration.create(
372+
Supply::Options.available_options,
373+
{
374+
package_name: package_name,
375+
track: track,
376+
json_key: json_key
377+
}
378+
)
379+
380+
client = Supply::Client.make_from_config
381+
track_info = client.track_version_codes(track: track)
382+
383+
# Check if there's a completed release (status "completed" means it's live)
384+
# With managed publishing, only completed releases are actually available to users
385+
if track_info && track_info.releases
386+
completed_release = track_info.releases.find { |r| r.status == "completed" }
387+
388+
if completed_release && completed_release.version_codes && !completed_release.version_codes.empty?
389+
# Get the highest version code from the completed release
390+
live_version_code = completed_release.version_codes.max
391+
392+
# Find the corresponding version name
393+
# Note: version_codes and releases arrays should be parallel
394+
index = version_codes.index(live_version_code)
395+
live_version_name = index ? releases[index] : releases.first
396+
397+
UI.message("Live version_name: #{live_version_name}")
398+
UI.message("Live version_number: #{live_version_code}")
399+
400+
# Output in the same format as getLatestPlayStoreVersion for compatibility
401+
UI.message("version_name: #{live_version_name}")
402+
UI.message("version_number: #{live_version_code}")
403+
else
404+
UI.message("No completed release found on track: #{track}")
405+
UI.message("version_name: ")
406+
UI.message("version_number: ")
407+
end
408+
else
409+
UI.message("No releases found on track: #{track}")
410+
UI.message("version_name: ")
411+
UI.message("version_number: ")
412+
end
413+
end
414+
338415
desc "Assemble debug variants"
339416
lane :buildAuthenticatorDebug do
340417
gradle(

0 commit comments

Comments
 (0)