Skip to content

Commit

Permalink
Support debug build uploads, auto detect archive path
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsmartin committed Apr 11, 2021
1 parent 04fe6d5 commit 17ace2e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
46 changes: 43 additions & 3 deletions lib/fastlane/plugin/emerge/actions/emerge_action.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,59 @@
require 'fastlane/action'
require 'fastlane_core/print_table'
require_relative '../helper/emerge_helper'
require 'pathname'
require 'tmpdir'
require 'fileutils'

module Fastlane
module Actions
class EmergeAction < Action
def self.run(params)
api_token = params[:api_token]
file_path = params[:file_path]
file_path = params[:file_path] || lane_context[SharedValues::XCODEBUILD_ARCHIVE]

if file_path == nil
file_path = Dir.glob("#{lane_context[SharedValues::SCAN_DERIVED_DATA_PATH]}/Build/Products/Debug-iphonesimulator/*.app").first
end
pr_number = params[:pr_number]
build_id = params[:build_id]
base_build_id = params[:base_build_id]
repo_name = params[:repo_name]
build_type = params[:build_type]
if !File.exist?(file_path) || !File.extname(file_path) == '.zip'

if !File.exist?(file_path)
UI.error("Invalid input file")
return
end

# If the user provided a .app we will look for dsyms and package it into a zipped xcarchive
if File.extname(file_path) == '.app'
absolute_path = Pathname.new(File.expand_path(file_path))
UI.message("A .app was provided, dSYMs will be looked for in #{absolute_path.dirname}")
Dir.mktmpdir do |d|
application_folder = "#{d}/archive.xcarchive/Products/Applications/"
dsym_folder = "#{d}/archive.xcarchive/dSYMs/"
FileUtils.mkdir_p application_folder
FileUtils.mkdir_p dsym_folder
FileUtils.cp_r(file_path, application_folder)
Dir.glob("#{absolute_path.dirname}/*/*.dsym") do |filename|
UI.message("Found dSYM: #{Pathname.new(filename).basename}")
FileUtils.cp_r(filename, dsym_folder)
end
Xcodeproj::Plist.write_to_path({"NAME" => "Emerge Upload"}, "#{d}/archive.xcarchive/Info.plist")
file_path = "#{absolute_path.dirname}/archive.xcarchive.zip"
ZipAction.run(
path: "#{d}/archive.xcarchive",
output_path: file_path)
UI.message("Archive generated at #{file_path}")
end
elsif File.extname(file_path) == '.xcarchive'
zip_path = file_path + ".zip"
Actions::ZipAction.run(
path: file_path,
output_path: zip_path)
file_path = zip_path
elsif !File.extname(file_path) == '.zip'
UI.error("Invalid input file")
return
end
Expand Down Expand Up @@ -85,7 +125,7 @@ def self.available_options
FastlaneCore::ConfigItem.new(key: :file_path,
env_name: "EMERGE_FILE_PATH",
description: "Path to the zipped xcarchive or app to upload",
optional: false,
optional: true,
type: String),
FastlaneCore::ConfigItem.new(key: :pr_number,
description: "The PR number that triggered this upload",
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/emerge/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Emerge
VERSION = "0.1.3"
VERSION = "0.2.0"
end
end

0 comments on commit 17ace2e

Please sign in to comment.