Created
June 4, 2013 15:32
-
-
Save easonoutlook/5706850 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
APP = LL | |
WORKSPACE = LL | |
CONFIG = AdHoc | |
SCHEME = LLAdHoc | |
ICON_NAME = "[email protected]" | |
BASE_URL = http://ota.nsnotfound.com/ | |
EMAIL_LIST = "[email protected]" | |
EMAIL_DOMAIN = "lexrus.mailgun.org" | |
SFTP_SERVER = [email protected] | |
SFTP_PATH = /var/beta | |
SFTP_PORT = 22 | |
BASE_URL := "http://$(shell hostname):9966" | |
IPA_URL = "$(BASE_URL)/$(APP).ipa" | |
BUILD_PATH = $(shell pwd)/Build | |
PAYLOAD_PATH = $(BUILD_PATH)/Payload | |
UPLOAD_PATH = "$(BUILD_PATH)/Upload" | |
INFO_FILE = $(BUILD_PATH)/Products/$(CONFIG)-iphoneos/$(APP).app/Info.plist | |
PLIST_FILE = $(UPLOAD_PATH)/$(APP).plist | |
IPA_FILE = $(UPLOAD_PATH)/$(APP).ipa | |
GIT_LOG = $(shell git log --no-merges --pretty=format:'<li>%s</li>' --abbrev-commit --date=relative -n 7) | |
MAILGUN_API_KEY = $(shell security find-generic-password -j "mailgun api key" -gw) | |
PLIST_BUDDY = /usr/libexec/PlistBuddy | |
define googl | |
$(shell curl -s -d "{'longUrl':'$(BASE_URL)'}" -H 'Content-Type: application/json' https://www.googleapis.com/urlshortener/v1/url | grep -o 'http://goo.gl/[^\"]*') | |
endef | |
define qrencode | |
$(shell type -P qrencode &>/dev/null && qrencode "$(BASE_URL)" -s 6 -o - | base64 | sed 's/^\(.*\)/<p><img src="data:image\/png;base64,\1"><\/p>/g') | |
endef | |
define html | |
'<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">\ | |
<title>'`$(PLIST_BUDDY) -c "Print :CFBundleDisplayName" "$(INFO_FILE)"`'</title><style type="text/css">body{text-align:center;font-family:"Helvetica";font-size:13px;}ul{text-align:left;}\ | |
.container{width:300px;margin:0 auto;}h1{margin:0;padding:0;font-size:14px;}.install_button{background-image:-webkit-linear-gradient(top,rgb(126,203,26),rgb(92,149,19));background-origin:padding-box;background-repeat:repeat;-webkit-box-shadow:rgba(0,0,0,0.36) 0px 1px 3px 0px;-webkit-font-smoothing:antialiased;-webkit-user-select:none;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);border-color:#75bc18;border-bottom-left-radius:18px;border-bottom-right-radius:18px;border-bottom-style:none;border-bottom-width:0px;border-left-style:none;border-left-width:0px;border-right-style:none;border-right-width:0px;border-top-left-radius:18px;border-top-right-radius:18px;border-top-style:none;border-top-width:0px;box-shadow:rgba(0,0,0,0.359375) 0px 1px 3px 0px;cursor:pointer;display:inline-block;margin:10px 0;padding:1px;position:relative;-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.36);line-height:50px;margin:.5em auto;}\ | |
.install_button a{-webkit-box-shadow:rgba(255,255,255,0.25) 0px 1px 0px 0px inset;-webkit-font-smoothing:antialiased;-webkit-user-select:none;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:-webkit-linear-gradient(top,rgb(195,250,123),rgb(134,216,27) 85%%,rgb(180,231,114));background-origin:padding-box;background-repeat:repeat;border-bottom-color:rgb(255,255,255);border-bottom-left-radius:17px;border-bottom-right-radius:17px;border-bottom-style:none;border-bottom-width:0px;border-left-color:rgb(255,255,255);border-left-style:none;border-left-width:0px;border-right-color:rgb(255,255,255);border-right-style:none;border-right-width:0px;border-top-color:rgb(255,255,255);border-top-left-radius:17px;border-top-right-radius:17px;border-top-style:none;border-top-width:0px;box-shadow:rgba(255,255,255,0.246094) 0px 1px 0px 0px inset;color:#fff;cursor:pointer;display:block;font-size:16px;font-weight:bold;height:36px;line-height:36px;margin:0;padding:0;text-decoration:none;text-shadow:rgba(0,0,0,0.527344) 0px 1px 1px;width:298px;}\ | |
.icon{border-radius:10px;box-shadow:1px 2px 3px lightgray;width:57px;height:57px;}\ | |
.release_notes{border:1px solid lightgray;padding:30px 10px 15px 30px;border-radius:8px;overflow:hidden;line-height:1.3em;box-shadow:1px 1px 3px lightgray;}\ | |
.release_notes:before{font-size:10px;content:"Release Notes";background:lightgray;margin:-31px;float:left;padding:3px 8px;border-radius:4px 0 6px 0;color:white;}\ | |
footer{font-size:x-small;font-weight:bolder;}</style></head><body><div class="container">\ | |
<p><img class="icon" src="$(BASE_URL)/icon.png"/></p><h1>'\ | |
`$(PLIST_BUDDY) -c "Print :CFBundleDisplayName" "$(INFO_FILE)"`\ | |
`$(PLIST_BUDDY) -c "Print :CFBundleShortVersionString" "$(INFO_FILE)"`'('`$(PLIST_BUDDY) -c "Print :CFBundleVersion" "$(INFO_FILE)"`')</h1>\ | |
<div class="install_button"><a href="itms-services://?action=download-manifest&url=$(BASE_URL)/$(APP).plist">INSTALL</a></div>\ | |
<ul class="release_notes">$(GIT_LOG)</ul>\ | |
<p><a href="$(googl)">$(googl)</a></p>\ | |
$(qrencode)\ | |
<footer>'`date`'</footer></div></body></html>' | |
endef | |
default: clean build package | |
.PHONY: clean | |
clean: | |
@echo "> Cleaning $(APP)..." | |
@xcodebuild -sdk iphoneos -workspace "$(WORKSPACE).xcworkspace" -scheme "$(SCHEME)" clean | tail -n 2 | cat && rm -rf Build | |
build: | |
@echo "> Building $(APP)..." | |
@xcodebuild -sdk iphoneos -workspace "$(WORKSPACE).xcworkspace" -scheme "$(SCHEME)" build | tail -n 2 | cat | |
package: | |
@echo "Building $(APP) `$(PLIST_BUDDY) -c 'Print :CFBundleShortVersionString' '$(INFO_FILE)'`(`$(PLIST_BUDDY) -c 'Print :CFBundleVersion' '$(INFO_FILE)'`)" | |
@rm -rf "$(PAYLOAD_PATH)" "$(UPLOAD_PATH)" | |
@mkdir -p "$(PAYLOAD_PATH)" "$(UPLOAD_PATH)" | |
@cp "$(BUILD_PATH)/Products/$(CONFIG)-iphoneos/$(APP).app/$(ICON_NAME)" "$(UPLOAD_PATH)/icon.png" | |
# @cp -r "$(BUILD_PATH)/Products/$(CONFIG)-iphoneos/$(APP).app.dSYM" "$(UPLOAD_PATH)" | |
@cp -r "$(BUILD_PATH)/Products/$(CONFIG)-iphoneos/$(APP).app" "$(PAYLOAD_PATH)" | |
@zip -rq "$(IPA_FILE)" "$(PAYLOAD_PATH)" && rm -rf "$(PAYLOAD_PATH)" | |
plist: | |
@rm -rf $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :items array" $(PLIST_FILE) $2>/dev/null | |
@$(PLIST_BUDDY) -c "Add :items:0 dict" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :items:0:assets array" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:0 dict" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:0:kind string display-image" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:0:needs-shine bool NO" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:0:url string \"$(ICON_URL)\"" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:1 dict" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:1:url string \"$(IPA_URL)\"" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:assets:1:kind string software-package" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:metadata dict" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:metadata:title string \"$(APP)\"" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:metadata:kind string software" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:metadata:bundle-version string \"`$(PLIST_BUDDY) -c 'Print :CFBundleShortVersionString' '$(INFO_FILE)'`\"" $(PLIST_FILE) | |
@$(PLIST_BUDDY) -c "Add :itmes:0:metadata:bundle-idnetifier string \"`$(PLIST_BUDDY) -c 'Print :CFBundleIdentifier' '$(INFO_FILE)'`\"" $(PLIST_FILE) | |
html: plist | |
@echo $(html) > "$(UPLOAD_PATH)/index.html" | |
upload: | |
@scp -P "$(SFTP_PORT)" -r "$(UPLOAD_PATH)" "$(SFTP_SERVER):$(SFTP_PATH)" | |
notify_mailgun: | |
@eval "curl -s --user api:$(MAILGUN_API_KEY) \ | |
https://api.mailgun.net/v2/samples.mailgun.org/messages \ | |
-F from='$(APP) <postmaster@$(EMAIL_DOMAIN)>' \ | |
-F to=$(EMAIL_LIST)\ | |
-F subject='$(APP) is ready' \ | |
-F text='New version is available!'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment