Skip to content

Commit

Permalink
Merge pull request #21 from mcasper/bucket_endpoint
Browse files Browse the repository at this point in the history
Add the ability to pass an s3 endpoint
  • Loading branch information
Josh Holtz authored Apr 21, 2017
2 parents 995c6d9 + 231dcf1 commit 9def13c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ aws_s3(
bucket: ENV['S3_BUCKET'], # Required from user.
region: ENV['S3_REGION'], # Required from user.

endpoint: 'https://s3-us-west-1.amazonaws.com', # Optional, for buckets that require a specific endpoint
ipa: 'AppName.ipa', # Required (if not uploading an APK).
dsym: 'AppName.app.dSYM.zip', # Optional is you use `ipa` to build.

apk: 'AppName.apk', # Required (if not uploading an IPA).

app_directory: 'ios_or_android', # Optional but nice if you want to put multiple apps in same bucket

path: 'v{CFBundleShortVersionString}_b{CFBundleVersion}/', # This is actually the default.
Expand Down
16 changes: 14 additions & 2 deletions lib/fastlane/plugin/aws_s3/actions/aws_s3_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def self.run(config)
params[:access_key] = config[:access_key]
params[:secret_access_key] = config[:secret_access_key]
params[:bucket] = config[:bucket]
params[:endpoint] = config[:endpoint]
params[:region] = config[:region]
params[:app_directory] = config[:app_directory]
params[:acl] = config[:acl]
Expand All @@ -43,6 +44,7 @@ def self.run(config)
s3_access_key = params[:access_key]
s3_secret_access_key = params[:secret_access_key]
s3_bucket = params[:bucket]
s3_endpoint = params[:endpoint]
apk_file = params[:apk]
ipa_file = params[:ipa]
dsym_file = params[:dsym]
Expand All @@ -61,7 +63,11 @@ def self.run(config)
credentials: Aws::Credentials.new(s3_access_key, s3_secret_access_key)
})

s3_client = Aws::S3::Client.new
s3_client = if s3_endpoint
Aws::S3::Client.new(endpoint: s3_endpoint)
else
Aws::S3::Client.new
end

upload_ipa(s3_client, params, s3_region, s3_access_key, s3_secret_access_key, s3_bucket, ipa_file, dsym_file, s3_path, acl) if ipa_file.to_s.length > 0
upload_apk(s3_client, params, s3_region, s3_access_key, s3_secret_access_key, s3_bucket, apk_file, s3_path, acl) if apk_file.to_s.length > 0
Expand Down Expand Up @@ -477,7 +483,13 @@ def self.available_options
description: "Uploaded object permissions e.g public_read (default), private, public_read_write, authenticated_read ",
optional: true,
default_value: "public-read"
)
),
FastlaneCore::ConfigItem.new(key: :endpoint,
env_name: "S3_ENDPOINT",
description: "The base endpoint for your S3 bucket",
optional: true,
default_value: nil
),
]
end

Expand Down

0 comments on commit 9def13c

Please sign in to comment.