Skip to content

Commit 3c616a5

Browse files
authored
Merge branch 'trunk' into issue/CMM-176-reader-subscribe-options
2 parents 8a4582f + ebfb41e commit 3c616a5

File tree

5 files changed

+97
-38
lines changed

5 files changed

+97
-38
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gem 'nokogiri'
88

99
### Fastlane Plugins
1010

11+
gem 'fastlane-plugin-firebase_app_distribution', '~> 0.10'
1112
gem 'fastlane-plugin-sentry'
1213
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 13.8'
1314
# gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../release-toolkit'

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ GEM
169169
xcodeproj (>= 1.13.0, < 2.0.0)
170170
xcpretty (~> 0.4.1)
171171
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
172+
fastlane-plugin-firebase_app_distribution (0.10.1)
173+
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
174+
google-apis-firebaseappdistribution_v1alpha (~> 0.2.0)
172175
fastlane-plugin-sentry (1.29.0)
173176
os (~> 1.1, >= 1.1.4)
174177
fastlane-plugin-wpmreleasetoolkit (13.8.1)
@@ -204,6 +207,10 @@ GEM
204207
representable (~> 3.0)
205208
retriable (>= 2.0, < 4.a)
206209
rexml
210+
google-apis-firebaseappdistribution_v1 (0.3.0)
211+
google-apis-core (>= 0.11.0, < 2.a)
212+
google-apis-firebaseappdistribution_v1alpha (0.2.0)
213+
google-apis-core (>= 0.11.0, < 2.a)
207214
google-apis-iamcredentials_v1 (0.17.0)
208215
google-apis-core (>= 0.11.0, < 2.a)
209216
google-apis-playcustomapp_v1 (0.13.0)
@@ -358,6 +365,7 @@ PLATFORMS
358365
DEPENDENCIES
359366
danger-dangermattic (~> 1.2)
360367
fastlane (~> 2)
368+
fastlane-plugin-firebase_app_distribution (~> 0.10)
361369
fastlane-plugin-sentry
362370
fastlane-plugin-wpmreleasetoolkit (~> 13.8)
363371
nokogiri

fastlane/Fastfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ APP_SPECIFIC_VALUES = {
1111
package_name: 'org.wordpress.android',
1212
bundle_name_prefix: 'wpandroid',
1313
screenshots_test_class: 'org.wordpress.android.ui.screenshots.WPScreenshotTest',
14-
screenshot_config_file: 'wordpress-config.json'
14+
screenshot_config_file: 'wordpress-config.json',
15+
firebase: {
16+
app_id: '1:124902176124:android:4f9776805ebf421d1620f9',
17+
testers_group: 'wordpress-android---prototype-builds'
18+
}
1519
},
1620
jetpack: {
1721
display_name: 'Jetpack',
@@ -21,15 +25,18 @@ APP_SPECIFIC_VALUES = {
2125
package_name: 'com.jetpack.android',
2226
bundle_name_prefix: 'jpandroid',
2327
screenshots_test_class: 'org.wordpress.android.ui.screenshots.JPScreenshotTest',
24-
screenshot_config_file: 'jetpack-config.json'
28+
screenshot_config_file: 'jetpack-config.json',
29+
firebase: {
30+
app_id: '1:124902176124:android:97a4443a7dbfb7cc1620f9',
31+
testers_group: 'jetpack-android---prototype-builds'
32+
}
2533
}
2634
}.freeze
2735

2836
UPLOAD_TO_PLAY_STORE_JSON_KEY = File.join(Dir.home, '.configure', 'wordpress-android', 'secrets', 'google-upload-credentials.json')
2937

3038
PROTOTYPE_BUILD_FLAVOR = 'Jalapeno'
3139
PROTOTYPE_BUILD_TYPE = 'Debug'
32-
PROTOTYPE_BUILD_DOMAIN = 'https://cdn.a8c-ci.services'
3340

3441
PROJECT_ROOT_FOLDER = File.dirname(File.expand_path(__dir__))
3542
FASTLANE_FOLDER = File.join(PROJECT_ROOT_FOLDER, 'fastlane')

fastlane/lanes/build.rb

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@
202202
#####################################################################################
203203
# build_and_upload_wordpress_prototype_build
204204
# -----------------------------------------------------------------------------------
205-
# Build a WordPress Prototype Build and make it available for download
205+
# Build a WordPress Prototype Build and upload it to Firebase App Distribution
206206
# -----------------------------------------------------------------------------------
207207
# Usage:
208208
# bundle exec fastlane build_and_upload_wordpress_prototype_build
209209
#####################################################################################
210-
desc 'Build a WordPress Prototype Build and make it available for download'
210+
desc 'Build a WordPress Prototype Build and upload it to Firebase App Distribution'
211211
lane :build_and_upload_wordpress_prototype_build do
212-
UI.user_error!("'BUILDKITE_ARTIFACTS_S3_BUCKET' must be defined as an environment variable.") unless ENV['BUILDKITE_ARTIFACTS_S3_BUCKET']
212+
UI.user_error!("'FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY' must be defined as an environment variable.") unless ENV['FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY']
213213

214214
version_name = generate_prototype_build_number
215215
gradle(
@@ -219,21 +219,21 @@
219219
properties: { prototypeBuildVersionName: version_name }
220220
)
221221

222-
upload_prototype_build(product: 'WordPress', version_name: version_name)
222+
upload_prototype_build(app: :wordpress, version_name: version_name)
223223
upload_gutenberg_sourcemaps(app: 'Wordpress', release_version: version_name)
224224
end
225225

226226
#####################################################################################
227227
# build_and_upload_jetpack_prototype_build
228228
# -----------------------------------------------------------------------------------
229-
# Build a Jetpack Prototype Build and make it available for download
229+
# Build a Jetpack Prototype Build and upload it to Firebase App Distribution
230230
# -----------------------------------------------------------------------------------
231231
# Usage:
232232
# bundle exec fastlane build_and_upload_jetpack_prototype_build
233233
#####################################################################################
234-
desc 'Build a Jetpack Prototype Build and make it available for download'
234+
desc 'Build a Jetpack Prototype Build and upload it to Firebase App Distribution'
235235
lane :build_and_upload_jetpack_prototype_build do
236-
UI.user_error!("'BUILDKITE_ARTIFACTS_S3_BUCKET' must be defined as an environment variable.") unless ENV['BUILDKITE_ARTIFACTS_S3_BUCKET']
236+
UI.user_error!("'FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY' must be defined as an environment variable.") unless ENV['FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY']
237237

238238
version_name = generate_prototype_build_number
239239
gradle(
@@ -243,7 +243,7 @@
243243
properties: { prototypeBuildVersionName: version_name }
244244
)
245245

246-
upload_prototype_build(product: 'Jetpack', version_name: version_name)
246+
upload_prototype_build(app: :jetpack, version_name: version_name)
247247
upload_gutenberg_sourcemaps(app: 'Jetpack', release_version: version_name)
248248
end
249249

@@ -310,44 +310,87 @@
310310
"#{build_dir}#{name}"
311311
end
312312

