├── Makefile ├── Makefile.cfg └── README.md /Makefile: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # Copyright © 2013 Carl Chen. 3 | 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the “Software”), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | 14 | # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | 23 | include Makefile.cfg 24 | 25 | ProjectAbsolutePath = $(shell pwd) 26 | 27 | WorkFolder = build 28 | 29 | VPATH = $(WorkFolder) 30 | 31 | WorkPath = $(ProjectAbsolutePath)/$(WorkFolder) 32 | 33 | CompileOutputPath = $(WorkPath)/iPhoneOS 34 | 35 | UploadPath = $(WorkPath)/upload 36 | 37 | PlistBuddyPath = /usr/libexec/PlistBuddy 38 | 39 | Configuration ?= Release 40 | 41 | #define InfoPlistFilePath 42 | #$(shell echo $(CompileOutputPath)/*.app/Info.plist) 43 | #endef 44 | 45 | InfoClr = \033[01;33m 46 | ResultClr = \033[01;32m 47 | ResetClr = \033[0m 48 | 49 | BuildCmdConfig = -configuration $(Configuration) CONFIGURATION_BUILD_DIR=$(CompileOutputPath) 50 | 51 | ifneq ($(Scheme),) 52 | BuildCmdConfig += -scheme $(Scheme) 53 | endif 54 | 55 | ifneq ($(ProvisioningProfile),) 56 | BuildCmdConfig += PROVISIONING_PROFILE=$(ProvisioningProfile) 57 | endif 58 | 59 | 60 | define AppDisplayName 61 | $(shell $(PlistBuddyPath) -c 'print CFBundleDisplayName' $(CompileOutputPath)/*.app/Info.plist) 62 | endef 63 | 64 | define AppBuildVersion 65 | $(shell $(PlistBuddyPath) -c 'print CFBundleVersion' $(CompileOutputPath)/*.app/Info.plist) 66 | endef 67 | 68 | define AppBuildIdentifier 69 | $(shell $(PlistBuddyPath) -c 'print CFBundleIdentifier' $(CompileOutputPath)/*.app/Info.plist) 70 | endef 71 | 72 | define AppBundleName 73 | $(shell $(PlistBuddyPath) -c 'print CFBundleName' $(CompileOutputPath)/*.app/Info.plist) 74 | endef 75 | 76 | UploadPlistName = $(AppBundleName).plist 77 | 78 | UploadLogoName = logo.png 79 | 80 | UploadPlistPath = $(UploadPath)/$(UploadPlistName) 81 | 82 | ItemsURL = itms-services://?action=download-manifest&url=$(PlistFileHttpsURL) 83 | 84 | AppName ?= $(AppDisplayName) 85 | 86 | GitLog = $(shell git log --no-merges --pretty=format:"\r✓ %s" --abbrev-commit --date=relative -n 10 | /usr/bin/php -r 'echo htmlentities(fread( STDIN, 2048 ), ENT_QUOTES, "UTF-8");') 87 | 88 | define html 89 | '
\ 90 |$(GitLog)\ 103 | \ 104 | ' 105 | endef 106 | 107 | 108 | all : package uploadFiles 109 | .PHONY : all compile package uploadFiles plist sendEmail sendIMsg upload 110 | 111 | compile : 112 | @echo "Start building project." 113 | @xcodebuild $(BuildCmdConfig) 114 | 115 | package : compile 116 | @echo "Start packaging." 117 | @xcrun -sdk iphoneos PackageApplication -v $(CompileOutputPath)/*.app -o $(WorkPath)/$(AppBundleName).ipa 118 | 119 | uploadFiles : plist 120 | @cp $(WorkPath)/*.ipa $(UploadPath)/$(AppBundleName).ipa 121 | @-cp Icon@2x.png $(UploadPath)/$(UploadLogoName) 122 | @echo $(html) > $(UploadPath)/index.html 123 | 124 | 125 | plist : 126 | @rm -rf $(UploadPath) 127 | @mkdir $(UploadPath) 128 | @$(PlistBuddyPath) -c "Add :items array" $(UploadPlistPath) $2>/dev/null 129 | @$(PlistBuddyPath) -c "Add :items:0 dict" $(UploadPlistPath) 130 | @$(PlistBuddyPath) -c "Add :items:0:assets array" $(UploadPlistPath) 131 | @$(PlistBuddyPath) -c "Add :items:0:assets:0 dict" $(UploadPlistPath) 132 | @$(PlistBuddyPath) -c "Add :items:0:assets:0:url string \"$(BaseURL)/$(AppBundleName).ipa\"" $(UploadPlistPath) 133 | @$(PlistBuddyPath) -c "Add :items:0:assets:0:kind string software-package" $(UploadPlistPath) 134 | @$(PlistBuddyPath) -c "Add :items:0:assets:1 dict" $(UploadPlistPath) 135 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:kind string display-image" $(UploadPlistPath) 136 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:needs-shine bool NO" $(UploadPlistPath) 137 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:url string \"$(BaseURL)/$(UploadLogoName)\"" $(UploadPlistPath) 138 | @$(PlistBuddyPath) -c "Add :items:0:assets:2 dict" $(UploadPlistPath) 139 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:kind string full-size-image" $(UploadPlistPath) 140 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:needs-shine bool NO" $(UploadPlistPath) 141 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:url string \"$(BaseURL)/$(UploadLogoName)\"" $(UploadPlistPath) 142 | @$(PlistBuddyPath) -c "Add :items:0:metadata dict" $(UploadPlistPath) 143 | @$(PlistBuddyPath) -c "Add :items:0:metadata:title string \"$(AppName)\"" $(UploadPlistPath) 144 | @$(PlistBuddyPath) -c "Add :items:0:metadata:kind string software" $(UploadPlistPath) 145 | @$(PlistBuddyPath) -c "Add :items:0:metadata:bundle-version string \"$(AppBuildVersion)\"" $(UploadPlistPath) 146 | @$(PlistBuddyPath) -c "Add :items:0:metadata:bundle-identifier string \"$(AppBuildIdentifier)\"" $(UploadPlistPath) 147 | @mv $(UploadPlistPath) $(WorkPath) 148 | 149 | sendEmail : 150 | @echo "Sending E-mails..." 151 | @curl -s --user api:$(MailGunApiKey) \ 152 | https://api.mailgun.net/v2/$(MailGunDomain)/messages \ 153 | -F from='$(AppName)
......