Skip to content

Instantly share code, notes, and snippets.

@Nicejinux
Forked from magicmon/build_script.sh
Created March 30, 2017 16:55
Show Gist options
  • Save Nicejinux/c92fc95304dab132e95f41e12ce828a2 to your computer and use it in GitHub Desktop.
Save Nicejinux/c92fc95304dab132e95f41e12ce828a2 to your computer and use it in GitHub Desktop.
Xcode command line build & publish on fabric.
# config
CONFIGURATION_MODE=Debug
WORKSPACE_NAME=$1
IPA_NAME=$1
SCHEME=$2
GROUP_ALIASES=$3
ARCHIVEPATH=`pwd`/archive
ARCHIVE_FILE=${ARCHIVEPATH}/${IPA_NAME}.xcarchive
PROJECT_BUILDDIR=${ARCHIVE_FILE}/Products/Applications
# auto increment the build number
APP_BUILD_NUMBER=$(date +"%m%d%H%M")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${APP_BUILD_NUMBER}" ./${WORKSPACE_NAME}/Info.plist
# build to workspace
xcodebuild -workspace ${WORKSPACE_NAME}.xcworkspace -scheme ${SCHEME} -configuration ${CONFIGURATION_MODE} clean archive -archivePath ${ARCHIVEPATH}/${IPA_NAME} ONLY_ACTIVE_ARCH=NO
/usr/bin/xcrun -sdk iphoneos PackageApplication -v ${PROJECT_BUILDDIR}/*.app -o ${ARCHIVEPATH}/${IPA_NAME}.ipa
if [ -r ${ARCHIVEPATH}/${IPA_NAME}.ipa ]
then
APP_JENKINS_URL=$(echo ${BUILD_URL} | sed -e 's/https:\/\///g' -e 's/http:\/\///g')
APP_JENKINS_SERVER=http://magicmon:00000000000000000000000000000000@${APP_JENKINS_URL}api/xml
APP_JENKINS_SERVER_STATUS_CODE=$(curl --write-out %{http_code} --silent --output /dev/null "${APP_JENKINS_SERVER}")
# Make to release note by commit log
COMMIT_LOGS=$(curl -s "${APP_JENKINS_SERVER}?wrapper=changes&xpath=//changeSet//comment")
echo ${COMMIT_LOGS} | sed -e 's/<\/*changes\/*>//g' -e 's/<comment>/- /g' -e 's/<\/comment>/\
/g' > ${ARCHIVEPATH}/ReleaseNotes_tmp.txt
sed -e '/no message/d' -e '/^$/d' ${ARCHIVEPATH}/ReleaseNotes_tmp.txt > ${ARCHIVEPATH}/ReleaseNotes.txt
# Upload IPA & Notify by Email
`pwd`/Pods/Crashlytics/submit 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 \
-ipaPath ${ARCHIVEPATH}/${IPA_NAME}.ipa \
-notesPath ${ARCHIVEPATH}/ReleaseNotes.txt \
-groupAliases ${GROUP_ALIASES} \
-notifications YES
# remove the ipa folder
rm -rf ${ARCHIVEPATH}
else
# remove the ipa folder
rm -rf ${ARCHIVEPATH}
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment