Skip to content
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

[pilot] ability to upload ipas to Testflight from Linux #22014

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ccaruceru
Copy link
Contributor

@ccaruceru ccaruceru commented May 11, 2024

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

Make Testflight upload work from Linux using Transporter. This requires having Transporter installed on the machine.

Description

Add support for uploading an ipa to App Store Connect via api key when running fastlane pilot from a Linux machine. In order for this to happen, two major changes are needed:

  • adapt the ShellScriptTransporterExecutor (and surrounding code) to support API keys in the upload method
  • add missing information to the generated metadata.xml file in the .itmsp folder so that Transporter's asset validation process passes. This means the -f <.itmsp> argument works without having to use -assetFile <ipa> in combination with the -assetDescription <plist> arguments (which improves users experience on linux).

In this PR:

  • read plist data w/o an intermediate file in IpaFileAnalyser (see CFPropertyList::List.initialize())
    • this was necessary to avoid conflicts while mocking Dir.mktmpdir from existing tests
  • change BuildManager, IpaUploadPackageBuilder and the XMLTemplate.xml.erb to add bundle identifier, short version and bundle version values
  • generate the private key (p8) file in a new TransporterExecutor.prepare method and call that before every execute command to create the file on disk in different places, depending on what kind of executor instance we deal with
    • might not be the best approach, I'm open for suggestions
  • use the api key args in ShellScriptTransporterExecutor.upload and make sure only one of user/pass, jwt or api key is used at any moment
  • avoid prompting the user for user/pass in ItunesTransporter.initialize when api key is not nil
  • add additional test in itunes_transporter_spec.rb and adapt tests in build_manager_spec.rb to use a real ipa and expect new calls and values
  • updated docs with pilot instructions on Linux

Tested on Linux (Debian 12) and MacOS (Sonoma 14).

Testing Steps

FASTLANE_ITUNES_TRANSPORTER_PATH=/usr/local/itms FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT=true [bundle exec] fastlane run pilot ipa:<path-to-my.ipa> api_key_path:<my-app-store-key.json>

- add extra values to XMLTemplate.xml.erb and the IpaUploadPackageBuilder generator to support uploads from Linux
- read straight from plist_data in IpaFileAnalyser
- adapt tests
- update readme
- make sur only 1 of auth args are used in the ShellScriptTransporterExecutor upload command
- prevent ItunesTransporter asking for user input when jwt or api key is present
- add extra test to expect the api key in the shell script command
@ccaruceru
Copy link
Contributor Author

Let me know what are your thoughts on these additional observations and if they should be addressed here, in a follow up PR, or not at all:

  • I added api key support only upload command since that's what fastalne is usually used most for. There are other commands that could be potentially adapted, like download, verify and provider_ids
  • I haven't changed PkgUploadPackageBuilder to write same additional data in metadata.xml like IpaUploadPackageBuilder does

@@ -686,7 +722,7 @@ def initialize(user = nil, password = nil, use_shell_script = false, provider_sh
use_shell_script ||= Helper.windows?
use_shell_script ||= Feature.enabled?('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT')

if jwt.to_s.empty?
if jwt.to_s.empty? && api_key.nil?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can anyone think of any reason to continue asking the user for input when the api key is set?

# as of Transporter v3.3.0, the app is unable to detect the private keys under the 'private_keys' folder in current directory
# so we must rely on the other search paths in the Home dir:
# https://help.apple.com/itc/transporteruserguide/en.lproj/static.html#itc803b7be80
private_keys_dir = File.join(Dir.home, ".appstoreconnect/private_keys")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the docs, a private_keys folder in the current directory SHOULD be supported (and would simplify the cleanup process a lot), but I couldn't make it work on my machine (bug in Transporter?), so I went ahead to use one of the other search paths suggested under $HOME

@ccaruceru ccaruceru changed the title Ability to upload ipas to Testflight from Linux [pilot] ability to upload ipas to Testflight from Linux May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant