github.com/getgauge/gauge@v1.6.9/build/publish_rpm_to_bintray.sh (about) 1 #!/bin/sh 2 3 # ---------------------------------------------------------------- 4 # Copyright (c) ThoughtWorks, Inc. 5 # Licensed under the Apache License, Version 2.0 6 # See LICENSE.txt in the project root for license information. 7 # ---------------------------------------------------------------- 8 9 set -e 10 11 if [ -z "$REPO" ]; then 12 REPO="gauge-rpm" 13 fi 14 15 if [ -z "$PACKAGE" ]; then 16 PACKAGE="gauge" 17 fi 18 19 if [ -z "$BINTRAY_PACKAGE" ]; then 20 PACKAGE="gauge-nightly" 21 fi 22 23 if [ -z "$USER" ]; then 24 echo "USER is not set" 25 exit 1 26 fi 27 28 if [ -z "$API_KEY" ]; then 29 echo "API_KEY is not set" 30 exit 1 31 fi 32 33 if [ -z "$PASSPHRASE" ]; then 34 echo "PASSPHRASE is not set" 35 exit 1 36 fi 37 38 39 PACKAGE_FILE_PREFIX=$(echo "$PACKAGE" | tr '[:upper:]' '[:lower:]'); 40 41 setVersion () { 42 VERSION=$(ls $PACKAGE_FILE_PREFIX*.rpm | head -1 | sed "s/\.[^\.]*$//" | sed "s/$PACKAGE_FILE_PREFIX-//" | sed "s/-[a-z]*\.[a-z0-9_]*$//" | rev | sed "s/^[a-z0-9]*-//" | rev); 43 } 44 45 getArchFromFileName () { 46 ARCH=$(echo $1 | sed "s/$PACKAGE_FILE_PREFIX-//" | rev | cut -d '-' -f 1 | rev | cut -d '.' -f 1); 47 echo $ARCH 48 } 49 50 setUploadDirPath () { 51 UPLOADDIRPATH="$BINTRAY_PACKAGE/$PACKAGE/$VERSION" 52 } 53 54 bintrayUpload () { 55 for i in `ls $PACKAGE_FILE_PREFIX*.rpm`; do 56 ARCH=$( getArchFromFileName $i ) 57 URL="https://api.bintray.com/content/gauge/$REPO/$BINTRAY_PACKAGE/$VERSION/$UPLOADDIRPATH/$i?publish=1&override=1" 58 59 echo "Uploading:" 60 echo "\tversion: $VERSION" 61 echo "\tarch: $ARCH" 62 echo "\tURL: $URL" 63 64 RESPONSE_CODE=$(curl -H "X-GPG-PASSPHRASE: $PASSPHRASE" -T $i -u$USER:$API_KEY "$URL" -I -s -w "%{http_code}" -o /dev/null); 65 if [ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]; then 66 echo "Unable to upload, HTTP response code: $RESPONSE_CODE" 67 exit 1 68 fi 69 echo "HTTP response code: $RESPONSE_CODE" 70 done; 71 } 72 73 bintraySetDownloads () { 74 for i in `ls *.rpm`; do 75 ARCH=$( getArchFromFileName $i ) 76 URL="https://api.bintray.com/file_metadata/gauge/$REPO/$UPLOADDIRPATH/$i" 77 78 echo "Putting $i in $PACKAGE's download list" 79 RESPONSE_CODE=$(curl -X PUT -d "{ \"list_in_downloads\": true }" -H "Content-Type: application/json" -u$USER:$API_KEY "$URL" -s -w "%{http_code}" -o /dev/null); 80 81 if [ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]; then 82 echo "Unable to put in download list, HTTP response code: $RESPONSE_CODE" 83 exit 1 84 fi 85 echo "HTTP response code: $RESPONSE_CODE" 86 done 87 } 88 89 snooze () { 90 echo "\nSleeping for 30 seconds. Have a coffee..." 91 sleep 30s; 92 echo "Done sleeping\n" 93 } 94 95 printMeta () { 96 echo "Publishing rpm: $PACKAGE" 97 echo "Version to be uploaded: $VERSION" 98 } 99 100 setVersion 101 printMeta 102 setUploadDirPath 103 bintrayUpload 104 snooze 105 bintraySetDownloads