Created
August 7, 2016 19:11
-
-
Save yene/17d29186fbb837a82f02bd05356e9394 to your computer and use it in GitHub Desktop.
Build and release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
APIKEY=$(<apikey.txt) | |
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "Info.plist") | |
PREV_TAG=$(curl -s https://api.github.com/repos/yene/DisplayBrightness/releases/latest | python -c "import json,sys;obj=json.load(sys.stdin);print obj['tag_name'];") | |
if [ "$PREV_TAG" == "v$VERSION" ]; then | |
echo "Error: This version is already published!" | |
exit 1 | |
fi | |
git push origin master | |
mkdir build | |
xcodebuild -project DisplayBrightness.xcodeproj -scheme DisplayBrightness -archivePath build/DisplayBrightness.xarchive archive > /dev/null | |
xcodebuild -exportArchive -archivePath build/DisplayBrightness.xarchive.xcarchive -exportPath build/ -exportOptionsPlist export.plist > /dev/null | |
cd build | |
zip -q -r "DisplayBrightness_${VERSION}.zip" DisplayBrightness.app/ | |
cd .. | |
RESULT=$(curl -s -H "Authorization: token ${APIKEY}" \ | |
-d "{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"draft\":true}" \ | |
https://api.github.com/repos/yene/DisplayBrightness/releases) | |
UPLOAD_URL=$(echo $RESULT | python -c "import json,sys;obj=json.load(sys.stdin);print obj['upload_url'];") | |
curl -s -H "Authorization: token ${APIKEY}" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"build/DisplayBrightness_${VERSION}.zip" \ | |
"${UPLOAD_URL/\{?name,label\}/?name=DisplayBrightness_v${VERSION}.zip}" > /dev/null | |
echo -e "\n\nYour release v${VERSION} is ready: https://github.com/yene/DisplayBrightness/releases" | |
rm -r build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment