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_name_from_app_id, binary_type_from_path, blank?, deep_symbolize_keys, get_ios_app_id_from_archive_plist, get_value_from_value_or_file, group_name, init_client, init_v1_client, init_v1alpha_client, parse_plist, present?, project_name, project_number_from_app_id, string_to_array

Class Method Details

.authorsObject



114
115
116
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 114

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

.available_optionsObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 77

def self.available_options
  [
    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: false,
                                 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: :debug,
                                 description: "Print verbose debug output",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



67
68
69
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 67

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

.detailsObject



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

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



122
123
124
125
126
127
128
129
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 122

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

Returns:

  • (Boolean)


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

def self.is_supported?(platform)
  true
end

.map_release_hash(release) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 44

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



57
58
59
60
61
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 57

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

  { text: release_notes.text }
end

.outputObject



100
101
102
103
104
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 100

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

.return_typeObject



110
111
112
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 110

def self.return_type
  :hash
end

.return_valueObject



106
107
108
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 106

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



15
16
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
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 15

def self.run(params)
  client = init_v1_client(params[:service_credentials_file], params[:firebase_cli_token], params[:debug])

  UI.message("⏳ Fetching latest release for app #{params[:app]}...")

  parent = app_name_from_app_id(params[:app])

  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}: #{params[:app]}")
    else
      UI.crash!(err)
    end
  end

  if releases.nil? || releases.empty?
    latest_release = nil
    UI.important("No releases for app #{params[:app]} 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



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb', line 131

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