313-
# Uploads the apk built by the `gradle` (i.e. `SharedValues::GRADLE_APK_OUTPUT_PATH`) to S3 then comment on the PR to provide the download link
313+
# Uploads the APK built by `gradle` to Firebase App Distribution and comments on the PR
314314
#
315-
# @param [String] product the display name of the app to upload to S3. 'WordPress' or 'Jetpack'
315+
# @param [Symbol] app the app identifier (:wordpress or :jetpack)
316+
# @param [String] version_name the version name for the build
316317
#
317-
def upload_prototype_build(product:, version_name:)
318-
filename = "#{product.downcase}-prototype-build-#{version_name}.apk"
319-
320-
upload_path = upload_to_s3(
321-
bucket: 'a8c-apps-public-artifacts',
322-
key: filename,
323-
file: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
324-
if_exists: :skip
318+
def upload_prototype_build(app:, version_name:)
319+
app_specific_values = APP_SPECIFIC_VALUES[app]
320+
app_display_name = app_specific_values[:display_name]
321+
firebase_settings = app_specific_values[:firebase]
322+
323+
release_notes = <<~NOTES
324+
App: #{app_display_name} Android
325+
Branch: `#{ENV.fetch('BUILDKITE_BRANCH', 'N/A')}`
326+
Commit: #{ENV.fetch('BUILDKITE_COMMIT', 'N/A')[0, 7]}
327+
Build Type: #{PROTOTYPE_BUILD_TYPE}
328+
Version: #{version_name}
329+
NOTES
330+
331+
firebase_app_distribution(
332+
app: firebase_settings[:app_id],
333+
service_credentials_json_data: ENV.fetch('FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY', nil),
334+
release_notes: release_notes,
335+
groups: firebase_settings[:testers_group]
325336
)
326337

327-
return if ENV['BUILDKITE_PULL_REQUEST'].nil?
338+
return unless is_ci
328339

329-
install_url = "#{PROTOTYPE_BUILD_DOMAIN}/#{upload_path}"
330-
comment_body = prototype_build_details_comment(
331-
app_display_name: product,
332-
app_icon: ":#{product.downcase}:", # Use Buildkite emoji based on product name
333-
download_url: install_url,
334-
metadata: { Flavor: PROTOTYPE_BUILD_FLAVOR, 'Build Type': PROTOTYPE_BUILD_TYPE, Version: version_name },
335-
footnote: '<em>Note: Google Login is not supported on these builds.</em>',
336-
fold: true
340+
comment_on_pr_with_prototype_build_install_link(
341+
project: GITHUB_REPO,
342+
app_display_name: "#{app_display_name} Android",
343+
app_icon: ":#{app}:",
344+
metadata: {
345+
Flavor: PROTOTYPE_BUILD_FLAVOR,
346+
'Build Type': PROTOTYPE_BUILD_TYPE,
347+
Version: version_name
348+
}
337349
)
338350

351+
annotate_ci_build_with_prototype_build_install_link(app_display_name: app_display_name)
352+
end
353+
354+
# Adds an install link for prototype build via PR comment
355+
#
356+
# @param [String] project the GitHub repository (e.g., 'wordpress-mobile/WordPress-Android')
357+
# @param [String] app_display_name the display name of the app (e.g., 'WordPress Android')
358+
# @param [String] app_icon the Buildkite emoji for the app (e.g., ':wordpress:')
359+
# @param [Hash] metadata additional metadata to display in the comment
360+
#
361+
def comment_on_pr_with_prototype_build_install_link(project:, app_display_name:, app_icon: nil, metadata: {})
362+
pr_number = ENV.fetch('BUILDKITE_PULL_REQUEST', nil)
363+
return unless pr_number && pr_number != 'false'
364+
339365
comment_on_pr(
340-
project: GITHUB_REPO,
341-
pr_number: Integer(ENV.fetch('BUILDKITE_PULL_REQUEST', nil)),
342-
reuse_identifier: "#{product.downcase}-prototype-build-link",
343-
body: comment_body
366+
project: project,
367+
pr_number: Integer(pr_number),
368+
reuse_identifier: "#{app_display_name.downcase.gsub(' ', '-')}-prototype-build-link",
369+
body: prototype_build_details_comment(
370+
app_display_name: app_display_name,
371+
app_icon: app_icon,
372+
metadata: metadata,
373+
footnote: '<em>Note: Google Login is not supported on these builds.</em>'
374+
)
344375
)
376+
end
345377

378+
# If running in Buildkite, annotates the current build with prototype build info
379+
#
380+
# @param [String] app_display_name the display name of the app
381+
#
382+
def annotate_ci_build_with_prototype_build_install_link(app_display_name:)
346383
return unless ENV['BUILDKITE']
347384

348-
message = "#{product} Prototype Build: [#{filename}](#{install_url})"
349-
buildkite_annotate(style: 'info', context: "prototype-build-#{product}", message: message)
350-
buildkite_metadata(set: { versionName: version_name, 'build:flavor': PROTOTYPE_BUILD_FLAVOR, 'build:type': PROTOTYPE_BUILD_TYPE })
385+
install_link = 'Firebase App Distribution'
386+
install_url = lane_context[SharedValues::FIREBASE_APP_DISTRO_RELEASE]&.dig(:testingUri)
387+
install_link = "[#{install_link}](#{install_url})" unless install_url.nil?
388+
389+
buildkite_annotate(
390+
style: 'success',
391+
context: "prototype-build-#{app_display_name.downcase.gsub(' ', '-')}",
392+
message: "#{app_display_name} Prototype Build uploaded to #{install_link}"
393+
)
351394
end
352395

353396
# This function is Buildkite-specific

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ kotlinx-coroutines = '1.10.2'
8989
kotlinx-kover = '0.9.4'
9090
ksp = '2.2.10-2.0.2'
9191
mockito-android = '5.21.0'
92-
mockito-kotlin = '6.2.2'
92+
mockito-kotlin = '6.2.3'
9393
mpandroidchart = 'v3.1.0'
9494
photoview = '2.3.0'
9595
robolectric = '4.16.1'

0 commit comments

Comments
 (0)