Skip to content

Commit

Permalink
adds support for uploading HTML & version to 'root' as well as versio…
Browse files Browse the repository at this point in the history
…n directories (#51)

Co-authored-by: Josh Holtz <josh@rokkincat.com>
  • Loading branch information
ctaintor and Josh Holtz authored Mar 25, 2021
1 parent c8fb77c commit c466a86
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 9 deletions.
15 changes: 13 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ lane :ipa21 do
ipa: './fastlane/ipa21/BanditTheCat.ipa',
source: './fastlane/ipa21/source',
skip_html_upload: false,
release_notes: 'Hey some notes <br/>And some other notes<br/>And some other'
release_notes: 'Hey some notes <br/>And some other notes<br/>And some other',

# html_in_folder: true,
# html_in_root: true,
#
# version_in_folder: true,
# version_in_root: true,
)
end

Expand All @@ -33,7 +39,12 @@ lane :ipa24 do
bucket: 'fastlane-plugin-s3-ios',
region: 'us-west-1',
ipa: './fastlane/ipa24/BanditTheCat.ipa',
html_in_folder: true

# html_in_folder: true,
# html_in_root: true,
#
# version_in_folder: true,
# version_in_root: true,
)
end

Expand Down
92 changes: 85 additions & 7 deletions lib/fastlane/plugin/aws_s3/actions/aws_s3_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def self.run(config)
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[:html_in_root] = config[:html_in_root]
params[:version_in_folder] = config[:version_in_folder]
params[:version_in_root] = config[:version_in_root]
params[:version_template_path] = config[:version_template_path]
params[:version_file_name] = config[:version_file_name]
params[:version_template_params] = config[:version_template_params]
Expand Down Expand Up @@ -115,6 +118,9 @@ def self.upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_acces
html_template_params = params[:html_template_params] || {}
html_file_name = params[:html_file_name]
generate_html_in_folder = params[:html_in_folder]
generate_html_in_root = params[:html_in_root]
generate_version_in_folder = params[:version_in_folder]
generate_version_in_root = params[:version_in_root]
version_template_path = params[:version_template_path]
version_template_params = params[:version_template_params] || {}
version_file_name = params[:version_file_name]
Expand Down Expand Up @@ -241,9 +247,34 @@ def self.upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_acces
#####################################

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, server_side_encryption, download_endpoint, download_endpoint_replacement_regex) unless skip_html
version_url = self.upload_file(s3_client, s3_bucket, app_directory, version_file_name, version_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)

html_file_names = []
version_file_names = []

unless skip_html
if generate_html_in_root
html_file_names << html_file_name
end
if generate_html_in_folder
html_file_names << "#{url_part}#{html_file_name}"
end
end
if generate_version_in_root
version_file_names << version_file_name
end
if generate_version_in_folder
version_file_names << "#{url_part}#{version_file_name}"
end

html_url = nil
version_url = nil

html_file_names.each do |html_file_name|
html_url = self.upload_file(s3_client, s3_bucket, app_directory, html_file_name, html_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)
end
version_file_names.each do |version_file_name|
version_url = self.upload_file(s3_client, s3_bucket, app_directory, version_file_name, version_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)
end

# Setting action and environment variables
Actions.lane_context[SharedValues::S3_PLIST_OUTPUT_PATH] = plist_url
Expand Down Expand Up @@ -301,6 +332,9 @@ def self.upload_apk(s3_client, params, s3_region, s3_access_key, s3_secret_acces
html_template_params = params[:html_template_params] || {}
html_file_name = params[:html_file_name]
generate_html_in_folder = params[:html_in_folder]
generate_html_in_root = params[:html_in_root]
generate_version_in_folder = params[:version_in_folder]
generate_version_in_root = params[:version_in_root]
version_template_path = params[:version_template_path]
version_template_params = params[:version_template_params] || {}
version_file_name = params[:version_file_name]
Expand Down Expand Up @@ -372,9 +406,35 @@ def self.upload_apk(s3_client, params, s3_region, s3_access_key, s3_secret_acces
#####################################

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, server_side_encryption, download_endpoint, download_endpoint_replacement_regex) unless skip_html
version_url = self.upload_file(s3_client, s3_bucket, app_directory, version_file_name, version_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)

html_file_names = []
version_file_names = []

unless skip_html
if generate_html_in_root
html_file_names << html_file_name
end
if generate_html_in_folder
html_file_names << "#{url_part}#{html_file_name}"
end
end
if generate_version_in_root
version_file_names << version_file_name
end
if generate_version_in_folder
version_file_names << "#{url_part}#{version_file_name}"
end

html_url = nil
version_url = nil

html_file_names.each do |html_file_name|
html_url = self.upload_file(s3_client, s3_bucket, app_directory, html_file_name, html_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)
end

version_file_names do |version_file_name|
version_url = self.upload_file(s3_client, s3_bucket, app_directory, version_file_name, version_render, acl, server_side_encryption, download_endpoint, download_endpoint_replacement_regex)
end

Actions.lane_context[SharedValues::S3_HTML_OUTPUT_PATH] = html_url unless skip_html
ENV[SharedValues::S3_HTML_OUTPUT_PATH.to_s] = html_url unless skip_html
Expand Down Expand Up @@ -625,10 +685,28 @@ def self.available_options
is_string: false),
FastlaneCore::ConfigItem.new(key: :html_in_folder,
env_name: "",
description: "move the uploaded html file into the version folder",
description: "upload the html file into the version folder",
optional: true,
default_value: false,
is_string: false),
FastlaneCore::ConfigItem.new(key: :html_in_root,
env_name: "",
description: "upload the html file into the 'root' folder",
optional: true,
default_value: true,
is_string: false),
FastlaneCore::ConfigItem.new(key: :version_in_folder,
env_name: "",
description: "upload the version file into the version folder",
optional: true,
default_value: false,
is_string: false),
FastlaneCore::ConfigItem.new(key: :version_in_root,
env_name: "",
description: "upload the html file into the 'root' folder",
optional: true,
default_value: true,
is_string: false),
FastlaneCore::ConfigItem.new(key: :version_template_path,
env_name: "",
description: "version erb template path",
Expand Down

0 comments on commit c466a86

Please sign in to comment.