github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/ci/scripts/upload-binaries-concourse (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  function upload_artifacts {
    16    s3_path_prefix=$1
    17  
    18    for file in $(ls release)
    19    do
    20      echo s3cmd --config=$S3_CONFIG_FILE put release/$file s3://cf-cli-pipeline-artifacts/$s3_path_prefix/$file
    21      s3cmd --config=$S3_CONFIG_FILE put release/$file s3://cf-cli-pipeline-artifacts/$s3_path_prefix/$file
    22    done
    23  }
    24  
    25  release_tags=$(git show-ref --tags -d | grep $(git rev-parse HEAD) | cut -d'/' -f3 | egrep 'v[0-9]'; exit 0)
    26  latest_release_tag=$(git tag | egrep 'v[0-9]' | sort | tail -n 1; exit 0)
    27  
    28  for tag in $release_tags
    29  do
    30    echo "Uploading artifacts for release" $tag
    31    upload_artifacts "releases/$tag"
    32  done
    33  
    34  # Only upload to the 'latest' bucket if we're building some
    35  # commit *after* the latest release
    36  
    37  # this tries to avoid uploading a release to the "latest" bucket if we're
    38  # actually building an older tag, which would result in us overwriting the
    39  # edge build with an older version.
    40  git merge-base --is-ancestor $latest_release_tag HEAD
    41  if [ $? -eq 0 ]
    42  then
    43    echo "Uploading master artifacts"
    44    upload_artifacts "master"
    45  fi