-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'bundler/inline' | ||
require 'json' | ||
require 'fileutils' | ||
require 'uri' | ||
require 'net/http' | ||
require 'digest/sha2' | ||
|
||
gemfile do | ||
source 'https://rubygems.org' | ||
gem 'octokit' | ||
end | ||
|
||
root = File.expand_path('../..', __dir__) | ||
|
||
Dir.chdir(root) | ||
CONFIG = JSON.parse(File.read('skylight.json')) | ||
VERSION = CONFIG.fetch('version') | ||
CHECKSUMS = CONFIG.fetch('otlp_checksums') | ||
BASE_URL = 'https://s3.amazonaws.com/skylight-agent-packages/skylight-native'.freeze | ||
REPO = 'tildeio/skylight-otlp' | ||
TOKEN = ENV.fetch('GITHUB_TOKEN') | ||
|
||
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 if checksum == fetched_checksum | ||
|
||
raise "non-matching checksum (expected = #{checksum}; actual = #{fetched_checksum} for #{platform}" | ||
end | ||
|
||
CHECKSUMS.each do |platform, checksum| | ||
download_artifact(platform: platform, checksum: checksum) | ||
end | ||
|
||
octokit = Octokit::Client.new(access_token: TOKEN) | ||
puts 'creating release...' | ||
release = octokit.create_release(REPO, VERSION, | ||
name: "Skylight for OTLP #{VERSION}", target_commitish: 'main', draft: true, prerelease: true) | ||
|
||
puts "Release id #{release.id} tagged #{VERSION} (#{release.url})" | ||
|
||
Dir['artifacts/*'].each do |file| | ||
puts "uploading #{file}..." | ||
asset = octokit.upload_asset(release.url, file, content_type: 'application/gzip') | ||
puts asset.url | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
create-release: | ||
permissions: | ||
contents: write | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: get version | ||
run: | | ||
echo "::set-output name=version::$(ruby .github/workflows/fetch_release.rb --version)" | ||
- name: download artifacts and create release | ||
id: download_artifacts | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: "ruby .github/workflows/fetch_release.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 5.2.1-3668ebb | ||
|
||
- [FEATURE] Initial release workflow test | ||
- [FEATURE] Skylight for OTLP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "5.2.1-3668ebb", | ||
"otlp_checksums": { | ||
"x86-linux": "b6211d2526064d58f2cb9143afca8ecd9e96a8e712af80ec878fa60c410f4519", | ||
"x86_64-linux": "9708adaed8b687e43c906b429d84a5e3778152e7bffac1770cb26e9e39e296d5", | ||
"x86_64-linux-musl": "4d5ee704d378bad2ff800195652976444f414f7c78eb0796679eeda68938dbd3", | ||
"x86_64-darwin": "afbecfa36ed7e31af498c8b834ec5e13367c82f0b762dfcb32f4983a70b5732d", | ||
"x86_64-freebsd": "30e84371330b63ec2665c4fb6378fb7b42d5c969d6791ae5ba1f690c242bc648", | ||
"aarch64-linux": "08967a97ac7f59b95117a4b6d8ef48cbbe2d009126dc8d4bd10c3467ebf91250", | ||
"aarch64-linux-musl": "b90806f2f0230b38b753579921ee61f3186b029e15c4a3d7ff7f1737925a7115", | ||
"aarch64-darwin": "d0e17e7e4b2a84501c0ec2383658a30e923030e19233ad251d803b7111cc38ca" | ||
} | ||
} |