allow destination ids when uploading build (#326)

Co-authored-by: Yves Delcoigne <yves.delcoigne@inthepocket.com>
This commit is contained in:
DelcoigneYves 2023-10-17 09:17:11 +02:00 коммит произвёл GitHub
Родитель b377ca2e2f
Коммит 62e9573afb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 69 добавлений и 1 удалений

Просмотреть файл

@ -9,6 +9,7 @@ module Fastlane
APPCENTER_OWNER_NAME = :APPCENTER_OWNER_NAME
APPCENTER_APP_NAME = :APPCENTER_APP_NAME
APPCENTER_DISTRIBUTE_DESTINATIONS = :APPCENTER_DISTRIBUTE_DESTINATIONS
APPCENTER_DISTRIBUTE_DESTINATION_IDS = :APPCENTER_DISTRIBUTE_DESTINATION_IDS
end
class AppcenterFetchDevicesAction < Action

Просмотреть файл

@ -133,6 +133,7 @@ module Fastlane
owner_type = params[:owner_type]
app_name = params[:app_name]
destinations = params[:destinations]
destination_ids = params[:destination_ids]
destination_type = params[:destination_type]
mandatory_update = params[:mandatory_update]
notify_testers = params[:notify_testers]
@ -172,6 +173,7 @@ module Fastlane
else
self.optional_error("Can't distribute #{file_ext} to stores, please use `destination_type: 'group'`") unless Constants::STORE_SUPPORTED_EXTENSIONS.include? file_ext
UI.user_error!("The combination of `destinations: '*'` and `destination_type: 'store'` is invalid, please use `destination_type: 'group'` or explicitly specify the destinations") if destinations == "*"
UI.user_error!("The combination of `destination_ids` and `destination_type: 'store'` is invalid, please use `destination_type: 'group'` or use `destinations`") unless destination_ids.to_s.strip.empty?
end
release_upload_body = nil
@ -248,7 +250,12 @@ module Fastlane
else
destinations_array = destinations.split(',').map(&:strip)
end
destination_ids_array = []
unless destination_ids.to_s.empty?
destination_ids_array = destination_ids.split(',').map(&:strip)
end
destinations_array.each do |destination_name|
destination = Helper::AppcenterHelper.get_destination(api_token, owner_name, app_name, destination_type, destination_name)
if destination
@ -264,6 +271,17 @@ module Fastlane
end
end
unless destination_ids_array.empty?
destination_ids_array.each do |destination_id|
distributed_release = Helper::AppcenterHelper.add_to_destination(api_token, owner_name, app_name, release_id, destination_type, destination_id, mandatory_update, notify_testers)
if distributed_release
UI.success("Release '#{release_id}' (#{distributed_release['short_version']}) was successfully distributed to #{destination_type} \"#{destination_id}\"")
else
UI.error("Release '#{release_id}' was not found for destination '#{destination_id}'")
end
end
end
safe_download_url = Helper::AppcenterHelper.get_install_url(owner_type, owner_name, app_name)
UI.message("Release '#{release_id}' is available for download at: #{safe_download_url}")
else
@ -582,6 +600,13 @@ module Fastlane
optional: true,
type: String),
FastlaneCore::ConfigItem.new(key: :destination_ids,
env_name: "APPCENTER_DISTRIBUTE_DESTINATION_IDS",
description: "Comma separated list of destination ids, use '00000000-0000-0000-0000-000000000000' for distributing to the Collaborators group. Only distribution groups are supported",
default_value: Actions.lane_context[SharedValues::APPCENTER_DISTRIBUTE_DESTINATION_IDS],
optional: true,
type: String),
FastlaneCore::ConfigItem.new(key: :destination_type,
env_name: "APPCENTER_DISTRIBUTE_DESTINATION_TYPE",
description: "Destination type of distribution destination. 'group' and 'store' are supported",
@ -701,6 +726,17 @@ module Fastlane
release_notes: "release notes",
notify_testers: false
)',
'appcenter_upload(
api_token: "...",
owner_name: "appcenter_owner",
app_name: "testing_ios_app",
file: "./app-release.ipa",
destination_ids: "00000000-0000-0000-0000-000000000000,12341234-1234-1234-1234-123412341234",
destination_type: "group",
dsym: "./app.dSYM.zip",
release_notes: "release notes",
notify_testers: false
)',
'appcenter_upload(
api_token: "...",
owner_name: "appcenter_owner",

Просмотреть файл

@ -2279,6 +2279,37 @@ describe Fastlane::Actions::AppcenterUploadAction do
end.to raise_error("The combination of `destinations: '*'` and `destination_type: 'store'` is invalid, please use `destination_type: 'group'` or explicitly specify the destinations")
end
it "destination_ids for store type" do
expect do
stub_poll_sleeper
stub_check_app(200)
stub_create_release_upload(200)
stub_set_release_upload_metadata(200, "ipa_file_empty.ipa")
stub_upload_build(200)
stub_finish_release_upload(200)
stub_poll_for_release_id(200)
stub_update_release_upload(200, 'uploadFinished')
stub_update_release(200, "No changelog given")
stub_add_to_destination(200)
stub_get_release(200)
stub_create_dsym_upload(200)
stub_upload_dsym(200)
stub_update_dsym_upload(200, "committed")
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
ipa: './spec/fixtures/appfiles/ipa_file_empty.ipa',
dsym: './spec/fixtures/symbols/Themoji.dSYM.zip',
destination_ids: '12341234-1234-1234-1234-123412341234',
destination_type: 'store'
})
end").runner.execute(:test)
end.to raise_error("The combination of `destination_ids` and `destination_type: 'store'` is invalid, please use `destination_type: 'group'` or use `destinations`")
end
it "Handles invalid app name error" do
expect do
Fastlane::FastFile.new.parse("lane :test do