<commit_before>require 'rubygems'
require 'aws-sdk'

options = {
					status:	ENV['CONCRETE_ARCHIVE_STATUS'],
						 ipa: ENV['CONCRETE_IPA_PATH'],
						dsym:	ENV['CONCRETE_DSYM_PATH'],
				app_slug: ENV['CONCRETE_APP_SLUG'],
			 app_title: ENV['CONCRETE_APP_TITLE'],
			build_slug: ENV['CONCRETE_BUILD_SLUG'],
			access_key:	ENV['S3_DEPLOY_AWS_ACCESS_KEY'],
			secret_key:	ENV['S3_DEPLOY_AWS_SECRET_KEY'],
		 bucket_name:	ENV['S3_BUCKET_NAME'],
		 region_name:	ENV['S3_REGION_NAME'],
	path_in_bucket: ENV['S3_PATH_IN_BUCKET'],
						 acl: ENV['S3_FILE_ACCESS_LEVEL']
}

p "Options: #{options}"

status = "success"
begin
	# checks
	#
	# ipa
	unless File.exists?(options[:ipa])
  	puts "No IPA found to deploy. Terminating."
  	exit!
	end
	# access_key
	unless options[:access_key]
  	puts "No AWS access key provided. Terminating."
  	exit!
	end
	# secret_key
	unless options[:secret_key]
  	puts "No AWS secret key provided. Terminating."
  	exit!
	end

	AWS.config(
  	:access_key_id => options[:access_key], 
  	:secret_access_key => options[:secret_key],
  	:region => options[:region_name]
	)

	s3 = AWS::S3.new

	# define object path
	path = ""
	if (options[:path_in_bucket])
		path = options[:path_in_bucket] + "/"
	else
		path = "concrete_#{options[:app_title]}_#{options[:app_slug]}/build_#{options[:build_slug]}/"
	end

	access_level = 'public_read'
	if (options[:acl])
		access_level = options[:acl]
	end

	# ipa upload
	s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:ipa])].write(:file => options[:ipa], :acl => access_level)
	puts "Uploading ipa #{options[:ipa]} to bucket #{options[:bucket_name]}. Path= #{path}"

	# dsym upload
	if File.exists?(options[:dsym])
		s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:dsym])].write(:file => options[:dsym], :acl => access_level)
		puts "Uploading dsym #{options[:dsym]} to bucket #{options[:bucket_name]}. Path= #{path}"
	end

	# public url
	public_url = s3.buckets[options[:bucket_name]].objects[path].public_url
	public_url2 = s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:ipa])].public_url

	puts public_url
	puts public_url2
	# output variables
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export S3_DEPLOY_STEP_URL=\"#{public_url}\"\n") }
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export CONCRETE_DEPLOY_URL=\"#{public_url}\"\n") }

rescue => ex
	puts "Exception happened: #{ex}"
	status = "failed"
	exit 1
ensure
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export S3_DEPLOY_STEP_STATUS=\"#{status}\"\n") }
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export CONCRETE_DEPLOY_STATUS=\"#{status}\"\n") }
	puts "status=" + status
end<commit_msg>url test<commit_after>require 'rubygems'
require 'aws-sdk'

options = {
					status:	ENV['CONCRETE_ARCHIVE_STATUS'],
						 ipa: ENV['CONCRETE_IPA_PATH'],
						dsym:	ENV['CONCRETE_DSYM_PATH'],
				app_slug: ENV['CONCRETE_APP_SLUG'],
			 app_title: ENV['CONCRETE_APP_TITLE'],
			build_slug: ENV['CONCRETE_BUILD_SLUG'],
			access_key:	ENV['S3_DEPLOY_AWS_ACCESS_KEY'],
			secret_key:	ENV['S3_DEPLOY_AWS_SECRET_KEY'],
		 bucket_name:	ENV['S3_BUCKET_NAME'],
		 region_name:	ENV['S3_REGION_NAME'],
	path_in_bucket: ENV['S3_PATH_IN_BUCKET'],
						 acl: ENV['S3_FILE_ACCESS_LEVEL']
}

p "Options: #{options}"

status = "success"
begin
	# checks
	#
	# ipa
	unless File.exists?(options[:ipa])
  	puts "No IPA found to deploy. Terminating."
  	exit!
	end
	# access_key
	unless options[:access_key]
  	puts "No AWS access key provided. Terminating."
  	exit!
	end
	# secret_key
	unless options[:secret_key]
  	puts "No AWS secret key provided. Terminating."
  	exit!
	end

	AWS.config(
  	:access_key_id => options[:access_key], 
  	:secret_access_key => options[:secret_key],
  	:region => options[:region_name]
	)

	s3 = AWS::S3.new

	# define object path
	path = ""
	if (options[:path_in_bucket])
		path = options[:path_in_bucket] + "/"
	else
		path = "concrete_#{options[:app_title]}_#{options[:app_slug]}/build_#{options[:build_slug]}/"
	end

	access_level = 'public_read'
	if (options[:acl])
		access_level = options[:acl]
	end

	# ipa upload
	s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:ipa])].write(:file => options[:ipa], :acl => access_level)
	puts "Uploading ipa #{options[:ipa]} to bucket #{options[:bucket_name]}. Path= #{path}"

	# dsym upload
	if File.exists?(options[:dsym])
		s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:dsym])].write(:file => options[:dsym], :acl => access_level)
		puts "Uploading dsym #{options[:dsym]} to bucket #{options[:bucket_name]}. Path= #{path}"
	end

	# public url
	public_url = s3.buckets[options[:bucket_name]].objects[path].public_url
	public_url2 = s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:ipa])].public_url
	public_url3 = s3.buckets[options[:bucket_name]].objects[path + File.basename(options[:dsym])].public_url

	puts public_url
	puts public_url2
	puts public_url3
	# output variables
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export S3_DEPLOY_STEP_URL=\"#{public_url}\"\n") }
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export CONCRETE_DEPLOY_URL=\"#{public_url}\"\n") }

rescue => ex
	puts "Exception happened: #{ex}"
	status = "failed"
	exit 1
ensure
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export S3_DEPLOY_STEP_STATUS=\"#{status}\"\n") }
	File.open(File.join(ENV['HOME'], '.bash_profile'), 'a') { |f| f.write("export CONCRETE_DEPLOY_STATUS=\"#{status}\"\n") }
	puts "status=" + status
end
{'fraction_non_alphanumeric': 0.17633654688869413, 'fraction_numerical': 0.006485539000876424, 'mean_word_length': 5.4767309875141885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '167253', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2239, 'n_words': 379}