github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/ci/scripts/upload-binaries-gocd (about) 1 #!/usr/bin/env bash 2 3 set -e 4 5 if [ -z "$AWS_ACCESS_KEY_ID" ]; then 6 echo "Need to set AWS_ACCESS_KEY_ID" 7 exit 1 8 fi 9 10 if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then 11 echo "Need to set AWS_SECRET_ACCESS_KEY" 12 exit 1 13 fi 14 15 s3_config_file=$(pwd)/../../../../cli-ci/ci/s3cfg 16 17 function upload_artifacts { 18 s3_path_prefix=$1 19 20 for file in $(ls release) 21 do 22 echo s3cmd --config=$s3_config_file put release/$file s3://go-cli/$s3_path_prefix/$file 23 s3cmd --config=$s3_config_file put release/$file s3://go-cli/$s3_path_prefix/$file 24 done 25 } 26 27 release_tags=$(git show-ref --tags -d | grep $(git rev-parse HEAD) | cut -d'/' -f3 | egrep 'v[0-9]'; exit 0) 28 latest_release_tag=$(git tag | egrep 'v[0-9]' | sort | tail -n 1; exit 0) 29 30 for tag in $release_tags 31 do 32 echo "Uploading artifacts for release" $tag 33 upload_artifacts "releases/$tag" 34 done 35 36 # Only upload to the 'latest' bucket if we're building some 37 # commit *after* the latest release 38 39 # this tries to avoid uploading a release to the "latest" bucket if we're 40 # actually building an older tag, which would result in us overwriting the 41 # edge build with an older version. 42 git merge-base --is-ancestor $latest_release_tag HEAD 43 if [ $? -eq 0 ] 44 then 45 echo "Uploading master artifacts" 46 upload_artifacts "master" 47 fi