Skip to content

Instantly share code, notes, and snippets.

@xiocode
Last active August 29, 2015 14:11
Show Gist options
  • Save xiocode/a73f0f3cf7d2ef375da9 to your computer and use it in GitHub Desktop.
Save xiocode/a73f0f3cf7d2ef375da9 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Upload ipa file to fir.im
#
# Syntax: upload_fir.sh application.xx
#
APPLICATION=$1
APP_ID=$2
PLATFORM=$3
APPNAME=$4
METADATA=$5
CHANGELOG="daily build!"
VERSION="1.0.0"
if [ -z "$APPLICATION" ];then
echo "Syntax: upload_fir.sh {application}"
exit 1
fi
if [ -n "$METADATA"];then
CHANGELOG=$(echo ${METADATA} | grep 'changelog.*"' -o | awk -F '"' '{print $2}')
VERSION=$(echo ${METADATA} | grep 'version.*"' -o | awk -F '"' '{print $2}')
fi
USER_TOKEN=""
echo "getting token"
INFO=`curl "http://fir.im/api/v2/app/info/${APP_ID}?token=${USER_TOKEN}&type=${PLATFORM}" 2>/dev/null`
KEY=$(echo ${INFO} | grep "pkg.*url" -o | grep "key.*$" -o | awk -F '"' '{print $3;}')
TOKEN=$(echo ${INFO} | grep "pkg.*url" -o | grep "token.*$" -o | awk -F '"' '{print $3;}')
echo upload_key ${KEY}
echo upload_token ${TOKEN}
echo "*********************************************"
echo "uploading"
echo "*********************************************"
APP_INFO=`curl -# -F file=@${APPLICATION} -F "key=${KEY}" -F "token=${TOKEN}" http://up.qiniu.com`
if [ $? != 0 ];then
echo "upload error"
exit 1
fi
APPOID=`echo ${APP_INFO} | grep "appOid.*," -o | awk -F '"' '{print $3;}'`
echo ${INFO}
echo ${APP_INFO}
echo ${APPOID}
curl -X PUT -d "changelog=${CHANGELOG}&name={$APPNAME}&version=${VERSION}" http://fir.im/api/v2/app/${APPOID}?token=${USER_TOKEN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment