Skip to content

Commit

Permalink
Merge pull request #21 from tildeio/6.0.0-alpha
Browse files Browse the repository at this point in the history
reorg script
  • Loading branch information
zvkemp authored Oct 10, 2024
2 parents 9ccead2 + bbea37a commit 5c62f8c
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/fetch_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,6 @@

ENV['AWS_REGION'] ||= 'us-east-1'

def download_artifact(platform:, checksum:, version: VERSION, base_url: BASE_URL)
filename = "skylight_otlp_#{platform}.tar.gz"
output_filename = filename.sub('skylight_otlp', "skylight_#{version}")
path = File.join("artifacts/#{output_filename}")
FileUtils.mkdir_p(File.dirname(path))

uri = URI("#{base_url}/#{version}/#{filename}")
digest = Digest::SHA2.new
puts "fetching Skylight for OTLP; platform=#{platform}"

Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
request = Net::HTTP::Get.new uri
http.request request do |response|
raise response.code unless response.code == '200'

File.open(path, 'wb') do |f|
response.read_body do |chunk|
digest << chunk
f.write(chunk)
end
end
end
end

fetched_checksum = digest.hexdigest

return Artifact.new(checksum: checksum, path: path, platform: platform) if checksum == fetched_checksum

raise "non-matching checksum (expected = #{checksum}; actual = #{fetched_checksum} for #{platform}"
end

artifacts = []

CHECKSUMS.each do |platform, checksum|
artifacts << download_artifact(platform: platform, checksum: checksum)
end

LAMBDA_PLATFORMS = { "x86_64-linux" => "x86_64", "aarch64-linux" => "arm64" }.freeze

class Artifact
attr_reader :layer_version_arn

Expand Down Expand Up @@ -135,6 +96,45 @@ def upload_lambda_layer(aws)
end
end

def download_artifact(platform:, checksum:, version: VERSION, base_url: BASE_URL)
filename = "skylight_otlp_#{platform}.tar.gz"
output_filename = filename.sub('skylight_otlp', "skylight_#{version}")
path = File.join("artifacts/#{output_filename}")
FileUtils.mkdir_p(File.dirname(path))

uri = URI("#{base_url}/#{version}/#{filename}")
digest = Digest::SHA2.new
puts "fetching Skylight for OTLP; platform=#{platform}"

Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
request = Net::HTTP::Get.new uri
http.request request do |response|
raise response.code unless response.code == '200'

File.open(path, 'wb') do |f|
response.read_body do |chunk|
digest << chunk
f.write(chunk)
end
end
end
end

fetched_checksum = digest.hexdigest

return Artifact.new(checksum: checksum, path: path, platform: platform) if checksum == fetched_checksum

raise "non-matching checksum (expected = #{checksum}; actual = #{fetched_checksum} for #{platform}"
end

artifacts = []

CHECKSUMS.each do |platform, checksum|
artifacts << download_artifact(platform: platform, checksum: checksum)
end

LAMBDA_PLATFORMS = { "x86_64-linux" => "x86_64", "aarch64-linux" => "arm64" }.freeze

aws = Aws::Lambda::Client.new
# do this first to get the ARNs
artifacts.each do |artifact|
Expand Down

0 comments on commit 5c62f8c

Please sign in to comment.