From 767d0713bfdee3e225d021187a4d712eb554067e Mon Sep 17 00:00:00 2001 From: Krisztian Godrei Date: Mon, 2 Nov 2015 20:34:44 +0000 Subject: [PATCH 1/3] ipa path fix --- export_ipa.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ step.sh | 14 +++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 export_ipa.rb diff --git a/export_ipa.rb b/export_ipa.rb new file mode 100644 index 00000000..e767fd12 --- /dev/null +++ b/export_ipa.rb @@ -0,0 +1,50 @@ +require 'plist' + +# ----------------------- +# --- functions +# ----------------------- + +def fail_with_message(message) + puts "\e[31m#{message}\e[0m" + exit(1) +end + +# ----------------------- +# --- main +# ----------------------- + +archive_path = ARGV[0] +output_dir = ARGV[1] + +fail_with_message('No archive_path specified') unless archive_path +fail_with_message('No output_dir specified') unless output_dir + +info_plist_path = File.join(archive_path, 'Info.plist') +unless File.exist?(info_plist_path) + puts '(!) No Info.plist found, search for other plist' + info_plist_paths = Dir[archive_path, '*.plist'] + fail_with_message('More then 1 plist found') unless info_plist_paths.nil? || info_plist_paths.count == 1 + + info_plist_path = info_plist_paths.first +end + +fail_with_message('No Info.plist found') unless info_plist_path + +infos = Plist.parse_xml(info_plist_path) +fail_with_message('Failed to read ipa name') if infos.nil? || infos['Name'].nil? + +ipa_name = infos['Name'] +ipa_path = File.join(output_dir, "#{ipa_name}.ipa") +unless File.exist?(ipa_path) + puts "(!) No #{ipa_name}.ipa found, search for other .ipa" + ipa_paths = Dir[output_dir, '*.ipa'] + fail_with_message('More then 1 ipa found') unless ipa_paths.nil? || ipa_paths.count == 1 + + ipa_path = ipa_paths.first +end + +fail_with_message('No ipa found') unless ipa_path +puts " (i) The IPA is now available at: #{ipa_path}" + +system("envman add --key BITRISE_IPA_PATH --value \"#{ipa_path}\"") +puts ' (i) The IPA path is now available in the Environment Variable: $BITRISE_IPA_PATH' diff --git a/step.sh b/step.sh index 9d2a0803..d9427eee 100644 --- a/step.sh +++ b/step.sh @@ -237,9 +237,17 @@ fi set +v set +x -echo " (i) The IPA is now available at: ${ipa_path}" -envman add --key BITRISE_IPA_PATH --value "${ipa_path}" -echo ' (i) The IPA path is now available in the Environment Variable: $BITRISE_IPA_PATH' + +# +# Export *.ipa path +set -x +curr_pwd="$(pwd)" +cd "${THIS_SCRIPT_DIR}" +bundle exec ruby "${THIS_SCRIPT_DIR}/export_ipa.rb" \ + "${archive_path}" \ + "${output_dir}" +cd "${curr_pwd}" +set +x # From 745428856f9f5100f98259b6e9283ba544c5f95f Mon Sep 17 00:00:00 2001 From: Krisztian Godrei Date: Mon, 2 Nov 2015 21:58:18 +0000 Subject: [PATCH 2/3] PR fix --- export_ipa.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/export_ipa.rb b/export_ipa.rb index e767fd12..acb6e8ee 100644 --- a/export_ipa.rb +++ b/export_ipa.rb @@ -20,15 +20,7 @@ def fail_with_message(message) fail_with_message('No output_dir specified') unless output_dir info_plist_path = File.join(archive_path, 'Info.plist') -unless File.exist?(info_plist_path) - puts '(!) No Info.plist found, search for other plist' - info_plist_paths = Dir[archive_path, '*.plist'] - fail_with_message('More then 1 plist found') unless info_plist_paths.nil? || info_plist_paths.count == 1 - - info_plist_path = info_plist_paths.first -end - -fail_with_message('No Info.plist found') unless info_plist_path +fail_with_message('No Info.plist found') unless File.exist?(info_plist_path) infos = Plist.parse_xml(info_plist_path) fail_with_message('Failed to read ipa name') if infos.nil? || infos['Name'].nil? From e4945468a8dfd7d3cb18e110eec262e0f51b6f7c Mon Sep 17 00:00:00 2001 From: Krisztian Godrei Date: Tue, 3 Nov 2015 09:31:38 +0000 Subject: [PATCH 3/3] ipa export fix --- export_ipa.rb | 42 ------------------------------------------ step.sh | 51 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 52 deletions(-) delete mode 100644 export_ipa.rb diff --git a/export_ipa.rb b/export_ipa.rb deleted file mode 100644 index acb6e8ee..00000000 --- a/export_ipa.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'plist' - -# ----------------------- -# --- functions -# ----------------------- - -def fail_with_message(message) - puts "\e[31m#{message}\e[0m" - exit(1) -end - -# ----------------------- -# --- main -# ----------------------- - -archive_path = ARGV[0] -output_dir = ARGV[1] - -fail_with_message('No archive_path specified') unless archive_path -fail_with_message('No output_dir specified') unless output_dir - -info_plist_path = File.join(archive_path, 'Info.plist') -fail_with_message('No Info.plist found') unless File.exist?(info_plist_path) - -infos = Plist.parse_xml(info_plist_path) -fail_with_message('Failed to read ipa name') if infos.nil? || infos['Name'].nil? - -ipa_name = infos['Name'] -ipa_path = File.join(output_dir, "#{ipa_name}.ipa") -unless File.exist?(ipa_path) - puts "(!) No #{ipa_name}.ipa found, search for other .ipa" - ipa_paths = Dir[output_dir, '*.ipa'] - fail_with_message('More then 1 ipa found') unless ipa_paths.nil? || ipa_paths.count == 1 - - ipa_path = ipa_paths.first -end - -fail_with_message('No ipa found') unless ipa_path -puts " (i) The IPA is now available at: #{ipa_path}" - -system("envman add --key BITRISE_IPA_PATH --value \"#{ipa_path}\"") -puts ' (i) The IPA path is now available in the Environment Variable: $BITRISE_IPA_PATH' diff --git a/step.sh b/step.sh index d9427eee..f8e66cd6 100644 --- a/step.sh +++ b/step.sh @@ -228,26 +228,57 @@ else set -x + tmp_dir=$(mktemp -d) + xcodebuild -exportArchive \ -archivePath "${archive_path}" \ - -exportPath "${output_dir}" \ + -exportPath "${tmp_dir}" \ -exportOptionsPlist "${export_options_path}" + + set +x + + # Searching for ipa + exported_ipa_path="" + IFS=$'\n' + for a_file_path in $(find "${tmp_dir}" -maxdepth 1 -mindepth 1) + do + filename=$(basename "$a_file_path") + echo " -> moving file: ${a_file_path} to ${output_dir}" + + mv "${a_file_path}" "${output_dir}" + + regex=".*.ipa" + if [[ "${filename}" =~ $regex ]]; then + if [[ -z "${exported_ipa_path}" ]] ; then + exported_ipa_path="${output_dir}/${filename}" + else + echo " (!) More then ipa file found" + fi + fi + done + unset IFS + + if [[ -z "${exported_ipa_path}" ]] ; then + echo " (!) No ipa file found" + exit 1 + fi + + if [ ! -e "${exported_ipa_path}" ] ; then + echo " (!) Failed to move ipa to output dir" + exit 1 + fi + + ipa_path="${exported_ipa_path}" fi set +v -set +x # # Export *.ipa path -set -x -curr_pwd="$(pwd)" -cd "${THIS_SCRIPT_DIR}" -bundle exec ruby "${THIS_SCRIPT_DIR}/export_ipa.rb" \ - "${archive_path}" \ - "${output_dir}" -cd "${curr_pwd}" -set +x +echo " (i) The IPA is now available at: ${ipa_path}" +envman add --key BITRISE_IPA_PATH --value "${ipa_path}" +echo ' (i) The IPA path is now available in the Environment Variable: $BITRISE_IPA_PATH' #