fastlane-plugin-wpmreleasetoolkit 12.4.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb +2 -0
  3. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +2 -0
  4. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb +2 -0
  5. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_preflight.rb +2 -0
  6. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb +2 -0
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb +2 -0
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +2 -0
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +2 -0
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +2 -0
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +2 -0
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_launch_emulator_action.rb +2 -0
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_send_app_size_metrics.rb +7 -5
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_shutdown_emulator_action.rb +2 -0
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb +2 -0
  16. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_annotate_action.rb +2 -0
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb +2 -0
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_pipeline_upload_action.rb +3 -1
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb +2 -0
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_for_toolkit_updates_action.rb +3 -1
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb +2 -0
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb +2 -0
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +2 -0
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb +2 -0
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb +2 -0
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb +2 -0
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +2 -0
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +3 -1
  29. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +2 -0
  30. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/find_previous_tag.rb +2 -0
  31. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/firebase_login.rb +2 -0
  32. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb +2 -0
  33. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +2 -0
  34. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +2 -0
  35. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/openai_ask_action.rb +3 -1
  36. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +2 -0
  37. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb +141 -109
  38. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +2 -0
  39. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb +2 -0
  40. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb +2 -0
  41. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_milestone_frozen_marker_action.rb +2 -0
  42. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/update_assigned_milestone_action.rb +2 -0
  43. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_build_to_apps_cdn.rb +320 -0
  44. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb +2 -0
  45. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb +2 -0
  46. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_apply_action.rb +2 -0
  47. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb +2 -0
  48. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb +2 -0
  49. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb +2 -0
  50. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb +2 -0
  51. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb +2 -0
  52. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb +2 -0
  53. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb +2 -0
  54. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +5 -3
  55. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_download_strings_files_from_glotpress.rb +2 -0
  56. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_extract_keys_from_strings_files.rb +2 -0
  57. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_generate_strings_file_from_code.rb +2 -0
  58. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_store_app_sizes.rb +2 -0
  59. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +14 -3
  60. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_strings_files.rb +2 -0
  61. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_send_app_size_metrics.rb +5 -3
  62. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb +2 -0
  63. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb +2 -0
  64. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_emulator_helper.rb +2 -0
  65. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +3 -1
  66. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_tools_path_helper.rb +2 -0
  67. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +6 -4
  68. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/app_size_metrics_helper.rb +2 -0
  69. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb +2 -0
  70. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb +2 -0
  71. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb +5 -7
  72. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb +2 -0
  73. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +3 -1
  74. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +2 -0
  75. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/glotpress_helper.rb +2 -0
  76. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb +3 -1
  77. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb +2 -0
  78. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb +2 -0
  79. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb +12 -8
  80. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_strings_file_validation_helper.rb +3 -1
  81. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +2 -0
  82. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/metadata_block.rb +2 -0
  83. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb +2 -0
  84. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb +2 -0
  85. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb +2 -0
  86. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/unknown_metadata_block.rb +2 -0
  87. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/whats_new_metadata_block.rb +2 -0
  88. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +2 -0
  89. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +2 -0
  90. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb +2 -0
  91. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb +3 -1
  92. data/lib/fastlane/plugin/wpmreleasetoolkit/models/app_version.rb +2 -0
  93. data/lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb +2 -0
  94. data/lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb +2 -0
  95. data/lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb +2 -0
  96. data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_account.rb +2 -0
  97. data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_device.rb +2 -0
  98. data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_lab_result.rb +2 -0
  99. data/lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_runner.rb +2 -0
  100. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
  101. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb +2 -0
  102. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb +2 -0
  103. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb +2 -0
  104. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb +2 -0
  105. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb +2 -0
  106. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb +2 -0
  107. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb +2 -0
  108. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb +2 -0
  109. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb +2 -0
  110. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb +2 -0
  111. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb +2 -0
  112. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb +2 -0
  113. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb +3 -1
  114. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb +2 -0
  115. data/lib/fastlane/plugin/wpmreleasetoolkit.rb +2 -0
  116. metadata +3 -2
@@ -1,24 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
4
+ require 'uri'
5
+
1
6
  module Fastlane
2
7
  module Actions
3
8
  class PrototypeBuildDetailsCommentAction < Action
4
9
  def self.run(params)
5
10
  app_display_name = params[:app_display_name]
6
- app_center_info = AppCenterInfo.from_params(params)
7
- metadata = consolidate_metadata(params, app_center_info)
11
+ download_url = params[:download_url]
12
+ release_info = FirebaseReleaseInfo.from_lane_context
8
13
 
9
- qr_code_url, extra_metadata = build_install_links(app_center_info, params[:download_url])
14
+ # Merge explicit extra metadata passed from params with ones derived from FirebaseReleaseInfo
15
+ metadata = generate_metadata_hash(params: params, release_info: release_info)
16
+ # Build the installation link, QR code URL and extra metadata for download links from the available info
17
+ qr_code_url, extra_metadata = install_links(release_info: release_info, download_url: download_url)
10
18
  metadata.merge!(extra_metadata)
11
19
 
12
- # Build the comment parts
13
- icon_img_tag = img_tag(params[:app_icon] || app_center_info.icon, alt: app_display_name)
20
+ # Build the comment parts and body
21
+ app_icon = params[:app_icon]
22
+ app_icon ||= ':firebase:' if !release_info.nil? || (download_url && is_firebase_url?(download_url))
23
+ intro = "#{img_tag(app_icon)}📲 You can test the changes from this Pull Request in <b>#{CGI.escape_html(app_display_name)}</b> by scanning the QR code below to install the corresponding build."
14
24
  metadata_rows = metadata.compact.map { |key, value| "<tr><td><b>#{key}</b></td><td>#{value}</td></tr>" }
15
- intro = "#{icon_img_tag}📲 You can test the changes from this Pull Request in <b>#{app_display_name}</b> by scanning the QR code below to install the corresponding build."
16
- footnote = params[:footnote] || (app_center_info.org_name.nil? ? '' : DEFAULT_APP_CENTER_FOOTNOTE)
17
- body = <<~COMMENT_BODY
25
+ footnote = params[:footnote]
26
+ footnote ||= DEFAULT_FOOTNOTE if !release_info.nil? || (download_url && is_firebase_url?(download_url))
27
+
28
+ body = <<~COMMENT_BODY.chomp('')
18
29
  <table>
19
30
  <tr>
20
31
  <td rowspan='#{metadata_rows.count + 1}' width='260px'><img src='#{qr_code_url}' width='250' height='250' /></td>
21
- <td><b>App Name</b></td><td>#{icon_img_tag} #{app_display_name}</td>
32
+ <td><b>App Name</b></td><td>#{CGI.escape_html(app_display_name)}</td>
22
33
  </tr>
23
34
  #{metadata_rows.join("\n")}
24
35
  </table>
@@ -26,9 +37,9 @@ module Fastlane
26
37
  COMMENT_BODY
27
38
 
28
39
  if params[:fold]
29
- "<details><summary>#{intro}</summary>\n#{body}</details>\n"
40
+ "<details><summary>#{intro}</summary>\n#{body}\n</details>\n"
30
41
  else
31
- "<p>#{intro}</p>\n#{body}"
42
+ "<p>#{intro}</p>\n#{body}\n"
32
43
  end
33
44
  end
34
45
 
@@ -36,78 +47,125 @@ module Fastlane
36
47
  # @!group Helpers
37
48
  #####################################################
38
49
 
39
- NO_INSTALL_URL_ERROR_MESSAGE = <<~NO_URL_ERROR.freeze
50
+ NO_INSTALL_URL_ERROR_MESSAGE = <<~NO_URL_ERROR
40
51
  No URL provided to download or install the app.
41
- - Either use this action right after using `appcenter_upload` and provide an `app_center_org_name` (so that this action can use the link to the App Center build)
52
+ - Either use this action right after using `firebase_app_distribution` so this action can extract the download URL from the `lane_context`
42
53
  - Or provide an explicit value for the `download_url` parameter
43
54
  NO_URL_ERROR
44
55
 
45
- DEFAULT_APP_CENTER_FOOTNOTE = '<em>Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.</em>'.freeze
56
+ DEFAULT_FOOTNOTE = '<em>Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.</em>'
46
57
 
47
- # A small model struct to consolidate and pack all the values related to App Center
58
+ # Parse and validate a URL string
48
59
  #
49
- AppCenterInfo = Struct.new(:org_name, :app_name, :display_name, :release_id, :icon, :version, :short_version, :os, :bundle_id) do
50
- # A method to construct an AppCenterInfo instance from the action params, and infer the rest from the `lane_context` if available
51
- def self.from_params(params)
52
- org_name = params[:app_center_org_name]
53
- ctx = if org_name && defined?(SharedValues::APPCENTER_BUILD_INFORMATION)
54
- Fastlane::Actions.lane_context[SharedValues::APPCENTER_BUILD_INFORMATION] || {}
55
- else
56
- {}
57
- end
58
- app_name = params[:app_center_app_name] || ctx['app_name']
60
+ # @param [String] url The URL string to parse and validate
61
+ # @return [URI] The parsed URI object
62
+ # @raise [FastlaneCore::Interface::FastlaneError] if the URL is invalid
63
+ #
64
+ def self.parse_url!(url)
65
+ URI.parse(url).tap do |uri|
66
+ raise URI::InvalidURIError unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
67
+ end
68
+ rescue URI::InvalidURIError
69
+ UI.user_error!("Invalid URL: #{url}")
70
+ end
71
+
72
+ # A small model/struct representing values exposed by Firebase App Distribution for a given release
73
+ #
74
+ FirebaseReleaseInfo = Struct.new(:display_version, :build_version, :testing_url, :os, :bundle_id, :release_id, keyword_init: true) do
75
+ def self.from_lane_context
76
+ return nil unless defined?(SharedValues::FIREBASE_APP_DISTRO_RELEASE)
77
+
78
+ ctx = Fastlane::Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_RELEASE]
79
+ return nil if ctx.nil?
80
+
81
+ # Extract platform info from Firebase Console URI
82
+ if ctx[:firebaseConsoleUri]
83
+ uri = URI(ctx[:firebaseConsoleUri])
84
+ os, bundle_id, release_id = uri.path.match(%r{project/.*/appdistribution/app/([^:]*):([^/]*)/releases/(.*)})&.captures
85
+ end
86
+
59
87
  new(
60
- org_name,
61
- app_name,
62
- ctx['app_display_name'] || app_name,
63
- params[:app_center_release_id] || ctx['id'],
64
- ctx['app_icon_url'],
65
- ctx['version'],
66
- ctx['short_version'],
67
- ctx['app_os'],
68
- ctx['bundle_identifier']
88
+ display_version: ctx[:displayVersion],
89
+ build_version: ctx[:buildVersion],
90
+ testing_url: ctx[:testingUri],
91
+ os: os,
92
+ bundle_id: bundle_id,
93
+ release_id: release_id
69
94
  )
70
95
  end
71
96
  end
72
97
 
73
- # Builds the installation link, QR code URL and extra metadata for download links from the available info
98
+ # Constructs the Hash of metadata, based on the explicit ones passed by the user as parameter + the implicit ones from `FirebaseReleaseInfo`
74
99
  #
75
- # @param [AppCenterInfo] app_center_info The struct containing all the values related to App Center info
76
- # @param [String] download_url The `download_url` parameter passed to the action, if one exists
100
+ # @param [Hash<Symbol, Any>] params The action's parameters, as received by `self.run`
101
+ # @param [FirebaseReleaseInfo?] release_info The information about the Firebase Release extracted from the `lane_context`
102
+ # @return [Hash<String, String>] A hash of all the metadata, consolidated from both the explicit and the implicit ones
103
+ #
104
+ def self.generate_metadata_hash(params:, release_info:)
105
+ metadata = params[:metadata]&.transform_keys(&:to_s) || {}
106
+
107
+ # Add Firebase-specific metadata if available
108
+ metadata['Build Number'] ||= "<code>#{release_info&.build_version}</code>"
109
+ metadata['Version'] ||= "<code>#{release_info&.display_version}</code>"
110
+ metadata[release_info&.os == 'ios' ? 'Bundle ID' : 'Application ID'] ||= "<code>#{release_info&.bundle_id}</code>"
111
+
112
+ # Add git metadata
113
+ metadata['Commit'] ||= ENV.fetch('BUILDKITE_COMMIT', nil) || other_action.last_git_commit[:abbreviated_commit_hash]
114
+ metadata
115
+ end
116
+
117
+ # Constructs the installation link, QR code URL and extra metadata for download links from the available info
118
+ #
119
+ # @param [FirebaseReleaseInfo?] release_info The information about the Firebase Release extracted from the `lane_context`
120
+ # @param [String] download_url The `download_url` parameter passed to the action, if one was provided
77
121
  # @return [(String, Hash<String,String>)] A tuple containing:
78
122
  # - The URL for the QR Code
79
123
  # - A Hash of the extra metadata key/value pairs to add to the existing metadata, to enrich them with download/install links
124
+ # @raise [FastlaneCore::Interface::FastlaneError] if no valid installation URL could be determined
80
125
  #
81
- def self.build_install_links(app_center_info, download_url)
126
+ def self.install_links(release_info:, download_url:)
82
127
  install_url = nil
83
128
  extra_metadata = {}
129
+ firebase_release_id = nil
130
+
131
+ # Validate and process direct download URL if provided
84
132
  if download_url
133
+ uri = parse_url!(download_url)
85
134
  install_url = download_url
86
- extra_metadata['Direct Download'] = "<a href='#{install_url}'><code>#{File.basename(install_url)}</code></a>"
135
+
136
+ if is_firebase_url?(uri)
137
+ firebase_release_id = File.basename(uri.path)
138
+ else
139
+ filename = File.basename(uri.path)
140
+ extra_metadata['Direct Download'] = "<a href='#{CGI.escape_html(install_url)}'><code>#{CGI.escape_html(filename)}</code></a>"
141
+ end
87
142
  end
88
- if app_center_info.org_name && app_center_info.app_name
89
- install_url = "https://install.appcenter.ms/orgs/#{app_center_info.org_name}/apps/#{app_center_info.app_name}/releases/#{app_center_info.release_id}"
90
- extra_metadata['App Center Build'] = "<a href='#{install_url}'>#{app_center_info.display_name} ##{app_center_info.release_id}</a>"
143
+
144
+ # Process Firebase testing URL if available from release_info
145
+ if release_info&.testing_url
146
+ install_url = release_info.testing_url
147
+ firebase_release_id = release_info.release_id
91
148
  end
149
+
92
150
  UI.user_error!(NO_INSTALL_URL_ERROR_MESSAGE) if install_url.nil?
151
+
152
+ # Add Installation URL metadata if we have a release_id
153
+ extra_metadata['Installation URL'] = "<a href='#{CGI.escape_html(install_url)}'>#{CGI.escape_html(firebase_release_id)}</a>" if firebase_release_id
154
+
155
+ # Generate QR code URL with proper escaping
93
156
  qr_code_url = "https://api.qrserver.com/v1/create-qr-code/?size=500x500&qzone=4&data=#{CGI.escape(install_url)}"
94
157
  [qr_code_url, extra_metadata]
95
158
  end
96
159
 
97
- # A method to build the Hash of metadata, based on the explicit ones passed by the user as parameter + the implicit ones from `AppCenterInfo`
160
+ # Determines if a given URI is a Firebase App Distribution URL
98
161
  #
99
- # @param [Hash<Symbol, Any>] params The action's parameters, as received by `self.run`
100
- # @param [AppCenterInfo] app_center_info The model object containing all the values related to App Center information
101
- # @return [Hash<String, String>] A hash of all the metadata, gathered from both the explicit and the implicit ones
162
+ # @param [String, URI] url The URL to check, either as a String or an already-parsed URI
163
+ # @return [Boolean] true if the URL is a Firebase App Distribution URL
164
+ # @raise [FastlaneCore::Interface::FastlaneError] if the URL is invalid
102
165
  #
103
- def self.consolidate_metadata(params, app_center_info)
104
- metadata = params[:metadata]&.transform_keys(&:to_s) || {}
105
- metadata['Build Number'] ||= app_center_info.version
106
- metadata['Version'] ||= app_center_info.short_version
107
- metadata[app_center_info.os == 'Android' ? 'Application ID' : 'Bundle ID'] ||= app_center_info.bundle_id
108
- # (Feel free to add more CI-specific env vars in the line below to support other CI providers if you need)
109
- metadata['Commit'] ||= ENV.fetch('BUILDKITE_COMMIT', nil) || other_action.last_git_commit[:abbreviated_commit_hash]
110
- metadata
166
+ def self.is_firebase_url?(url)
167
+ uri = url.is_a?(URI) ? url : parse_url!(url)
168
+ uri.host == 'appdistribution.firebase.google.com' && uri.path.start_with?('/testerapps/')
111
169
  end
112
170
 
113
171
  # Creates an HTML `<img>` tag for an icon URL or the image URL to represent a given Buildkite emoji
@@ -115,19 +173,19 @@ module Fastlane
115
173
  # @param [String] url_or_emoji A `String` which can be:
116
174
  # - Either a valid URI to an image
117
175
  # - Or a string formatted like `:emojiname:`, using a valid Buildite emoji name as defined in https://github.com/buildkite/emojis
118
- # @param [String] alt The alt text to use for the `<img>` tag
119
176
  # @return [String] The `<img …>` tag with the proper image and alt tag
177
+ # @raise [FastlaneCore::Interface::FastlaneError] if the URL is invalid
120
178
  #
121
- def self.img_tag(url_or_emoji, alt: '')
179
+ def self.img_tag(url_or_emoji)
122
180
  return nil if url_or_emoji.nil?
123
181
 
124
182
  emoji = url_or_emoji.match(/:(.*):/)&.captures&.first
125
183
  app_icon_url = if emoji
126
184
  "https://raw.githubusercontent.com/buildkite/emojis/main/img-buildkite-64/#{emoji}.png"
127
- elsif URI(url_or_emoji)
128
- url_or_emoji
185
+ else
186
+ url_or_emoji.tap { parse_url!(url_or_emoji) }
129
187
  end
130
- app_icon_url ? "<img alt='#{alt}' align='top' src='#{app_icon_url}' width='20px' />" : ''
188
+ app_icon_url ? "<img align='top' src='#{app_icon_url}' width='20px' alt='App Icon' />" : ''
131
189
  end
132
190
 
133
191
  #####################################################
@@ -143,98 +201,72 @@ module Fastlane
143
201
  Generates a string providing all the details of a prototype build, nicely-formatted as HTML.
144
202
  The returned string will typically be subsequently used by the `comment_on_pr` action to post that HTML as comment on a PR.
145
203
 
146
- If you used the `appcenter_upload` lane (to upload the Prototype build to App Center) before calling this action, and pass
147
- a value to the `app_center_org_name` parameter, then many of the parameters and metadata will be automatically extracted
148
- from the `lane_context` provided by `appcenter_upload`, including:
204
+ If you used the `firebase_app_distribution` action (to upload the Prototype build to Firebase App Distribution) before calling this action,
205
+ then many of the metadata will be automatically extracted from the `lane_context` it exposed:
149
206
 
150
- - The `app_center_app_name`, `app_center_release_id` and installation URL to use for the QR code to point to that release in App Center
151
- - The `app_icon`
152
- - The app's Build Number / versionCode
153
- - The app's Version / versionName
154
- - The app's Bundle ID / Application ID
155
- - A `footnote` mentioning the MC tool for Automatticians to add themselves to App Center
207
+ - "Version" (from `:displayVersion`) and "Build Number" (from `:buildVersion`)
208
+ - "Bundle ID" (extracted from `:firebaseConsoleUri`)
209
+ - "Commit" (from `BUILDKITE_COMMIT` environment variable or last git commit)
210
+ - "Installation URL" (from `:testingUri`)
156
211
 
157
- This means that if you are using App Center to distribute your Prototype Build, the only parameters you *have* to provide
158
- to this action are `app_display_name` and `app_center_org_name`; plus, for `metadata` most of the interesting values will already be pre-filled.
212
+ You can also pass additional metadata to this action via the `metadata` parameter, and they will also be included in the HTML table of the comment.
159
213
 
160
- Any of those implicit default values/metadata can of course be overridden by passing an explicit value to the appropriate parameter(s).
214
+ This means that if you are using Firebase App Distribution to distribute your Prototype Build, the can just provide
215
+ `app_display_name` and optionally `app_icon`, and the rest will be automatically inferred from the `lane_context`.
216
+
217
+ If you are not using Firebase App Distribution, you can pass an explicit value for the `download_url` parameter,
218
+ and the action will use it to generate the installation link and QR code.
161
219
  DESC
162
220
  end
163
221
 
164
222
  def self.available_options
165
- app_center_auto = '(will be automatically extracted from `lane_context if you used `appcenter_upload` to distribute your Prototype build)'
166
223
  [
167
224
  FastlaneCore::ConfigItem.new(
168
225
  key: :app_display_name,
169
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_APP_DISPLAY_NAME',
170
226
  description: 'The display name to use for the app in the comment message',
171
227
  optional: false,
172
228
  type: String
173
229
  ),
174
- FastlaneCore::ConfigItem.new(
175
- key: :app_center_org_name,
176
- env_name: 'APPCENTER_OWNER_NAME', # Intentionally the same as the one used by the `appcenter_upload` action
177
- description: 'The name of the organization in App Center (if you used `appcenter_upload` to distribute your Prototype build)',
178
- type: String,
179
- optional: true
180
- ),
181
- FastlaneCore::ConfigItem.new(
182
- key: :app_center_app_name,
183
- env_name: 'APPCENTER_APP_NAME', # Intentionally the same as the one used by the `appcenter_upload` action
184
- description: "The name of the app in App Center #{app_center_auto}",
185
- type: String,
186
- optional: true,
187
- default_value_dynamic: true # As it will be extracted from the `lane_context`` if you used `appcenter_upload``
188
- ),
189
- FastlaneCore::ConfigItem.new(
190
- key: :app_center_release_id,
191
- env_name: 'APPCENTER_RELEASE_ID',
192
- description: "The release ID/Number in App Center #{app_center_auto}",
193
- type: String,
194
- optional: true,
195
- default_value_dynamic: true # As it will be extracted from the `lane_context`` if you used `appcenter_upload``
196
- ),
197
230
  FastlaneCore::ConfigItem.new(
198
231
  key: :app_icon,
199
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_APP_ICON',
200
- description: "The name of an emoji from the https://github.com/buildkite/emojis list or the full image URL to use for the icon of the app in the message. #{app_center_auto}",
232
+ description: 'The name of an emoji from the https://github.com/buildkite/emojis list or the full image URL to use for the icon of the app in the message',
201
233
  type: String,
202
234
  optional: true,
203
- default_value_dynamic: true # As it will be extracted from the `lane_context`` if you used `appcenter_upload``
235
+ default_value_dynamic: true # Defaults to `:firebase:` only if `firebase_app_distribution` was used
204
236
  ),
205
237
  FastlaneCore::ConfigItem.new(
206
238
  key: :download_url,
207
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_DOWNLOAD_URL',
208
- description: 'The URL to download the build as a direct download. ' \
209
- + 'If you uploaded the build to App Center, we recommend leaving this nil (the comment will use the URL to the App Center build for the QR code)',
239
+ description: <<~DESC,
240
+ The URL to use to download/install the build.
241
+ - If you used `firebase_app_distribution` to upload the build during the same `fastlane` run, you should leave this nil
242
+ - If you used `firebase_app_distribution` during a separate CI job, you can store the `:testingUri` of that call's returned hash (in e.g. Buildkite metadata), then pass that URI to this parameter
243
+ - Otherwise, you can provide a direct download URL for the build (e.g. link to Cloudfront or AppsCDN URL)
244
+ DESC
210
245
  type: String,
211
246
  optional: true,
212
247
  default_value: nil
213
248
  ),
214
249
  FastlaneCore::ConfigItem.new(
215
250
  key: :fold,
216
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_FOLD',
217
251
  description: 'If true, will wrap the HTML table inside a <details> block (hidden by default)',
218
252
  type: Boolean,
219
253
  default_value: false
220
254
  ),
221
255
  FastlaneCore::ConfigItem.new(
222
256
  key: :metadata,
223
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_METADATA',
224
257
  description: 'All additional metadata (as key/value pairs) you want to include in the HTML table of the comment. ' \
225
- + 'If you are running this action after `appcenter_upload`, some metadata will automatically be added to this list too',
258
+ + 'If you are running this action after `firebase_app_distribution`, some metadata will automatically be added and merged with this list',
226
259
  type: Hash,
227
260
  optional: true,
228
- default_value_dynamic: true # As some metadata will be auto-filled if you used `appcenter_upload`
261
+ default_value_dynamic: true # As some metadata will be auto-filled if you used `firebase_app_distribution`
229
262
  ),
230
263
  FastlaneCore::ConfigItem.new(
231
264
  key: :footnote,
232
- env_name: 'FL_PROTOTYPE_BUILD_DETAILS_COMMENT_FOOTNOTE',
233
265
  description: 'Optional footnote to add below the HTML table of the comment. ' \
234
- + 'If you are running this action after `appcenter_upload`, a default footnote for Automatticians will be used unless you provide an explicit value',
266
+ + 'If you are running this action after `firebase_app_distribution`, a default footnote for Automatticians will be used unless you provide an explicit value',
235
267
  type: String,
236
268
  optional: true,
237
- default_value_dynamic: true # We have a default footnote for the case when you used App Center
269
+ default_value_dynamic: true # We have a default footnote for the case when you used Firebase App Distribution
238
270
  ),
239
271
  ]
240
272
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../../helper/github_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../../helper/github_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../../helper/github_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../../helper/github_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../../helper/github_helper'
3
5