diff --git a/README.md b/README.md index 9399986..11bd677 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ appcenter_upload( api_token: "", owner_name: "", app_name: "", - apk: "", + apk: "", # Or aab: "" for app bundles notify_testers: true # Set to false if you don't want to notify testers of your new release (default: `false`) ) ``` @@ -35,6 +35,7 @@ The action parameters `api_token` and `owner_name` can also be omitted when thei - `APPCENTER_OWNER_NAME` - Owner name - `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_AAB` - Build release path for android app bundle build - `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 diff --git a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb index b157941..f6367cc 100644 --- a/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb +++ b/lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb @@ -117,7 +117,8 @@ module Fastlane file = [ params[:ipa], - params[:apk] + params[:apk], + params[:aab] ].detect { |e| !e.to_s.empty? } UI.user_error!("Couldn't find build file at path '#{file}'") unless file && File.exist?(file) @@ -274,7 +275,7 @@ module Fastlane default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH], optional: true, type: String, - conflicting_options: [:ipa], + conflicting_options: [:ipa, :aab], conflict_block: proc do |value| UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run") end, @@ -283,13 +284,28 @@ module Fastlane UI.user_error!("Only \".apk\" formats are allowed, you provided \"#{File.extname(value)}\"") unless accepted_formats.include? File.extname(value) end), + FastlaneCore::ConfigItem.new(key: :aab, + env_name: "APPCENTER_DISTRIBUTE_AAB", + description: "Build release path for android app bundle build", + default_value: Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH], + optional: true, + type: String, + conflicting_options: [:ipa, :apk], + conflict_block: proc do |value| + UI.user_error!("You can't use 'aab' and '#{value.key}' options in one run") + end, + verify_block: proc do |value| + accepted_formats = [".aab"] + UI.user_error!("Only \".aab\" formats are allowed, you provided \"#{File.extname(value)}\"") unless accepted_formats.include? File.extname(value) + end), + FastlaneCore::ConfigItem.new(key: :ipa, env_name: "APPCENTER_DISTRIBUTE_IPA", description: "Build release path for ios build", default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], optional: true, type: String, - conflicting_options: [:apk], + conflicting_options: [:apk, :aab], conflict_block: proc do |value| UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run") end, @@ -451,6 +467,19 @@ module Fastlane dsym: "./app.dSYM.zip", release_notes: "release notes", notify_testers: false + )', + 'appcenter_upload( + api_token: "...", + owner_name: "appcenter_owner", + app_name: "testing_app", + aab: "./app.aab", + destinations: "Alpha", + destination_type: "store", + build_number: "3", + version: "1.0.0", + mapping: "./mapping.txt", + release_notes: "release notes", + notify_testers: false )' ] end diff --git a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb index 11d96a8..8ba9d08 100644 --- a/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb +++ b/lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb @@ -184,7 +184,7 @@ module Fastlane options = {} options[:upload_id] = upload_id - # ipa field is used both for .apk and .ipa files + # ipa field is used for .apk, .aab and .ipa files options[:ipa] = Faraday::UploadIO.new(file, 'application/octet-stream') if file && File.exist?(file) response = connection.post do |req| diff --git a/lib/fastlane/plugin/appcenter/version.rb b/lib/fastlane/plugin/appcenter/version.rb index ee2d8c3..35d9fd2 100644 --- a/lib/fastlane/plugin/appcenter/version.rb +++ b/lib/fastlane/plugin/appcenter/version.rb @@ -1,5 +1,5 @@ module Fastlane module Appcenter - VERSION = "1.1.0" + VERSION = "1.1.1" end end diff --git a/spec/appcenter_upload_spec.rb b/spec/appcenter_upload_spec.rb index 8df3af5..fc6b5bc 100644 --- a/spec/appcenter_upload_spec.rb +++ b/spec/appcenter_upload_spec.rb @@ -198,6 +198,22 @@ describe Fastlane::Actions::AppcenterUploadAction do end.to raise_error("Couldn't find build file at path './nothing.apk'") end + it "raises an error if given aab was not found" do + expect do + stub_check_app(200) + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + destinations: 'Testers', + destination_type: 'group', + aab: './nothing.aab' + }) + end").runner.execute(:test) + end.to raise_error("Couldn't find build file at path './nothing.aab'") + end + it "raises an error if given ipa was not found" do expect do stub_check_app(200) @@ -229,6 +245,21 @@ describe Fastlane::Actions::AppcenterUploadAction do end.to raise_error("Only \".apk\" formats are allowed, you provided \"\"") end + it "raises an error if given file has invalid extension for aab" do + expect do + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + destinations: 'Testers', + destination_type: 'group', + aab: './spec/fixtures/appfiles/Appfile_empty' + }) + end").runner.execute(:test) + end.to raise_error("Only \".aab\" formats are allowed, you provided \"\"") + end + it "raises an error if given file has invalid extension for ipa" do expect do Fastlane::FastFile.new.parse("lane :test do @@ -260,6 +291,38 @@ describe Fastlane::Actions::AppcenterUploadAction do end.to raise_error("You can't use 'ipa' and 'apk' options in one run") end + it "raises an error if both aab and apk provided" do + expect do + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + destinations: 'Testers', + destination_type: 'group', + aab: './spec/fixtures/appfiles/aab_file_empty.aab', + apk: './spec/fixtures/appfiles/apk_file_empty.apk' + }) + end").runner.execute(:test) + end.to raise_error("You can't use 'aab' and 'apk' options in one run") + end + + it "raises an error if both aab and ipa provided" do + expect do + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + destinations: 'Testers', + destination_type: 'group', + ipa: './spec/fixtures/appfiles/ipa_file_empty.ipa', + apk: './spec/fixtures/appfiles/apk_file_empty.apk' + }) + end").runner.execute(:test) + end.to raise_error("You can't use 'ipa' and 'apk' options in one run") + end + it "raises an error if destination type is not group or store" do expect do Fastlane::FastFile.new.parse("lane :test do @@ -502,7 +565,7 @@ describe Fastlane::Actions::AppcenterUploadAction do stub_create_release_upload(200) stub_upload_build(200) stub_update_release_upload(200, 'committed') - stub_update_release(200) + stub_update_release(200) stub_get_destination(200) stub_add_to_destination(200) stub_get_release(200) @@ -519,12 +582,34 @@ describe Fastlane::Actions::AppcenterUploadAction do end").runner.execute(:test) end + it "works with valid parameters for android app bundle" 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) + + Fastlane::FastFile.new.parse("lane :test do + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + aab: './spec/fixtures/appfiles/aab_file_empty.aab', + destinations: 'Testers', + destination_type: 'group' + }) + end").runner.execute(:test) + end + it "uses GRADLE_APK_OUTPUT_PATH as default for apk" 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_update_release(200) stub_get_destination(200) stub_add_to_destination(200) stub_get_release(200) @@ -544,6 +629,31 @@ describe Fastlane::Actions::AppcenterUploadAction do expect(values[:apk]).to eq('./spec/fixtures/appfiles/apk_file_empty.apk') end + it "uses GRADLE_AAB_OUTPUT_PATH as default for aab" 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) + + values = Fastlane::FastFile.new.parse("lane :test do + Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] = './spec/fixtures/appfiles/aab_file_empty.aab' + + appcenter_upload({ + api_token: 'xxx', + owner_name: 'owner', + app_name: 'app', + destinations: 'Testers', + destination_type: 'group' + }) + end").runner.execute(:test) + + expect(values[:aab]).to eq('./spec/fixtures/appfiles/aab_file_empty.aab') + end + it "uses IPA_OUTPUT_PATH as default for ipa" do stub_check_app(200) stub_create_release_upload(200) diff --git a/spec/fixtures/appfiles/aab_file_empty.aab b/spec/fixtures/appfiles/aab_file_empty.aab new file mode 100644 index 0000000..e69de29