-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dedicated make target to download packages from pre_release and uploa…
…d to s3
- Loading branch information
1 parent
ad07e9d
commit 3a36a33
Showing
4 changed files
with
60 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
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,6 @@ | ||
.DEFAULT_GOAL := upload | ||
|
||
.PHONY: upload | ||
upload: | ||
pip3 install -r requirements.txt | ||
python3 upload.py |
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,2 @@ | ||
boto3 | ||
PyGithub |
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,36 @@ | ||
import logging | ||
import boto3 | ||
from botocore.exceptions import ClientError | ||
import os | ||
import urllib.request | ||
from github import Github | ||
from github import Auth | ||
|
||
|
||
def download_win_packages_from_gh_release(token, tag_name): | ||
auth = Auth.Token(token) | ||
fluent_bit_package_repo = Github(auth).get_repo('newrelic/fluent-bit-package').get_releases() | ||
asset_names = [] | ||
|
||
for release in fluent_bit_package_repo: | ||
if release.tag_name == tag_name: | ||
for asset in release.get_assets(): | ||
if "windows" in asset.name: | ||
urllib.request.urlretrieve(asset.url, asset.name) | ||
asset_names.append(asset.name) | ||
|
||
return asset_names | ||
|
||
def upload_file(file_name, bucket): | ||
s3_client = boto3.client('s3') | ||
try: | ||
s3_client.upload_file(file_name, bucket, None) | ||
except ClientError as e: | ||
logging.error(e) | ||
|
||
if __name__ == "__main__": | ||
token = os.environ['GITHUB_TOKEN'] | ||
asset_names = download_win_packages_from_gh_release(token) | ||
bucket_name = os.environ['AWS_S3_BUCKET_NAME'] | ||
for asset_name in asset_names: | ||
upload_file(asset_name, 'fluent-bit-package') |