Skip to content

Commit

Permalink
backend: deploy backend.framework based on the Info.plist version
Browse files Browse the repository at this point in the history
* Fail to deploy if version number is incorrect (must be x.x.x)
* Fail to deploy if it would otherwise overwrite a release
  • Loading branch information
JonasVautherin committed Feb 7, 2019
1 parent 576c209 commit 603c1da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ logs/
*.files
*.includes
CMakeLists.txt.user*

.DS_Store
4 changes: 4 additions & 0 deletions backend/tools/package_backend_framework.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ if [ -f ${FAT_BIN_DIR}/dronecode-backend.zip ]; then
exit 1
fi

echo "Creating fat bin..."

cp -r ${IOS_BACKEND_DIR}/backend.framework ${FAT_BIN_DIR}
lipo ${IOS_BACKEND_DIR}/backend.framework/backend ${IOS_SIM_BACKEND_DIR}/backend.framework/backend -create -output ${FAT_BIN_DIR}/backend.framework/backend

cd ${FAT_BIN_DIR}
zip -9 -r dronecode-backend.zip backend.framework

echo "Success! You'll find the fat bin in ${FAT_BIN_DIR}!"
26 changes: 25 additions & 1 deletion backend/tools/push_backend_framework_to_s3.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@ set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FAT_BIN_DIR=${SCRIPT_DIR}/../../build/fat_bin
CURRENT_VERSION=$(cat ${SCRIPT_DIR}/../../version)

INFO_PLIST=${FAT_BIN_DIR}/backend.framework/Info.plist
CURRENT_VERSION=`grep -A 1 "<key>CFBundleShortVersionString</key>" "${INFO_PLIST}" | grep -o "<string>.*<\/string>" | sed 's/<\(\/*\)string>//g'`

grep -qo '^[0-9]\+\.[0-9]\+\.[0-9]\+$' <<< ${CURRENT_VERSION} || (echo "error: invalid version number for Info.plist (${INFO_PLIST}): '${CURRENT_VERSION}' (expecting [0-9]+\.[0-9]+\.[0-9]+)" && echo "Not deploying." && exit 1)

if [ -z ${CURRENT_VERSION} ]
then
echo "Invalid CFBundleShortVersionString in ${INFO_PLIST}"
exit 1
fi

## Push release to AWS
aws s3 ls dronecode-sdk/dronecode-backend-${CURRENT_VERSION}.zip >/dev/null && echo "Trying to overwrite an existing release! Aborting..." && exit 1

aws s3 cp ${FAT_BIN_DIR}/dronecode-backend.zip s3://dronecode-sdk/dronecode-backend-latest.zip
aws s3api put-object-acl --bucket dronecode-sdk --key dronecode-backend-latest.zip --acl public-read

aws s3 cp ${FAT_BIN_DIR}/dronecode-backend.zip s3://dronecode-sdk/dronecode-backend-${CURRENT_VERSION}.zip
aws s3api put-object-acl --bucket dronecode-sdk --key dronecode-backend-${CURRENT_VERSION}.zip --acl public-read

# Update backend.json on AWS
TMP_DIR=${TMP_DIR:-"$(mktemp -d)"}
curl -s https://s3.eu-central-1.amazonaws.com/dronecode-sdk/backend.json -o ${TMP_DIR}/backend.json
sed -i "" '$ d' ${TMP_DIR}/backend.json
sed -i "" '$s/$/\,/' ${TMP_DIR}/backend.json
echo " \"${CURRENT_VERSION}\": \"https://s3.eu-central-1.amazonaws.com/dronecode-sdk/dronecode-backend-${CURRENT_VERSION}.zip\"" >> ${TMP_DIR}/backend.json
echo "}" >> ${TMP_DIR}/backend.json

aws s3 cp ${TMP_DIR}/backend.json s3://dronecode-sdk/backend.json
aws s3api put-object-acl --bucket dronecode-sdk --key backend.json --acl public-read

0 comments on commit 603c1da

Please sign in to comment.