Skip to content

[Tooling] Draft: Upload app metrics #16580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ jobs:
mkdir -p Artifacts
mv WordPress/build/outputs/apk/wordpressJalapeno/debug/org.wordpress.android-wordpress-jalapeno-debug.apk "Artifacts/WordPress-${VERSION_NAME}.apk"
mv WordPress/build/outputs/apk/jetpackJalapeno/debug/org.wordpress.android-jetpack-jalapeno-debug.apk "Artifacts/Jetpack-${VERSION_NAME}.apk"
- run:
name: Send App Size Metrics
command: |
bundle exec fastlane send_installable_build_app_metrics apk:"Artifacts/WordPress-${VERSION_NAME}.apk" app_name:WordPress version_name:"${VERSION_NAME}"
bundle exec fastlane send_installable_build_app_metrics apk:"Artifacts/Jetpack-${VERSION_NAME}.apk" app_name:Jetpack version_name:"${VERSION_NAME}"
- store_artifacts:
path: Artifacts
destination: Artifacts
Expand Down
13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: [email protected]:wordpress-mobile/release-toolkit.git
revision: ee92ff145fa4c2d1782d2b60cacbba97f2c94b54
branch: trunk
remote: [email protected]:wordpress-mobile/release-toolkit
revision: f4d314a91342e6497ccc8f43a47878d5c6f2f061
branch: app-size-metrics+android-universal-apk
specs:
fastlane-plugin-wpmreleasetoolkit (4.1.0)
activesupport (~> 5)
Expand All @@ -14,6 +14,7 @@ GIT
nokogiri (~> 1.11)
octokit (~> 4.18)
parallel (~> 1.14)
plist (~> 3.1)
progress_bar (~> 1.3)
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
Expand All @@ -23,7 +24,7 @@ GEM
specs:
CFPropertyList (3.0.5)
rexml
activesupport (5.2.7.1)
activesupport (5.2.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -198,13 +199,13 @@ GEM
multipart-post (2.0.0)
nanaimo (0.3.0)
naturally (2.2.1)
nokogiri (1.13.4)
nokogiri (1.13.6)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
oj (3.13.11)
oj (3.13.13)
optimist (3.0.1)
options (2.3.2)
optparse (0.1.1)
Expand Down
3 changes: 2 additions & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ group :screenshots, optional: true do
gem 'rmagick', '~> 4.1'
end

gem 'fastlane-plugin-wpmreleasetoolkit', git: '[email protected]:wordpress-mobile/release-toolkit.git', branch: 'trunk'
# gem 'fastlane-plugin-wpmreleasetoolkit', git: '[email protected]:wordpress-mobile/release-toolkit.git', branch: 'trunk'
gem 'fastlane-plugin-wpmreleasetoolkit', git: '[email protected]:wordpress-mobile/release-toolkit', branch: 'app-size-metrics+android-universal-apk'
# gem 'fastlane-plugin-wpmreleasetoolkit', '~> 4.1'
77 changes: 73 additions & 4 deletions fastlane/lanes/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@
# Create the file names
app = get_app_name_option!(options)
version = android_get_release_version()
build_bundle(app: app, version: version, flavor: 'Vanilla', buildType: 'Release')
aab_path = build_bundle(app: app, version: version, flavor: 'Vanilla', buildType: 'Release')

upload_build_to_play_store(app: app, version: version, track: 'production')

create_gh_release(app: app, version: version) if options[:create_release]

android_send_app_size_metrics(
api_url: ENV['APPMETRICS_BASE_URL'] = File.join('file://localhost/', ENV['PROJECT_ROOT_FOLDER'], 'build', "#{app}-app-size-metrics.json"),
use_gzip_content_encoding: false,
app_name: 'WordPress',
app_version_name: version['name'],
app_version_code: version['code'],
product_flavor: 'Vanilla',
build_type: 'Release',
source: 'Final Build',
aab_path: aab_path
)
end

#####################################################################################
Expand Down Expand Up @@ -81,11 +93,23 @@
# Create the file names
app = get_app_name_option!(options)
version = android_get_alpha_version()
build_bundle(app: app, version: version, flavor: 'Zalpha', buildType: 'Release')
aab_path = build_bundle(app: app, version: version, flavor: 'Zalpha', buildType: 'Release')

upload_build_to_play_store(app: app, version: version, track: 'alpha') if options[:upload_to_play_store]

create_gh_release(app: app, version: version, prerelease: true) if options[:create_release]

android_send_app_size_metrics(
api_url: ENV['APPMETRICS_BASE_URL'] = File.join('file://localhost/', ENV['PROJECT_ROOT_FOLDER'], 'build', "#{app}-app-size-metrics.json"),
use_gzip_content_encoding: false,
app_name: 'WordPress',
app_version_name: version['name'],
app_version_code: version['code'],
product_flavor: 'Zalpha',
build_type: 'Release',
source: 'Alpha',
aab_path: aab_path
)
end

#####################################################################################
Expand All @@ -109,11 +133,23 @@
# Create the file names
app = get_app_name_option!(options)
version = android_get_release_version()
build_bundle(app: app, version: version, flavor: 'Vanilla', buildType: 'Release')
aab_path = build_bundle(app: app, version: version, flavor: 'Vanilla', buildType: 'Release')

upload_build_to_play_store(app: app, version: version, track: 'beta') if options[:upload_to_play_store]

create_gh_release(app: app, version: version, prerelease: true) if options[:create_release]

android_send_app_size_metrics(
api_url: ENV['APPMETRICS_BASE_URL'] = File.join('file://localhost/', ENV['PROJECT_ROOT_FOLDER'], 'build', "#{app}-app-size-metrics.json"),
use_gzip_content_encoding: false,
app_name: 'WordPress',
app_version_name: version['name'],
app_version_code: version['code'],
product_flavor: 'Vanilla',
build_type: 'Release',
source: 'Beta',
aab_path: aab_path
)
end

#####################################################################################
Expand All @@ -137,11 +173,23 @@
# Create the file names
app = get_app_name_option!(options)
version = android_get_release_version()
build_bundle(app: app, version: version, flavor: 'Zalpha', buildType: 'Debug')
aab_path = build_bundle(app: app, version: version, flavor: 'Zalpha', buildType: 'Debug')

upload_build_to_play_store(app: app, version: version, track: 'internal') if options[:upload_to_play_store]

create_gh_release(app: app, version: version, prerelease: true) if options[:create_release]

android_send_app_size_metrics(
api_url: ENV['APPMETRICS_BASE_URL'] = File.join('file://localhost/', ENV['PROJECT_ROOT_FOLDER'], 'build', "#{app}-app-size-metrics.json"),
use_gzip_content_encoding: false,
app_name: 'WordPress',
app_version_name: version['name'],
app_version_code: version['code'],
product_flavor: 'Zalpha',
build_type: 'Debug',
source: 'Internal',
aab_path: aab_path
)
end

#####################################################################################
Expand Down Expand Up @@ -262,4 +310,25 @@
end
"#{build_dir}#{name}"
end

# Send Universal APK app size metrics for Installable Builds
# @called_by CI
#
# @option [String,Symbol] apk The path to the Universal APK to send metrics for
# @option [String] app_name The display name of the app to send metrics for. "WordPress" or "Jetpack"
# @option [String] version_name The `versionName` of the APK
#
lane :send_installable_build_app_metrics do |options|
basename = File.basename(options[:apk], '.apk')
android_send_app_size_metrics(
api_url: ENV['APPMETRICS_BASE_URL'] = File.join('file://localhost/', ENV['PROJECT_ROOT_FOLDER'], 'Artifacts', "#{basename}-app-size-metrics.json"),
use_gzip_content_encoding: false,
app_name: options[:app_name],
app_version_name: options[:version_name],
product_flavor: 'Jalapeno',
build_type: 'Debug',
source: 'Installable Build',
universal_apk_path: options[:apk]
)
end
end