Class: Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction

Inherits:
Action
  • Object
show all
Extended by:
Fastlane::Auth::FirebaseAppDistributionAuthClient, Helper::FirebaseAppDistributionHelper
Defined in:
lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb

Constant Summary

Constants included from Fastlane::Auth::FirebaseAppDistributionAuthClient

Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_ID, Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_SECRET, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_CHARACTER, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_EXPOSED_LENGTH, Fastlane::Auth::FirebaseAppDistributionAuthClient::SCOPE, Fastlane::Auth::FirebaseAppDistributionAuthClient::TOKEN_CREDENTIAL_URI

Documentation collapse

Class Method Summary collapse

Methods included from Fastlane::Auth::FirebaseAppDistributionAuthClient

get_authorization

Methods included from Helper::FirebaseAppDistributionHelper

app_id_from_params, app_name_from_app_id, binary_type_from_path, blank?, deep_symbolize_keys, get_ios_app_id_from_archive_plist, get_ios_app_id_from_plist, get_value_from_value_or_file, group_name, init_google_api_client, lane_platform, parse_plist, present?, project_name, project_number_from_app_id, string_to_array, xcode_archive_path

Class Method Details

.authorsObject



131
132
133
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 131

def self.authors
  ["[email protected]"]
end

.available_optionsObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 81

def self.available_options
  [
    # iOS Specific
    FastlaneCore::ConfigItem.new(key: :googleservice_info_plist_path,
                                 env_name: "GOOGLESERVICE_INFO_PLIST_PATH",
                                 description: "Path to your GoogleService-Info.plist file, relative to the archived product path (or directly, if no archived product path is found)",
                                 default_value: "GoogleService-Info.plist",
                                 optional: true,
                                 type: String),

    # General
    FastlaneCore::ConfigItem.new(key: :app,
                                 env_name: "FIREBASEAPPDISTRO_APP",
                                 description: "Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
                                 description: "Auth token generated using Firebase CLI's login:ci command",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :service_credentials_file,
                                 description: "Path to Google service account json",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :service_credentials_json_data,
                                 description: "Google service account json file content",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :debug,
                                 description: "Print verbose debug output",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



71
72
73
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 71

def self.description
  "Fetches the latest release in Firebase App Distribution"
end

.detailsObject



75
76
77
78
79
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 75

def self.details
  [
    "Fetches information about the most recently created release in App Distribution, including the version and release notes. Returns nil if no releases are found."
  ].join("\n")
end

.example_codeObject



139
140
141
142
143
144
145
146
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 139

def self.example_code
  [
    'release = firebase_app_distribution_get_latest_release(app: "<your Firebase app ID>")',
    'increment_build_number({
      build_number: firebase_app_distribution_get_latest_release(app: "<your Firebase app ID>")[:buildVersion].to_i + 1
    })'
  ]
end

.is_supported?(platform) ⇒ Boolean



135
136
137
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 135

def self.is_supported?(platform)
  true
end

.map_release_hash(release) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 48

def self.map_release_hash(release)
  {
    name: release.name,
    releaseNotes: map_release_notes_hash(release.release_notes),
    displayVersion: release.display_version,
    buildVersion: release.build_version,
    binaryDownloadUri: release.binary_download_uri,
    firebaseConsoleUri: release.firebase_console_uri,
    testingUri: release.testing_uri,
    createTime: release.create_time
  }
end

.map_release_notes_hash(release_notes) ⇒ Object



61
62
63
64
65
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 61

def self.map_release_notes_hash(release_notes)
  return nil if release_notes.nil?

  { text: release_notes.text }
end

.outputObject



117
118
119
120
121
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 117

def self.output
  [
    ['FIREBASE_APP_DISTRO_LATEST_RELEASE', 'A hash representing the lastest release created in Firebase App Distribution']
  ]
end

.return_typeObject



127
128
129
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 127

def self.return_type
  :hash
end

.return_valueObject



123
124
125
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 123

def self.return_value
  "Hash representation of the lastest release created in Firebase App Distribution (see https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.apps.releases#resource:-release)"
end

.run(params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 17

def self.run(params)
  init_google_api_client(params[:debug])
  client = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService.new
  client.authorization = get_authorization(params[:service_credentials_file], params[:firebase_cli_token], params[:service_credentials_json_data], params[:debug])

  app_id = app_id_from_params(params)
  UI.message("⏳ Fetching latest release for app #{app_id}...")
  parent = app_name_from_app_id(app_id)

  begin
    releases = client.list_project_app_releases(parent, page_size: 1).releases
  rescue Google::Apis::Error => err
    if err.status_code.to_i == 404
      UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
    else
      UI.crash!(err)
    end
  end

  if releases.nil? || releases.empty?
    latest_release = nil
    UI.important("No releases for app #{app_id} found in App Distribution. Returning nil and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
  else
    # latest_release = append_json_style_fields(response.releases[0].to_h)
    latest_release = map_release_hash(releases[0])
    UI.success("✅ Latest release fetched successfully. Returning release and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
  end
  Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE] = latest_release
  return latest_release
end

.sample_return_valueObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 148

def self.sample_return_value
  {
    name: "projects/123456789/apps/1:1234567890:ios:0a1b2c3d4e5f67890/releases/0a1b2c3d4",
    releaseNotes: {
      text: "Here are some release notes!"
    },
    displayVersion: "1.2.3",
    buildVersion: "10",
    binaryDownloadUri: "<URI>",
    firebaseConsoleUri: "<URI>",
    testingUri: "<URI>",
    createTime: "2021-10-06T15:01:23Z"
  }
end