Files
macos-stats/Makefile

129 lines
3.8 KiB
Makefile
Raw Normal View History

2019-07-04 19:30:19 +02:00
APP = Stats
2020-07-04 23:00:21 +02:00
BUNDLE_ID = eu.exelban.$(APP)
2019-07-04 19:30:19 +02:00
2019-07-04 20:53:18 +02:00
BUILD_PATH = $(PWD)/build
APP_PATH = "$(BUILD_PATH)/$(APP).app"
ZIP_PATH = "$(BUILD_PATH)/$(APP).zip"
2019-07-04 19:30:19 +02:00
2020-11-29 12:51:53 +01:00
.SILENT: archive notarize sign prepare-dmg prepare-dSYM clean next-version check history disk
.PHONY: build archive notarize sign prepare-dmg prepare-dSYM clean next-version check history open
2019-07-04 19:30:19 +02:00
2020-07-04 23:01:54 +02:00
build: clean next-version archive notarize sign prepare-dmg prepare-dSYM open
2020-07-04 23:00:21 +02:00
# --- MAIN WORLFLOW FUNCTIONS --- #
2020-11-29 12:51:53 +01:00
archive: clean
osascript -e 'display notification "Exporting application archive..." with title "Build the Stats"'
echo "Exporting application archive..."
2019-07-04 19:30:19 +02:00
xcodebuild \
2019-07-04 20:53:18 +02:00
-scheme $(APP) \
2019-07-04 19:30:19 +02:00
-destination 'platform=OS X,arch=x86_64' \
2020-10-18 19:06:10 +02:00
-configuration Release archive \
2020-07-04 23:00:21 +02:00
-archivePath $(BUILD_PATH)/$(APP).xcarchive
2019-07-04 19:30:19 +02:00
2020-07-04 23:00:21 +02:00
echo "Application built, starting the export archive..."
xcodebuild -exportArchive \
2019-07-04 20:53:18 +02:00
-exportOptionsPlist "$(PWD)/exportOptions.plist" \
2020-07-04 23:00:21 +02:00
-archivePath $(BUILD_PATH)/$(APP).xcarchive \
2019-07-04 20:53:18 +02:00
-exportPath $(BUILD_PATH)
2019-07-04 19:30:19 +02:00
2019-07-04 20:53:18 +02:00
ditto -c -k --keepParent $(APP_PATH) $(ZIP_PATH)
2019-07-04 19:30:19 +02:00
2020-07-04 23:00:21 +02:00
echo "Project archived successfully"
2019-07-04 20:53:18 +02:00
notarize:
2020-11-29 12:51:53 +01:00
osascript -e 'display notification "Submitting app for notarization..." with title "Build the Stats"'
echo "Submitting app for notarization..."
2020-07-04 23:00:21 +02:00
xcrun altool --notarize-app \
2019-07-04 20:53:18 +02:00
--primary-bundle-id $(BUNDLE_ID)\
2020-07-04 23:00:21 +02:00
-itc_provider $(AC_PROVIDER) \
-u $(AC_USERNAME) \
-p @keychain:AC_PASSWORD \
--file $(ZIP_PATH)
2019-07-04 19:30:19 +02:00
2020-07-04 23:00:21 +02:00
echo "Application sent to the notarization center"
sleep 30s
LAST_REQUEST="test"
2019-07-04 19:30:19 +02:00
sign:
2020-11-29 12:51:53 +01:00
osascript -e 'display notification "Checking if package is approved by Apple..." with title "Build the Stats"'
2020-07-04 23:00:21 +02:00
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..."
2019-07-04 19:30:19 +02:00
xcrun stapler staple $(APP_PATH)
spctl -a -t exec -vvv $(APP_PATH)
2020-11-29 12:51:53 +01:00
osascript -e 'display notification "Stats successfully stapled" with title "Build the Stats"'
echo "Stats successfully stapled"
2020-07-04 23:00:21 +02:00
prepare-dmg:
2019-07-04 19:30:19 +02:00
if [ ! -d $(PWD)/create-dmg ]; then \
git clone https://github.com/andreyvit/create-dmg; \
fi
./create-dmg/create-dmg \
--volname $(APP) \
--background "./Stats/Supporting Files/background.png" \
2019-07-04 19:30:19 +02:00
--window-pos 200 120 \
--window-size 500 320 \
--icon-size 80 \
--icon "Stats.app" 125 175 \
--hide-extension "Stats.app" \
--app-drop-link 375 175 \
2020-07-04 23:00:21 +02:00
$(PWD)/$(APP).dmg \
2019-07-04 19:30:19 +02:00
$(APP_PATH)
rm -rf ./create-dmg
2020-07-04 23:00:21 +02:00
prepare-dSYM:
echo "Zipping dSYMs..."
2020-07-09 16:30:49 +02:00
cd $(BUILD_PATH)/Stats.xcarchive/dSYMs && zip -r $(PWD)/dSYMs.zip .
2020-07-04 23:00:21 +02:00
echo "Created zip with dSYMs"
# --- HELPERS --- #
clean:
rm -rf $(BUILD_PATH)
if [ -a $(PWD)/dSYMs.zip ]; then rm $(PWD)/dSYMs.zip; fi;
2020-07-04 23:00:21 +02:00
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" ;\
2019-07-04 19:30:19 +02:00
check:
xcrun altool \
2020-11-01 11:53:07 +01:00
--notarization-info 36ba52a7-97bb-43e7-8faf-72bd6e9e1df3 \
2020-07-04 23:00:21 +02:00
-itc_provider $(AC_PROVIDER) \
-u $(AC_USERNAME) \
-p @keychain:AC_PASSWORD
2019-07-04 19:30:19 +02:00
history:
2020-07-04 23:00:21 +02:00
xcrun altool --notarization-history 0 \
-itc_provider $(AC_PROVIDER) \
-u $(AC_USERNAME) \
-p @keychain:AC_PASSWORD
open:
2020-11-29 12:51:53 +01:00
osascript -e 'display notification "Stats signed and ready for distribution" with title "Build the Stats"'
2020-07-04 23:00:21 +02:00
echo "Opening working folder..."
open $(PWD)