Skip to content

Commit

Permalink
updating build and upload scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitarora committed Mar 30, 2016
1 parent 31255cd commit cd2c760
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crxmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))

echo "Wrote $crx"

echo "<script>window.location.href = 'https://s3.amazonaws.com/batarangle.io/$crx';</script>" > download.html
echo "Wrote file"

# clean up
rm -rf $dir
echo "Fin."
25 changes: 19 additions & 6 deletions s3-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,38 @@

echo "Start"

# filename generated using circleci
file="batarangle-$CIRCLE_BUILD_NUM.crx"

# bucket name
bucket=batarangle.io
dateValue=$(date -u +'%Y%m%dT%H%M%SZ')

# filename generated using circleci
file="batarangle-$CIRCLE_BUILD_NUM.crx"
resource="/${bucket}/${file}"
contentType="application/x-compressed-tar"
dateValue=$(date -u +'%Y%m%dT%H%M%SZ')

# create signed token
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"

# fetch aws credentials from env variables
s3Key=$AWS_ACCESS_KEY_ID
s3Secret=$AWS_SECRET_ACCESS_KEY
s3Key=AKIAJYULXJICIOUFRZ7Q
s3Secret=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

# create hmac signature
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`

# curl request to put the file
curl -X PUT -T "${file}" \
-H "Host: ${bucket}.s3.amazonaws.com" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${s3Key}:${signature}" \
http://${bucket}.s3.amazonaws.com/${file}


file="download.html"
resource="/${bucket}/${file}"
contentType="text/html"

# curl request to put the file
curl -X PUT -T "${file}" \
-H "Host: ${bucket}.s3.amazonaws.com" \
Expand Down

0 comments on commit cd2c760

Please sign in to comment.