Skip to content

Commit

Permalink
ci: Upload resources ZIP archive file
Browse files Browse the repository at this point in the history
Reduce network bandwidth.
  • Loading branch information
dcalhoun committed Dec 3, 2024
1 parent 9c258b0 commit bdc0ac4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'zip'

before_all do
# Ensure we use the latest version of the toolkit
check_for_toolkit_updates unless is_ci || ENV['FASTLANE_SKIP_TOOLKIT_UPDATE_CHECK']
Expand All @@ -12,7 +14,15 @@ lane :upload_ios_artifacts_to_s3 do
UI.user_error!("Could not find artifacts to upload at '#{artifacts_path}'.")
end

upload_artifact_files_to_s3(archive_path: artifacts_path, id: last_git_commit[:commit_hash])
zipfile_name = "#{artifacts_path}.zip"

Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir[File.join(artifacts_path, '**', '**')].each do |file|
zipfile.add(file.sub(artifacts_path + '/', ''), file)
end
end

upload_artifact_files_to_s3(archive_path: zipfile_name, id: last_git_commit[:commit_hash])

next unless is_ci

Expand All @@ -22,16 +32,11 @@ lane :upload_ios_artifacts_to_s3 do

# Tradeoff: We are "wasting" space on S3 by uploading the same archive under different name.
# What we get in return is a 1-1 correspondency between archive and podspec, which keeps the setup simpler.
upload_artifact_files_to_s3(archive_path: xcframework_archive_path, id: tag)
upload_artifact_files_to_s3(archive_path: zipfile_name, id: tag)
end

def upload_artifact_files_to_s3(archive_path:, id:)
Dir.glob("#{archive_path}/**/*").each do |file_path|
next if File.directory?(file_path)

relative_path = file_path.sub("#{archive_path}/", '')
upload_to_a8c_s3(file: file_path, name_on_s3: "#{id}/#{relative_path}")
end
upload_to_a8c_s3(file: archive_path, name_on_s3: "gutenberg-kit-resources-#{id}.zip")
end

# Notice skip_if_exists is true by default.
Expand Down

0 comments on commit bdc0ac4

Please sign in to comment.