Skip to content

Commit 23a93d7

Browse files
authored
Add getLivePlayStoreVersion Fastlane lane (#7156)
1 parent 36c892e commit 23a93d7

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

fastlane/Fastfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,73 @@ 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+
# Use supply to get detailed release status
355+
require 'supply'
356+
require 'supply/options'
357+
358+
Supply.config = FastlaneCore::Configuration.create(
359+
Supply::Options.available_options,
360+
{
361+
package_name: package_name,
362+
track: track,
363+
json_key: json_key
364+
}
365+
)
366+
367+
client = Supply::Client.make_from_config
368+
369+
# Begin edit to access track information
370+
client.begin_edit(package_name: package_name)
371+
tracks = client.tracks(track)
372+
track_obj = tracks.first
373+
client.abort_current_edit
374+
375+
# Check if there's a completed release (status "completed" means it's live)
376+
# With managed publishing, only completed releases are actually available to users
377+
if track_obj && track_obj.releases
378+
completed_release = track_obj.releases.find { |r| r.status == "completed" }
379+
380+
if completed_release && completed_release.version_codes && !completed_release.version_codes.empty?
381+
# Get the highest version code from the completed release
382+
live_version_code = completed_release.version_codes.max
383+
384+
# Get the corresponding version name from the release
385+
live_version_name = completed_release.name
386+
387+
UI.message("Live version_name: #{live_version_name}")
388+
UI.message("Live version_number: #{live_version_code}")
389+
390+
# Output in the same format as getLatestPlayStoreVersion for compatibility
391+
UI.message("version_name: #{live_version_name}")
392+
UI.message("version_number: #{live_version_code}")
393+
else
394+
UI.message("No completed release found on track: #{track}")
395+
UI.message("version_name: ")
396+
UI.message("version_number: ")
397+
end
398+
else
399+
UI.message("No releases found on track: #{track}")
400+
UI.message("version_name: ")
401+
UI.message("version_number: ")
402+
end
403+
end
404+
338405
desc "Assemble debug variants"
339406
lane :buildAuthenticatorDebug do
340407
gradle(

0 commit comments

Comments
 (0)