From cb5d3ec5be8c8906aefd02bbfdc44f945290e5b1 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Tue, 4 Jun 2019 17:08:21 -0700 Subject: [PATCH 01/17] WIP: Add fastlane support for mapping explicitly. --- fastlane/Fastfile | 4 +- .../actions/appcenter_upload_action.rb | 53 ++++++++++++++++++- .../appcenter/helper/appcenter_helper.rb | 1 + 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 39d2c38..502e792 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -139,10 +139,10 @@ lane :test do owner_name: ENV["TEST_APPCENTER_OWNER_NAME"], app_name: "MyApplication", apk: "./fastlane/app-release.apk", - upload_dsym_only: true, + upload_mapping_only: true, build_number: "3", version: "1.0.0", - dsym: "./fastlane/mapping.txt", + mapping: "./fastlane/mapping.txt", notify_testers: false ) end diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index de297ba..ee70052 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -62,6 +62,29 @@ module Fastlane end end + # TODO: Discuss converting internal functions to create_symbol_upload rather than create_dsym_upload and pass mapping as first-class option + # def self.run_mapping_upload(params) + # values = params.values + # api_token = params[:api_token] + # owner_name = params[:owner_name] + # app_name = params[:app_name] + # file = params[:ipa] + # dsym = params[:dsym] + # build_number = params[:build_number] + # version = params[:version] + + # file_name = File.basename(dsym_path) + # dsym_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file_name ,build_number, version) + + # if dsym_upload_details + # symbol_upload_id = dsym_upload_details['symbol_upload_id'] + # upload_url = dsym_upload_details['upload_url'] + + # UI.message("Uploading dSYM...") + # Helper::AppcenterHelper.upload_dsym(api_token, owner_name, app_name, dsym_path, symbol_upload_id, upload_url) + # end + # end + # run whole upload process for release def self.run_release_upload(params) values = params.values @@ -158,11 +181,13 @@ module Fastlane def self.run(params) values = params.values upload_dsym_only = params[:upload_dsym_only] + upload_mapping_only = params[:upload_mapping_only] # if app found or successfully created if self.get_or_create_app(params) - self.run_release_upload(params) unless upload_dsym_only - self.run_dsym_upload(params) + self.run_release_upload(params) unless upload_dsym_only or unless upload_mapping_only + self.run_dsym_upload(params) when upload_dsym_only = true + self.run_mapping_upload(params) when upload_mapping_only = true end return values if Helper.test? @@ -246,8 +271,10 @@ module Fastlane optional: true, type: String, verify_block: proc do |value| + deprecated_files = ["mapping.txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) + UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") when deprecated_files.include? File.name(value) end end), @@ -258,6 +285,27 @@ module Fastlane is_string: false, default_value: false), + FastlaneCore::ConfigItem.new(key: :mapping, + env_name: "APPCENTER_DISTRIBUTE_ANDROID_MAPPING", + description: "Path to your Android Proguard or R8 mapping.txt", + default_value: Actions.lane_context[SharedValues::MAPPING_OUTPUT_PATH], + optional: true, + type: String, + verify_block: proc do |value| + accepted_formats = ["mapping.txt"] + if value + UI.user_error!("Couldn't find mapping.txt at path '#{value}'") unless File.exist?(value) + UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.name(value) + end + end), + + FastlaneCore::ConfigItem.new(key: :upload_mapping_only, + env_name: "APPCENTER_DISTRIBUTE_UPLOAD_ANDROID_MAPPING_ONLY", + description: "Flag to upload only the mapping.txt file to App Center", + optional: true, + is_string: false, + default_value: false), + FastlaneCore::ConfigItem.new(key: :group, env_name: "APPCENTER_DISTRIBUTE_GROUP", description: "Comma separated list of Distribution Group names", @@ -354,6 +402,7 @@ module Fastlane apk: "./app-release.apk", destinations: "Testers", destination_type: "group", + mapping: "./mapping.txt", release_notes: "release notes", notify_testers: false )', diff --git a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb index d683c36..0da666a 100644 --- a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb +++ b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb @@ -146,6 +146,7 @@ module Fastlane end end + # TODO: Convert this to more generic upload_symbol and support Android mapping as first-class citizens # upload dSYM files to specified upload url # if succeed, then commits the upload # otherwise aborts From 8531dcd18af6366b964e6b6a91cf728e6b045811 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Wed, 5 Jun 2019 15:56:56 -0700 Subject: [PATCH 02/17] Make helper functions for uploading symbols more generic. --- .../actions/appcenter_upload_action.rb | 44 +++++++++---------- .../appcenter/helper/appcenter_helper.rb | 26 ++++++----- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index ee70052..5c9591f 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -45,6 +45,7 @@ module Fastlane UI.message("Starting dSYM upload...") + # TODO: this should eventually be removed once we have warned of deprecation for long enough if File.extname(dsym_path) == ".txt" file_name = File.basename(dsym_path) dsym_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file_name ,build_number, version) @@ -57,33 +58,32 @@ module Fastlane upload_url = dsym_upload_details['upload_url'] UI.message("Uploading dSYM...") - Helper::AppcenterHelper.upload_dsym(api_token, owner_name, app_name, dsym_path, symbol_upload_id, upload_url) + Helper::AppcenterHelper.upload_symbol(api_token, owner_name, app_name, dsym_path, "Apple", symbol_upload_id, upload_url) end end end - # TODO: Discuss converting internal functions to create_symbol_upload rather than create_dsym_upload and pass mapping as first-class option - # def self.run_mapping_upload(params) - # values = params.values - # api_token = params[:api_token] - # owner_name = params[:owner_name] - # app_name = params[:app_name] - # file = params[:ipa] - # dsym = params[:dsym] - # build_number = params[:build_number] - # version = params[:version] + def self.run_mapping_upload(params) + values = params.values + api_token = params[:api_token] + owner_name = params[:owner_name] + app_name = params[:app_name] + file = params[:apk] + mapping = params[:mapping] + build_number = params[:build_number] + version = params[:version] - # file_name = File.basename(dsym_path) - # dsym_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file_name ,build_number, version) + UI.message("Starting mapping upload...") + symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file, build_number, version) - # if dsym_upload_details - # symbol_upload_id = dsym_upload_details['symbol_upload_id'] - # upload_url = dsym_upload_details['upload_url'] + if symbol_upload_details + symbol_upload_id = symbol_upload_details['symbol_upload_id'] + upload_url = symbol_upload_details['upload_url'] - # UI.message("Uploading dSYM...") - # Helper::AppcenterHelper.upload_dsym(api_token, owner_name, app_name, dsym_path, symbol_upload_id, upload_url) - # end - # end + UI.message("Uploading mapping...") + Helper::AppcenterHelper.upload_symbol(api_token, owner_name, app_name, mapping, symbol_upload_id, upload_url) + end + end # run whole upload process for release def self.run_release_upload(params) @@ -186,8 +186,8 @@ module Fastlane # if app found or successfully created if self.get_or_create_app(params) self.run_release_upload(params) unless upload_dsym_only or unless upload_mapping_only - self.run_dsym_upload(params) when upload_dsym_only = true - self.run_mapping_upload(params) when upload_mapping_only = true + self.run_dsym_upload(params) if (upload_dsym_only == true) + self.run_mapping_upload(params) if (upload_mapping_only == true) end return values if Helper.test? diff --git a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb index 0da666a..b81542d 100644 --- a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb +++ b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb @@ -123,8 +123,8 @@ module Fastlane end end - # committs or aborts dsym upload - def self.update_dsym_upload(api_token, owner_name, app_name, symbol_upload_id, status) + # committs or aborts symbol upload + def self.update_symbol_upload(api_token, owner_name, app_name, symbol_upload_id, status) connection = self.connection response = connection.patch do |req| @@ -146,28 +146,30 @@ module Fastlane end end - # TODO: Convert this to more generic upload_symbol and support Android mapping as first-class citizens - # upload dSYM files to specified upload url + # upload symbol (dSYM or mapping) files to specified upload url # if succeed, then commits the upload # otherwise aborts - def self.upload_dsym(api_token, owner_name, app_name, dsym, symbol_upload_id, upload_url) + def self.upload_symbol(api_token, owner_name, app_name, symbol, symbol_type, symbol_upload_id, upload_url) connection = self.connection(upload_url, true) response = connection.put do |req| req.headers['x-ms-blob-type'] = "BlockBlob" - req.headers['Content-Length'] = File.size(dsym).to_s + req.headers['Content-Length'] = File.size(symbol).to_s req.headers['internal-request-source'] = "fastlane" - req.body = Faraday::UploadIO.new(dsym, 'application/octet-stream') if dsym && File.exist?(dsym) + req.body = Faraday::UploadIO.new(symbol, 'application/octet-stream') if symbol && File.exist?(symbol) end + logType = "dSYM" if (symbol_type == "Apple") + logType = "mapping" if (symbol_type == "Android") + case response.status when 200...300 - self.update_dsym_upload(api_token, owner_name, app_name, symbol_upload_id, 'committed') - UI.success("dSYM uploaded") + self.update_symbol_upload(api_token, owner_name, app_name, symbol_upload_id, 'committed') + UI.success("#{logType} uploaded") else - UI.error("Error uploading dSYM #{response.status}: #{response.body}") - self.update_dsym_upload(api_token, owner_name, app_name, symbol_upload_id, 'aborted') - UI.error("dSYM upload aborted") + UI.error("Error uploading #{logType} #{response.status}: #{response.body}") + self.update_symbol_upload(api_token, owner_name, app_name, symbol_upload_id, 'aborted') + UI.error("#{logType} upload aborted") false end end From dfd15d58bbd7376c6adc9a92a12c410f8b9c88a3 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Wed, 5 Jun 2019 17:04:36 -0700 Subject: [PATCH 03/17] fix syntax errors --- README.md | 4 +++- .../plugin/appcenter/actions/appcenter_upload_action.rb | 8 ++++---- lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f3230bd..5a26994 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,10 @@ The action parameters `api_token` and `owner_name` can also be omitted when thei - `APPCENTER_APP_NAME` - App name. If there is no app with such name, you will be prompted to create one - `APPCENTER_DISTRIBUTE_APK` - Build release path for android build - `APPCENTER_DISTRIBUTE_IPA` - Build release path for ios build -- `APPCENTER_DISTRIBUTE_DSYM` - Path to your symbols file. For iOS provide path to app.dSYM.zip +- `APPCENTER_DISTRIBUTE_DSYM` - Path to your symbols (app.dSYM.zip) file - `APPCENTER_DISTRIBUTE_UPLOAD_DSYM_ONLY` - Flag to upload only the dSYM file to App Center +- `APPCENTER_DISTRIBUTE_MAPPING` - Path to your Android mapping.txt file +- `APPCENTER_DISTRIBUTE_UPLOAD_MAPPING_ONLY` - Flag to upload only the mapping file to App Center - `APPCENTER_DISTRIBUTE_DESTINATIONS` - Comma separated list of destination names. Both distribution groups and stores are supported. All names are required to be of the same destination type. Default is `Collaborators`. - `APPCENTER_DISTRIBUTE_DESTINATION_TYPE` - Destination type of distribution destination. `group` and `store` are supported. Default is `group` - `APPCENTER_DISTRIBUTE_MANDATORY_UPDATE` - Require users to update to this release diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 5c9591f..1bea2f5 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -185,9 +185,9 @@ module Fastlane # if app found or successfully created if self.get_or_create_app(params) - self.run_release_upload(params) unless upload_dsym_only or unless upload_mapping_only - self.run_dsym_upload(params) if (upload_dsym_only == true) - self.run_mapping_upload(params) if (upload_mapping_only == true) + self.run_release_upload(params) unless upload_dsym_only unless upload_mapping_only + self.run_dsym_upload(params) if upload_dsym_only + self.run_mapping_upload(params) if upload_mapping_only end return values if Helper.test? @@ -274,7 +274,7 @@ module Fastlane deprecated_files = ["mapping.txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) - UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") when deprecated_files.include? File.name(value) + UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") if (deprecated_files.include? File.name(value)) end end), diff --git a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb index b81542d..837e419 100644 --- a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb +++ b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb @@ -3,6 +3,7 @@ module Fastlane class AppcenterHelper # create request + # TODO: handle dsym vs mapping def self.connection(upload_url = false, dsym = false) require 'faraday' require 'faraday_middleware' From 4f2e96df1784db3ab9219f24a5bbb5e3f1fc5e38 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Thu, 6 Jun 2019 08:50:38 -0700 Subject: [PATCH 04/17] Fix incorrect ruby function call. --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 1bea2f5..4cf4725 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -81,7 +81,7 @@ module Fastlane upload_url = symbol_upload_details['upload_url'] UI.message("Uploading mapping...") - Helper::AppcenterHelper.upload_symbol(api_token, owner_name, app_name, mapping, symbol_upload_id, upload_url) + Helper::AppcenterHelper.upload_symbol(api_token, owner_name, app_name, mapping, "Android", symbol_upload_id, upload_url) end end @@ -274,7 +274,7 @@ module Fastlane deprecated_files = ["mapping.txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) - UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") if (deprecated_files.include? File.name(value)) + UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") if deprecated_files.include? File.basename(value) end end), @@ -288,14 +288,13 @@ module Fastlane FastlaneCore::ConfigItem.new(key: :mapping, env_name: "APPCENTER_DISTRIBUTE_ANDROID_MAPPING", description: "Path to your Android Proguard or R8 mapping.txt", - default_value: Actions.lane_context[SharedValues::MAPPING_OUTPUT_PATH], optional: true, type: String, verify_block: proc do |value| accepted_formats = ["mapping.txt"] if value UI.user_error!("Couldn't find mapping.txt at path '#{value}'") unless File.exist?(value) - UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.name(value) + UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.basename(value) end end), From 69a9013ede928dca7f5c2ded14d54d054318bdd3 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Thu, 6 Jun 2019 09:11:25 -0700 Subject: [PATCH 05/17] Remove unnecessary conditionals for symbol uploads. --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 4cf4725..92ebd5b 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -73,6 +73,10 @@ module Fastlane build_number = params[:build_number] version = params[:version] + if mapping == nil + return + end + UI.message("Starting mapping upload...") symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file, build_number, version) @@ -186,8 +190,8 @@ module Fastlane # if app found or successfully created if self.get_or_create_app(params) self.run_release_upload(params) unless upload_dsym_only unless upload_mapping_only - self.run_dsym_upload(params) if upload_dsym_only - self.run_mapping_upload(params) if upload_mapping_only + self.run_dsym_upload(params) + self.run_mapping_upload(params) end return values if Helper.test? From 343f2328445e9454e00a437df3b62526b0d78b40 Mon Sep 17 00:00:00 2001 From: Bryan Smith Date: Thu, 6 Jun 2019 09:12:37 -0700 Subject: [PATCH 06/17] Update deprecation message. --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 92ebd5b..95c4c09 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -278,7 +278,7 @@ module Fastlane deprecated_files = ["mapping.txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) - UI.message("Support for mapping.txt has been deprecated. Please use APPCENTER_DISTRIBUTE_ANDROID_MAPPING instead.") if deprecated_files.include? File.basename(value) + UI.message("Support for mapping.txt has been deprecated. Please use --mapping parameter or APPCENTER_DISTRIBUTE_ANDROID_MAPPING environment variable instead.") if deprecated_files.include? File.basename(value) end end), From 9e4721ff8c6cd157ca93f0f0b8e50382b0b596e3 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 09:24:40 -0700 Subject: [PATCH 07/17] Restrict only to .txt files --- .../appcenter/actions/appcenter_upload_action.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 95c4c09..3f9833c 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -78,7 +78,7 @@ module Fastlane end UI.message("Starting mapping upload...") - symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, file, build_number, version) + symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, mapping, build_number, version) if symbol_upload_details symbol_upload_id = symbol_upload_details['symbol_upload_id'] @@ -275,10 +275,10 @@ module Fastlane optional: true, type: String, verify_block: proc do |value| - deprecated_files = ["mapping.txt"] + deprecated_files = [".txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) - UI.message("Support for mapping.txt has been deprecated. Please use --mapping parameter or APPCENTER_DISTRIBUTE_ANDROID_MAPPING environment variable instead.") if deprecated_files.include? File.basename(value) + UI.message("Support for mapping.txt has been deprecated. Please use --mapping parameter or APPCENTER_DISTRIBUTE_ANDROID_MAPPING environment variable instead.") if deprecated_files.include? File.extname(value) end end), @@ -295,10 +295,10 @@ module Fastlane optional: true, type: String, verify_block: proc do |value| - accepted_formats = ["mapping.txt"] + accepted_formats = [".txt"] if value UI.user_error!("Couldn't find mapping.txt at path '#{value}'") unless File.exist?(value) - UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.basename(value) + UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.extname(value) end end), From 497087f2392189d534051e4eb59a7c261594b757 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 09:46:09 -0700 Subject: [PATCH 08/17] use proper file name --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 3f9833c..1177fa0 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -78,7 +78,8 @@ module Fastlane end UI.message("Starting mapping upload...") - symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, mapping, build_number, version) + mapping_name = File.basename(mapping) + symbol_upload_details = Helper::AppcenterHelper.create_mapping_upload(api_token, owner_name, app_name, mapping_name, build_number, version) if symbol_upload_details symbol_upload_id = symbol_upload_details['symbol_upload_id'] From ff98cf17762b6b01a4eee716dc35fb2f7211711e Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:04:52 -0700 Subject: [PATCH 09/17] add android mapping tests --- spec/appcenter_upload_spec.rb | 98 +++++++++++++++++++++++ spec/fixtures/symbols/mapping.txt | 0 spec/fixtures/symbols/renamed-mapping.txt | 0 3 files changed, 98 insertions(+) create mode 100644 spec/fixtures/symbols/mapping.txt create mode 100644 spec/fixtures/symbols/renamed-mapping.txt diff --git a/spec/appcenter_upload_spec.rb b/spec/appcenter_upload_spec.rb index 1d418bc..537b23a 100644 --- a/spec/appcenter_upload_spec.rb +++ b/spec/appcenter_upload_spec.rb @@ -35,6 +35,16 @@ def stub_create_dsym_upload(status) ) end +def stub_create_mapping_upload(status, version, build, file_name = "mapping.txt") + stub_request(:post, "https://api.appcenter.ms/v0.1/apps/owner/app/symbol_uploads") + .with(body: "{\"symbol_type\":\"AndroidProguard\",\"file_name\":\"#{file_name}\",\"build\":\"3\",\"version\":\"1.0.0\"}",) + .to_return( + status: status, + body: "", + headers: { 'Content-Type' => 'application/json' } + ) +end + def stub_upload_build(status) stub_request(:post, "https://upload.com/") .to_return(status: status, body: "", headers: {}) @@ -45,6 +55,11 @@ def stub_upload_dsym(status) .to_return(status: status, body: "", headers: {}) end +def stub_upload_mapping(status) + stub_request(:put, "https://upload_dsym.com/") + .to_return(status: status, body: "", headers: {}) +end + def stub_update_release_upload(status, release_status) stub_request(:patch, "https://api.appcenter.ms/v0.1/apps/owner/app/release_uploads/upload_id") .with( @@ -61,6 +76,14 @@ def stub_update_dsym_upload(status, release_status) .to_return(status: status, body: "{\"release_id\":\"1\"}", headers: { 'Content-Type' => 'application/json' }) end +def stub_update_mapping_upload(status, release_status) + stub_request(:patch, "https://api.appcenter.ms/v0.1/apps/owner/app/symbol_uploads/symbol_upload_id") + .with( + body: "{\"status\":\"#{release_status}\"}" + ) + .to_return(status: status, body: "{\"release_id\":\"1\"}", headers: { 'Content-Type' => 'application/json' }) +end + def stub_get_destination(status, destination_type = "group", destination_name = "Testers") stub_request(:get, "https://api.appcenter.ms/v0.1/apps/owner/app/distribution_#{destination_type}s/#{destination_name}") .to_return(status: status, body: "{\"id\":\"1\"}", headers: { 'Content-Type' => 'application/json' }) @@ -717,6 +740,81 @@ describe Fastlane::Actions::AppcenterUploadAction do end").runner.execute(:test) end + it "allows to send android mappings" do + stub_check_app(200) + stub_create_release_upload(200) + stub_upload_build(200) + stub_update_release_upload(200, 'committed') + stub_update_release(200) + stub_get_destination(200) + stub_add_to_destination(200) + stub_get_release(200) + stub_create_mapping_upload(200, "1.0.0", "3") + stub_upload_mapping(200) + stub_update_mapping_upload(200, "committed") + + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + apk: './spec/fixtures/appfiles/apk_file_empty.apk', + mapping: './spec/fixtures/symbols/mapping.txt', + build_number: '3', + version: '1.0.0', + destinations: 'Testers', + destination_type: 'group' + }) + end").runner.execute(:test) + end + + it "allows to send android mappings with custom name" do + stub_check_app(200) + stub_create_release_upload(200) + stub_upload_build(200) + stub_update_release_upload(200, 'committed') + stub_update_release(200) + stub_get_destination(200) + stub_add_to_destination(200) + stub_get_release(200) + stub_create_mapping_upload(200, "1.0.0", "3", "renamed-mapping.txt") + stub_upload_mapping(200) + stub_update_mapping_upload(200, "committed") + + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + apk: './spec/fixtures/appfiles/apk_file_empty.apk', + mapping: './spec/fixtures/symbols/renamed-mapping.txt', + build_number: '3', + version: '1.0.0', + destinations: 'Testers', + destination_type: 'group' + }) + end").runner.execute(:test) + end + + it "allows to send only android mappings" do + stub_check_app(200) + stub_create_mapping_upload(200, "1.0.0", "3", "renamed-mapping.txt") + stub_upload_mapping(200) + stub_update_mapping_upload(200, "committed") + + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + upload_mapping_only: true, + mapping: './spec/fixtures/symbols/renamed-mapping.txt', + build_number: '3', + version: '1.0.0' + }) + end").runner.execute(:test) + end + it "zips dSYM files if dsym parameter is folder" do stub_check_app(200) stub_create_release_upload(200) diff --git a/spec/fixtures/symbols/mapping.txt b/spec/fixtures/symbols/mapping.txt new file mode 100644 index 0000000..e69de29 diff --git a/spec/fixtures/symbols/renamed-mapping.txt b/spec/fixtures/symbols/renamed-mapping.txt new file mode 100644 index 0000000..e69de29 From dee743c2330566cfdb9917fed0cd29f6b180bfaa Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:05:30 -0700 Subject: [PATCH 10/17] fix android example --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 1177fa0..1ce4237 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -406,6 +406,8 @@ module Fastlane apk: "./app-release.apk", destinations: "Testers", destination_type: "group", + build_number: "3", + version: "1.0.0", mapping: "./mapping.txt", release_notes: "release notes", notify_testers: false From 4daea401f600f96b67fedb50baf2eaa83af25046 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:10:34 -0700 Subject: [PATCH 11/17] fix description --- README.md | 4 ++-- .../plugin/appcenter/actions/appcenter_upload_action.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5a26994..9399986 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ The action parameters `api_token` and `owner_name` can also be omitted when thei - `APPCENTER_DISTRIBUTE_IPA` - Build release path for ios build - `APPCENTER_DISTRIBUTE_DSYM` - Path to your symbols (app.dSYM.zip) file - `APPCENTER_DISTRIBUTE_UPLOAD_DSYM_ONLY` - Flag to upload only the dSYM file to App Center -- `APPCENTER_DISTRIBUTE_MAPPING` - Path to your Android mapping.txt file -- `APPCENTER_DISTRIBUTE_UPLOAD_MAPPING_ONLY` - Flag to upload only the mapping file to App Center +- `APPCENTER_DISTRIBUTE_ANDROID_MAPPING` - Path to your Android mapping.txt file +- `APPCENTER_DISTRIBUTE_UPLOAD_ANDROID_MAPPING_ONLY` - Flag to upload only the mapping file to App Center - `APPCENTER_DISTRIBUTE_DESTINATIONS` - Comma separated list of destination names. Both distribution groups and stores are supported. All names are required to be of the same destination type. Default is `Collaborators`. - `APPCENTER_DISTRIBUTE_DESTINATION_TYPE` - Destination type of distribution destination. `group` and `store` are supported. Default is `group` - `APPCENTER_DISTRIBUTE_MANDATORY_UPDATE` - Require users to update to this release diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 1ce4237..4673988 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -292,7 +292,7 @@ module Fastlane FastlaneCore::ConfigItem.new(key: :mapping, env_name: "APPCENTER_DISTRIBUTE_ANDROID_MAPPING", - description: "Path to your Android Proguard or R8 mapping.txt", + description: "Path to your Android mapping.txt", optional: true, type: String, verify_block: proc do |value| From c03e042beea35c06d25f9bbd57f26080632f1325 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:19:09 -0700 Subject: [PATCH 12/17] update strings --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 4673988..b2129a3 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -279,7 +279,7 @@ module Fastlane deprecated_files = [".txt"] if value UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) - UI.message("Support for mapping.txt has been deprecated. Please use --mapping parameter or APPCENTER_DISTRIBUTE_ANDROID_MAPPING environment variable instead.") if deprecated_files.include? File.extname(value) + UI.message("Support for *.txt has been deprecated. Please use --mapping parameter or APPCENTER_DISTRIBUTE_ANDROID_MAPPING environment variable instead.") if deprecated_files.include? File.extname(value) end end), @@ -298,8 +298,8 @@ module Fastlane verify_block: proc do |value| accepted_formats = [".txt"] if value - UI.user_error!("Couldn't find mapping.txt at path '#{value}'") unless File.exist?(value) - UI.user_error!("Only \"mapping.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.extname(value) + UI.user_error!("Couldn't find mapping file at path '#{value}'") unless File.exist?(value) + UI.user_error!("Only \"*.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.extname(value) end end), From 22e939cf9ece36f36edc6e96083929e9c058758a Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:33:06 -0700 Subject: [PATCH 13/17] remove unused parameter --- lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index b2129a3..fd3ee0c 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -68,7 +68,6 @@ module Fastlane api_token = params[:api_token] owner_name = params[:owner_name] app_name = params[:app_name] - file = params[:apk] mapping = params[:mapping] build_number = params[:build_number] version = params[:version] From 1e423589b6134d56073225261cfe8493f8f56ef5 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:35:13 -0700 Subject: [PATCH 14/17] unify error message --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index fd3ee0c..68506d4 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -298,7 +298,7 @@ module Fastlane accepted_formats = [".txt"] if value UI.user_error!("Couldn't find mapping file at path '#{value}'") unless File.exist?(value) - UI.user_error!("Only \"*.txt\" file name is allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.extname(value) + UI.user_error!("Only \"*.txt\" formats are allowed, you provided \"#{File.name(value)}\"") unless accepted_formats.include? File.extname(value) end end), From 1e47946fa8fdc0ec0ddb94d595d668a132ada4e7 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:46:36 -0700 Subject: [PATCH 15/17] add additional checks --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index 68506d4..b0eae4f 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -190,8 +190,8 @@ module Fastlane # if app found or successfully created if self.get_or_create_app(params) self.run_release_upload(params) unless upload_dsym_only unless upload_mapping_only - self.run_dsym_upload(params) - self.run_mapping_upload(params) + self.run_dsym_upload(params) unless upload_mapping_only + self.run_mapping_upload(params) unless upload_dsym_only end return values if Helper.test? From 759c11350e1a2606e6b57b44e5356590157f0641 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 10:50:28 -0700 Subject: [PATCH 16/17] proper unless logic --- .../plugin/appcenter/actions/appcenter_upload_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index b0eae4f..3880375 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -189,7 +189,7 @@ module Fastlane # if app found or successfully created if self.get_or_create_app(params) - self.run_release_upload(params) unless upload_dsym_only unless upload_mapping_only + self.run_release_upload(params) unless upload_dsym_only || upload_mapping_only self.run_dsym_upload(params) unless upload_mapping_only self.run_mapping_upload(params) unless upload_dsym_only end From 302cd3d2fde40ebc2b90fe0c46baacb029ed380b Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 10 Jun 2019 11:10:27 -0700 Subject: [PATCH 17/17] remove comment --- lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb index 837e419..b81542d 100644 --- a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb +++ b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb @@ -3,7 +3,6 @@ module Fastlane class AppcenterHelper # create request - # TODO: handle dsym vs mapping def self.connection(upload_url = false, dsym = false) require 'faraday' require 'faraday_middleware'