Skip to content

Commit

Permalink
Upload ironfish-cli release to R2 (#3657)
Browse files Browse the repository at this point in the history
* Upload ironfish-cli release to R2

* Add R2 credential in envs

* Pass in R2 to aws env variables

* Clean up

* Update .github/workflows/deploy-brew.yml

Co-authored-by: Derek Guenther <[email protected]>

---------

Co-authored-by: Derek Guenther <[email protected]>
  • Loading branch information
ygao76 and dguenther authored Mar 16, 2023
1 parent 6271722 commit 8b76569
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/deploy-brew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BREW_GITHUB_USERNAME: ${{ secrets.BREW_GITHUB_USERNAME }}
BREW_GITHUB_TOKEN: ${{ secrets.BREW_GITHUB_TOKEN }}

- name: Deploy Ironfish CLI Brew to R2
run: ./ironfish-cli/scripts/deploy-brew.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
BREW_GITHUB_USERNAME: ${{ secrets.BREW_GITHUB_USERNAME }}
BREW_GITHUB_TOKEN: ${{ secrets.BREW_GITHUB_TOKEN }}
AWS_DEFAULT_REGION: auto
UPLOAD_TO_R2: true
27 changes: 22 additions & 5 deletions ironfish-cli/scripts/deploy-brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ UPLOAD_HASH=$(shasum -a 256 $SOURCE_PATH | awk '{print $1}')

UPLOAD_NAME=ironfish-cli-$GIT_HASH.tar.gz
UPLOAD_URL=s3://ironfish-cli/$UPLOAD_NAME
PUBLIC_URL=https://ironfish-cli.s3.amazonaws.com/$UPLOAD_NAME

if [ -z "${UPLOAD_TO_R2-}" ];
then
PUBLIC_URL=https://ironfish-cli.s3.amazonaws.com/$UPLOAD_NAME
else
PUBLIC_URL=https://releases.ironfish.network/$UPLOAD_NAME
fi

echo ""
echo "GIT HASH: $GIT_HASH"
Expand All @@ -38,13 +44,24 @@ echo "UPLOAD URL: $UPLOAD_URL"
echo "PUBLIC URL: $PUBLIC_URL"
echo ""

if aws s3api head-object --bucket ironfish-cli --key $UPLOAD_NAME > /dev/null 2>&1 ; then
if [ -z "${UPLOAD_TO_R2-}" ];
then
if aws s3api head-object --bucket ironfish-cli --key $UPLOAD_NAME > /dev/null 2>&1 ; then
echo "Release already uploaded: $PUBLIC_URL"
exit 1
fi
fi

echo "Uploading $SOURCE_NAME to $UPLOAD_URL"
aws s3 cp $SOURCE_PATH $UPLOAD_URL
echo "Uploading $SOURCE_NAME to $UPLOAD_URL"
aws s3 cp $SOURCE_PATH $UPLOAD_URL
else
if aws s3api head-object --bucket ironfish-cli --endpoint-url https://a93bebf26da4c2fe205f71c896afcf89.r2.cloudflarestorage.com --key $UPLOAD_NAME > /dev/null 2>&1 ; then
echo "Release already uploaded: $PUBLIC_URL"
exit 1
fi

echo "Uploading $SOURCE_NAME to $UPLOAD_URL"
aws s3 cp $SOURCE_PATH $UPLOAD_URL --endpoint-url https://a93bebf26da4c2fe205f71c896afcf89.r2.cloudflarestorage.com
fi

echo ""
echo "You are almost finished! To finish the process you need to update update url and sha256 in"
Expand Down

0 comments on commit 8b76569

Please sign in to comment.