- new Makefile

This commit is contained in:
Serhiy Mytrovtsiy
2020-07-04 23:00:21 +02:00
parent 6100ba7380
commit 457f370fc0
3 changed files with 77 additions and 51 deletions

1
.gitignore vendored
View File

@@ -8,5 +8,6 @@ xcuserdata
Stats.dmg Stats.dmg
Stats.app Stats.app
create-dmg create-dmg
dSYM.zip
Cartfile.resolved Cartfile.resolved

125
Makefile
View File

@@ -1,58 +1,73 @@
APP = Stats APP = Stats
BUNDLE_ID = eu.exelban.Stats BUNDLE_ID = eu.exelban.$(APP)
ITC_USERNAME = $(AC_USERNAME)
ITC_PASSWORD = @keychain:AC_PASSWORD
ITC_PROVIDER = $(AC_PROVIDER)
RequestUUID = 32c80f6c-36ed-4042-9837-b9093c9f4eb9
BUILD_PATH = $(PWD)/build BUILD_PATH = $(PWD)/build
ARCHIVE_PATH = $(BUILD_PATH)/$(APP).xcarchive
APP_PATH = "$(BUILD_PATH)/$(APP).app" APP_PATH = "$(BUILD_PATH)/$(APP).app"
ZIP_PATH = "$(BUILD_PATH)/$(APP).zip" ZIP_PATH = "$(BUILD_PATH)/$(APP).zip"
DMG_PATH = $(PWD)/$(APP).dmg
all: clean archive notarize sign build .SILENT: archive notarize sign prepare-dmg prepare-dSYM clean next-version check history
.PHONY: build archive notarize sign prepare-dmg prepare-dSYM clean next-version check history
clean: build: clean archive notarize sign prepare-dmg prepare-dSYM open
# rm -rf $(BUILD_PATH)
# --- MAIN WORLFLOW FUNCTIONS --- #
archive: next-version clean
echo "Starting archiving the project..."
.PHONY: archive
archive: clean
xcodebuild \ xcodebuild \
-scheme $(APP) \ -scheme $(APP) \
-destination 'platform=OS X,arch=x86_64' \ -destination 'platform=OS X,arch=x86_64' \
-configuration AppStoreDistribution archive \ -configuration AppStoreDistribution archive \
-archivePath $(ARCHIVE_PATH) -archivePath $(BUILD_PATH)/$(APP).xcarchive
xcodebuild \ echo "Application built, starting the export archive..."
-exportArchive \
xcodebuild -exportArchive \
-exportOptionsPlist "$(PWD)/exportOptions.plist" \ -exportOptionsPlist "$(PWD)/exportOptions.plist" \
-archivePath $(ARCHIVE_PATH) \ -archivePath $(BUILD_PATH)/$(APP).xcarchive \
-exportPath $(BUILD_PATH) -exportPath $(BUILD_PATH)
ditto -c -k --keepParent $(APP_PATH) $(ZIP_PATH) ditto -c -k --keepParent $(APP_PATH) $(ZIP_PATH)
.PHONY: notarize echo "Project archived successfully"
notarize: notarize:
xcrun altool \ echo "Starting notarizing the project..."
--notarize-app \
xcrun altool --notarize-app \
--primary-bundle-id $(BUNDLE_ID)\ --primary-bundle-id $(BUNDLE_ID)\
-itc_provider $(ITC_PROVIDER) \ -itc_provider $(AC_PROVIDER) \
-u $(ITC_USERNAME) \ -u $(AC_USERNAME) \
-p $(ITC_PASSWORD) \ -p @keychain:AC_PASSWORD \
--file $(ZIP_PATH) --file $(ZIP_PATH)
sleep 380 echo "Application sent to the notarization center"
sleep 30s
LAST_REQUEST="test"
.PHONY: sign
sign: sign:
echo "Checking if package is approved by Apple..."
while true; do \
if [[ "$$(xcrun altool --notarization-history 0 -itc_provider $(AC_PROVIDER) -u $(AC_USERNAME) -p @keychain:AC_PASSWORD | sed -n '6p')" == *"success"* ]]; then \
echo "OK" ;\
break ;\
fi ;\
echo "Package was not approved by Apple, recheck in 10s..."; \
sleep 10s ;\
done
echo "Going to staple an application..."
xcrun stapler staple $(APP_PATH) xcrun stapler staple $(APP_PATH)
spctl -a -t exec -vvv $(APP_PATH) spctl -a -t exec -vvv $(APP_PATH)
.PHONY: build echo "Application successfully stapled"
build: sign
prepare-dmg:
if [ ! -d $(PWD)/create-dmg ]; then \ if [ ! -d $(PWD)/create-dmg ]; then \
git clone https://github.com/andreyvit/create-dmg; \ git clone https://github.com/andreyvit/create-dmg; \
fi fi
@@ -66,33 +81,43 @@ build: sign
--icon "Stats.app" 125 175 \ --icon "Stats.app" 125 175 \
--hide-extension "Stats.app" \ --hide-extension "Stats.app" \
--app-drop-link 375 175 \ --app-drop-link 375 175 \
$(DMG_PATH) \ $(PWD)/$(APP).dmg \
$(APP_PATH) $(APP_PATH)
rm -rf ./create-dmg rm -rf ./create-dmg
# rm -rf $(BUILD_PATH)
open $(PWD) prepare-dSYM:
echo "Zipping dSYMs..."
zip -r $(PWD)/dSYM.zip $(BUILD_PATH)/Stats.xcarchive/dSYMs
echo "Created zip with dSYMs"
# --- HELPERS --- #
clean:
rm -rf $(BUILD_PATH)
if [ -a $(PWD)/dSYM.zip ]; then rm $(PWD)/dSYM.zip; fi;
if [ -a $(PWD)/Stats.dmg ]; then rm $(PWD)/Stats.dmg; fi;
next-version:
versionNumber=$$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$(PWD)/Stats/Supporting Files/Info.plist") ;\
echo "Actual version is: $$versionNumber" ;\
versionNumber=$$((versionNumber + 1)) ;\
echo "Next version is: $$versionNumber" ;\
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $$versionNumber" "$(PWD)/Stats/Supporting Files/Info.plist" ;\
check: check:
xcrun altool \ xcrun altool \
--notarization-info $(RequestUUID) \ --notarization-info 9b7c4d1f-ae81-4571-9ab1-592289f9d57a \
-itc_provider $(ITC_PROVIDER) \ -itc_provider $(AC_PROVIDER) \
-u $(ITC_USERNAME) \ -u $(AC_USERNAME) \
-p $(ITC_PASSWORD) -p @keychain:AC_PASSWORD
history: history:
xcrun altool \ xcrun altool --notarization-history 0 \
--notarization-history 0 \ -itc_provider $(AC_PROVIDER) \
-itc_provider $(ITC_PROVIDER) \ -u $(AC_USERNAME) \
-u $(ITC_USERNAME) \ -p @keychain:AC_PASSWORD
-p $(ITC_PASSWORD)
.PHONY: dep open:
dep: echo "Opening working folder..."
carthage update --platform macOS open $(PWD)
.PHONY: zip
zip:
cd ../
zip -r archive.zip ./
open $(PWD)

View File

@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string> <string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string> <string>1</string>
<key>Description</key> <key>Description</key>
<string>Simple macOS system monitor in your menu bar</string> <string>Simple macOS system monitor in your menu bar</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>