Skip to content

Commit

Permalink
option to move the generated HTML file into the version directory (is…
Browse files Browse the repository at this point in the history
  • Loading branch information
schluete committed Jun 15, 2017
1 parent 4c04ef1 commit e9c406a
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lib/fastlane/plugin/aws_s3/actions/aws_s3_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def self.run(config)
params[:html_template_path] = config[:html_template_path]
params[:html_file_name] = config[:html_file_name]
params[:skip_html_upload] = config[:skip_html_upload]
params[:html_in_folder] = config[:html_in_folder]
params[:version_template_path] = config[:version_template_path]
params[:version_file_name] = config[:version_file_name]

Expand Down Expand Up @@ -87,6 +88,7 @@ def self.upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_acces
plist_file_name = params[:plist_file_name]
html_template_path = params[:html_template_path]
html_file_name = params[:html_file_name]
generate_html_in_folder = params[:html_in_folder]
version_template_path = params[:version_template_path]
version_file_name = params[:version_file_name]

Expand Down Expand Up @@ -202,9 +204,9 @@ def self.upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_acces
# html uploading
#
#####################################

skip_html = params[:skip_html_upload]

html_file_name = "#{url_part}#{html_file_name}" if generate_html_in_folder
html_url = self.upload_file(s3_client, s3_bucket, app_directory, html_file_name, html_render, acl) unless skip_html
version_url = self.upload_file(s3_client, s3_bucket, app_directory, version_file_name, version_render, acl)

Expand All @@ -217,7 +219,7 @@ def self.upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_acces

Actions.lane_context[SharedValues::S3_VERSION_OUTPUT_PATH] = version_url
ENV[SharedValues::S3_VERSION_OUTPUT_PATH.to_s] = version_url

self.upload_source(s3_client, params, s3_bucket, params[:source], s3_path, acl)

UI.success("Successfully uploaded ipa file to '#{Actions.lane_context[SharedValues::S3_IPA_OUTPUT_PATH]}'")
Expand Down Expand Up @@ -300,7 +302,7 @@ def self.upload_apk(s3_client, params, s3_region, s3_access_key, s3_secret_acces
# html and plist uploading
#
#####################################

skip_html = params[:skip_html_upload]

html_url = self.upload_file(s3_client, s3_bucket, app_directory, html_file_name, html_render, acl) unless skip_html
Expand All @@ -313,32 +315,32 @@ def self.upload_apk(s3_client, params, s3_region, s3_access_key, s3_secret_acces
ENV[SharedValues::S3_VERSION_OUTPUT_PATH.to_s] = version_url

self.upload_source(s3_client, params, s3_bucket, params[:source], s3_path, acl)

UI.success("Successfully uploaded apk file to '#{Actions.lane_context[SharedValues::S3_APK_OUTPUT_PATH]}'")
UI.success("Android app can be downloaded at '#{Actions.lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}'") unless skip_html
end

def self.upload_source(s3_client, params, s3_bucket, source_directory, s3_path, acl)
if source_directory && File.directory?(source_directory)
source_directory = File.absolute_path source_directory
output_file_path = Tempfile.new('aws_s3_source').path

output_file_path = other_action.zip(
path: source_directory,
output_path: output_file_path.gsub(/(?<!.zip)$/, ".zip")
)

s3_path = "#{version_code}_#{version_name}/" unless s3_path
app_directory = params[:app_directory]
url_part = s3_path
zip_file_name = "#{url_part}source.zip"

output_path_data = File.open("#{output_file_path}", 'rb')
source_url = self.upload_file(s3_client, s3_bucket, app_directory, zip_file_name, output_path_data, acl)

Actions.lane_context[SharedValues::S3_SOURCE_OUTPUT_PATH] = source_url
ENV[SharedValues::S3_SOURCE_OUTPUT_PATH.to_s] = source_url

UI.success("Source can be downloaded at '#{Actions.lane_context[SharedValues::S3_SOURCE_OUTPUT_PATH]}'")
end
end
Expand Down Expand Up @@ -478,6 +480,12 @@ def self.available_options
optional: true,
default_value: false,
is_string: false),
FastlaneCore::ConfigItem.new(key: :html_in_folder,
env_name: "",
description: "move the uploaded html file into the version folder",
optional: true,
default_value: false,
is_string: false),
FastlaneCore::ConfigItem.new(key: :version_template_path,
env_name: "",
description: "version erb template path",
Expand Down

0 comments on commit e9c406a

Please sign in to comment.