|
| 1 | +#! /bin/bash |
| 2 | + |
| 3 | +source $(dirname "$0")/version.sh |
| 4 | + |
| 5 | +# Set default version to develop |
| 6 | +BUILD_VERSION=develop |
| 7 | + |
| 8 | +# Trigger read version |
| 9 | +read_version |
| 10 | +echo "Build version: $BUILD_VERSION" |
| 11 | + |
| 12 | +create_release() { |
| 13 | + user="aperture-data" |
| 14 | + repo="aperturedb-cpp" |
| 15 | + token=$TOKEN |
| 16 | + tag="v$BUILD_VERSION" |
| 17 | + |
| 18 | + command="curl -s -o release.json -w '%{http_code}' \ |
| 19 | + --request POST \ |
| 20 | + --header 'Accept: application/vnd.github.v3+json' \ |
| 21 | + --header 'Authorization: token ${token}' \ |
| 22 | + --header 'content-type: application/json' \ |
| 23 | + --data '{\"tag_name\": \"${tag}\", \"name\": \"${tag}\", \"body\":\"Release ${tag}\"}' \ |
| 24 | + https://api.github.com/repos/$user/$repo/releases" |
| 25 | + http_code=`eval $command` |
| 26 | + if [ $http_code == "201" ]; then |
| 27 | + echo "created release:" |
| 28 | + cat release.json |
| 29 | + else |
| 30 | + echo "create release failed with code '$http_code':" |
| 31 | + cat release.json |
| 32 | + echo "command:" |
| 33 | + echo $command |
| 34 | + return 1 |
| 35 | + fi |
| 36 | +} |
| 37 | + |
| 38 | +upload_custom_release_file() { |
| 39 | + mkdir /tmp/aperturedb-cpp |
| 40 | + mkdir -p /tmp/aperturedb-cpp/lib |
| 41 | + mkdir -p /tmp/aperturedb-cpp/include |
| 42 | + |
| 43 | + docker create -ti --name aperturedb aperturedb-client-testing bash |
| 44 | + docker start aperturedb |
| 45 | + docker exec aperturedb bash -c "mkdir -p /x64; cp /usr/local/lib/libprotobuf.so.* /x64" |
| 46 | + docker exec aperturedb bash -c "cp /aperturedb-client/lib/* /x64" |
| 47 | + docker exec aperturedb bash -c "mkdir -p /comm; cp /aperturedb-client/include/comm/* /comm" |
| 48 | + docker cp aperturedb:/x64/ /tmp/aperturedb-cpp/lib/ |
| 49 | + docker cp aperturedb:/comm/ /tmp/aperturedb-cpp/include/ |
| 50 | + |
| 51 | + tar -cvzf libs_64.tgz -C /tmp aperturedb-cpp |
| 52 | + docker stop aperturedb |
| 53 | + docker rm -f aperturedb |
| 54 | + |
| 55 | + token=$TOKEN |
| 56 | + file="libs_64.tgz" |
| 57 | + name="libs_64.tgz" |
| 58 | + |
| 59 | + url=`jq -r .upload_url release.json | cut -d{ -f'1'` |
| 60 | + command="\ |
| 61 | + curl -s -o upload.json -w '%{http_code}' \ |
| 62 | + --request POST \ |
| 63 | + --header 'Accept: application/vnd.github.v3+json' \ |
| 64 | + --header 'Authorization: token ${token}' \ |
| 65 | + --header 'Content-Type: application/octet-stream' \ |
| 66 | + --data-binary @\"${file}\" |
| 67 | + ${url}?name=${name}" |
| 68 | + http_code=`eval $command` |
| 69 | + if [ $http_code == "201" ]; then |
| 70 | + echo "asset $name uploaded:" |
| 71 | + jq -r .browser_download_url upload.json |
| 72 | + else |
| 73 | + echo "upload failed with code '$http_code':" |
| 74 | + cat upload.json |
| 75 | + echo "command:" |
| 76 | + echo $command |
| 77 | + return 1 |
| 78 | + fi |
| 79 | +} |
| 80 | + |
| 81 | + |
| 82 | +create_release |
| 83 | +upload_custom_release_file |
0 commit comments