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

new "html_in_folder" option #30

Merged
merged 2 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/assets/s3_android_html_template.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Install <%= title %> <%= version_name %> (<%= version_code %>)
</a>
<br>
<p>Built on <%= Date.current.strftime('%a, %e %b %Y %H:%M %p') %></p>
<p>Built on <%= Date.today.strftime('%a, %e %b %Y %H:%M %p') %></p>
</span>

<!-- <span class="download" id="android">
Expand Down
2 changes: 1 addition & 1 deletion lib/assets/s3_ios_html_template.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Install <%= title %> <%= bundle_version %> (<%= build_num %>)
</a>
<br>
<p>Built on <%= Date.current.strftime('%a, %e %b %Y %H:%M %p') %></p>
<p>Built on <%= Date.today.strftime('%a, %e %b %Y %H:%M %p') %></p>
</span>

<!-- <span class="download" id="android">
Expand Down
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