Skip to content

Commit

Permalink
[fastlane_core] fix TransportExecutor to specifically look for ipa, d…
Browse files Browse the repository at this point in the history
…mg, ipa, and zip and not directory for -assetFile and then fall bask to -f (#19620)

* [fastlane_core] fix TransportExecutor to specifically look for ipa, dmg, ipa, and zip and not directory for -assetFile and then fall bask to -f

* Added a way to force ITMSP if needed and added some more tests
  • Loading branch information
joshdholtz committed Nov 17, 2021
1 parent 5dc9f74 commit d5a88ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fastlane_core/lib/fastlane_core/itunes_transporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,13 @@ def parse_line(line, hide_output)
end

def file_upload_option(source)
if File.extname(source) == ".itmsp"
return "-f #{source.shellescape}"
else
ext = File.extname(source).downcase
is_asset_file_type = !File.directory?(source) && [".ipa", ".pkg", ".dmg", ".zip"].include?(ext)

if is_asset_file_type
return "-assetFile #{source.shellescape}"
else
return "-f #{source.shellescape}"
end
end

Expand Down Expand Up @@ -492,7 +495,11 @@ def upload(app_id = nil, dir = nil, package_path: nil, asset_path: nil)
# However, -assetFile requires -assetDescription if Linux or Windows
# This will give the asset directly if macOS and asset_path exists
# otherwise it will use the .itmsp package
actual_dir = if Helper.is_mac? && asset_path

force_itmsp = FastlaneCore::Env.truthy?("ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD")
can_use_asset_path = Helper.is_mac? && asset_path

actual_dir = if can_use_asset_path && !force_itmsp
# The asset gets deleted upon completion so copying to a temp directory
tmp_asset_path = File.join(Dir.tmpdir, File.basename(asset_path))
FileUtils.cp(asset_path, tmp_asset_path)
Expand Down
21 changes: 21 additions & 0 deletions fastlane_core/spec/itunes_transporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,27 @@ def xcrun_download_command(provider_short_name = nil, jwt: nil)
end
end
end

describe "with package_path and asset_path" do
describe "upload command generation" do
it 'generates a call to xcrun iTMSTransporter with -assetFile' do
expect(Dir).to receive(:tmpdir).and_return("/tmp")
expect(FileUtils).to receive(:cp)

transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt)
expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp', asset_path: '/tmp/my_app.ipa')).to eq(java_upload_command(jwt: jwt, use_asset_path: true))
end
end

describe "upload command generation with ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD=true" do
it 'generates a call to xcrun iTMSTransporter with -assetFile' do
stub_const('ENV', { 'ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD' => 'true' })

transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt)
expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp', asset_path: '/tmp/my_app.ipa')).to eq(java_upload_command(jwt: jwt, use_asset_path: false))
end
end
end
end
end

Expand Down

0 comments on commit d5a88ab

Please sign in to comment.