Skip to content

Commit 897ccd3

Browse files
committed
Build, sign and notarize the .dmg, and attempt upload to macOS App Store
1 parent dc891a1 commit 897ccd3

File tree

3 files changed

+104
-36
lines changed

3 files changed

+104
-36
lines changed

GNUmakefile

Lines changed: 101 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
# Change to your own Apple Developer ID, if you want to code-sign the resultant .app
6+
67
TEAMID ?= ZD8TVTCXDS
78
#DEVID ?= 3rd Party Mac Developer Application: Perry Kundert ($(TEAMID))
89
DEVID ?= Developer ID Application: Perry Kundert ($(TEAMID))
@@ -69,40 +70,82 @@ install: dist/slip39-$(VERSION)-py3-none-any.whl FORCE
6970

7071
app: dist/SLIP39.app
7172

72-
# Generate, Sign and Zip the macOS SLIP39.app GUI package for local/manual installation
73-
app-zip: dist/SLIP39-$(VERSION).app.zip
73+
app-upload: dist/SLIP39-$(VERSION).dmg.uploaded
7474

75-
# Generate, Sign and Pacakage the macOS SLIP39.app GUI package for App Store
75+
76+
# Generate, Sign and Package the macOS SLIP39.app GUI for App Store or local/manual installation
77+
app-dmg: dist/SLIP39-$(VERSION).dmg
78+
app-zip: dist/SLIP39-$(VERSION).zip
7679
app-pkg: dist/SLIP39-$(VERSION).pkg
77-
app-pkg-signed: dist/SLIP39-$(VERSION)-signed.pkg
7880

79-
#
80-
# Build a deployable macOS App
81-
# See: https://gist.github.com/txoof/0636835d3cc65245c6288b2374799c43
82-
# See: https://wiki.lazarus.freepascal.org/Code_Signing_for_macOS
83-
app-upload: dist/SLIP39-$(VERSION).app.zip
84-
xcrun altool --validate-app -f $< -t osx --apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
85-
&& xcrun altool --upload-app -f $< -t osx --apiKey $(APIKEY) --apiIssuer $(APIISSUER)
86-
87-
# dist/SLIP39-$(VERSION).pkg: dist/SLIP39.app FORCE
88-
# pkgbuild --install-location /Applications --component $< $@
89-
90-
#--identifier $(BUNDLEID)
91-
# codesign -vvvv -R="anchor apple" $</Contents/MacOS/Python \
92-
# || codesign --deep --force --options=runtime --timestamp \
93-
# --entitlements ./SLIP39.metadata/entitlements.plist \
94-
# --sign "$(DEVID)" \
95-
# $< \
96-
# && codesign -vvvv -R="anchor apple" $</Contents/MacOS/Python
97-
# codesign -vvvv -R="anchor apple" $</Contents/MacOS/Python
98-
99-
# doesn't work... code is not signed by an apple-anchored Dev. ID
81+
82+
#
83+
# Build the macOS App, and create and sign the .dmg file
84+
#
85+
# o Uses https://github.com/sindresorhus/create-dmg
86+
# - npm install --global create-dmg
87+
# - Renames the resultant file from "SLIP39 1.2.3.dmg" to "SLIP39-1.2.3.dmg"
88+
# - It automatically finds the correct signing key (unkown)
89+
#
90+
dist/SLIP39-$(VERSION).dmg: dist/SLIP39.app
91+
@echo "\n\n*** Creating and signing DMG $@..."
92+
npx create-dmg --overwrite $<
93+
mv "SLIP39 $(VERSION).dmg" "$@"
94+
@echo "Checking signature..."; ./SLIP39.metadata/check-signature $@
95+
96+
# Upload the .dmg, unless we've already uploaded it and have a RequestUUID
97+
dist/SLIP39-$(VERSION).dmg.notarization: dist/SLIP39-$(VERSION).dmg
98+
jq -r '.["notarization-upload"]["RequestUUID"]' $@ 2>/dev/null \
99+
|| xcrun altool --notarize-app -f $< \
100+
--primary-bundle-id $(BUNDLEID) \
101+
--team-id $(TEAMID) \
102+
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
103+
--output-format json \
104+
> $@
105+
106+
# Refresh the ...dmg.notariation-status, unless it is already "Status: success"
107+
dist/SLIP39-$(VERSION).dmg.notarization-status: dist/SLIP39-$(VERSION).dmg.notarization FORCE
108+
[ -s $@ ] && grep "Status: success" $@ \
109+
|| xcrun altool \
110+
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
111+
--notarization-info $$( jq -r '.["notarization-upload"]["RequestUUID"]' $< ) \
112+
| tee -a $@
113+
114+
# Check notarization status 'til Status: success, then staple it to ...dmg, and create ...dmg.final marker file
115+
dist/SLIP39-$(VERSION).dmg.valid: dist/SLIP39-$(VERSION).dmg.notarization-status FORCE
116+
grep "Status: success" $< || \
117+
( tail -10 $<; echo "\n\n!!! App not yet notarized; cannot produce $@"; false )
118+
( [ -r $@ ] ) \
119+
&& ( echo "\n\n*** Notarization complete; refreshing $@" && touch $@ ) \
120+
|| ( \
121+
xcrun stapler staple dist/SLIP39-$(VERSION).dmg && \
122+
xcrun stapler validate dist/SLIP39-$(VERSION).dmg && \
123+
echo "\n\n*** Notarization attached to $@" && \
124+
touch $@ \
125+
)
126+
127+
# macOS ...dmg App Upload: Unless the ...dmg.upload file exists and is non-empty
128+
dist/SLIP39-$(VERSION).dmg.uploaded: dist/SLIP39-$(VERSION).dmg dist/SLIP39-$(VERSION).dmg.valid FORCE
129+
[ -s $@ ] || ( \
130+
echo "\n\n*** Uploading the signed DMG file: $<..." && \
131+
echo "*** Verifying notarization stapling..." && xcrun stapler validate $< && \
132+
echo "*** Checking signature..." && ./SLIP39.metadata/check-signature $< && \
133+
echo "*** Upload starting for $<..." && \
134+
xcrun altool --upload-package $< \
135+
--type macos \
136+
--bundle-id $(BUNDLEID) --bundle-version $(VERSION) --bundle-short-version-string $(VERSION) \
137+
--apple-id $(APPLEID) --team $(TEAMID) \
138+
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
139+
| tee -a $@ \
140+
)
141+
100142
#
101143
# Create the .pkg, ensuring that the App was created and signed appropriately
102144
# o Sign this w/ the ...Developer ID?
103145
# - Nope: "...An installer signing identity (not an application signing identity) is required for signing flat-style products."
104146
# See: https://lessons.livecode.com/m/4071/l/876834-signing-and-uploading-apps-to-the-mac-app-store
105147
# o Need ... --product <path-to-app-bundle-Info.plist>
148+
#
106149
dist/SLIP39-$(VERSION).pkg: dist/SLIP39.app \
107150
dist/SLIP39.app-signed
108151
productbuild --sign "$(PKGID)" --timestamp \
@@ -113,7 +156,7 @@ dist/SLIP39-$(VERSION).pkg: dist/SLIP39.app \
113156
xcrun altool --validate-app -f $@ -t osx --apiKey $(APIKEY) --apiIssuer $(APIISSUER)
114157

115158
dist/SLIP39.pkg: dist/SLIP39.app # dist/SLIP39.app-signed
116-
echo "Checking signature..."; ./SLIP39.metadata/check-signature $<
159+
@echo "Checking signature..."; ./SLIP39.metadata/check-signature $<
117160
productbuild --sign "$(PKGID)" --timestamp \
118161
--identifier "$(BUNDLEID).pkg" \
119162
--version $(VERSION) \
@@ -144,15 +187,19 @@ dist/SLIP39-signed.pkg: dist/SLIP39.pkg FORCE
144187
productsign --timestamp --sign "$(PKGID)" $< $@
145188

146189

147-
190+
#
148191
# macOS Package Notarization
149192
# See: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues
150-
193+
# See: https://oozou.com/blog/scripting-notarization-for-macos-app-distribution-38
194+
# o The .pkg version doesn't work due to incorrect signing keys for the .pkg (unknown reason)
195+
# o The .zip version works, but the notarization cannot be stapled to the zip;
196+
# - We have to receive notification that the SLIP39.zip.notarization-status Status: success
197+
# - Then, re-package the zip and
151198
dist/SLIP39.pkg.notarization: dist/SLIP39.pkg
152199
jq -r '.["notarization-upload"]["RequestUUID"]' $@ 2>/dev/null \
153200
|| xcrun altool --notarize-app -f $< \
201+
--primary-bundle-id $(BUNDLEID) \
154202
--team-id $(TEAMID) \
155-
--primary-bundle-id ca.kundert.perry.SLIP39 \
156203
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
157204
--output-format json \
158205
> $@
@@ -166,20 +213,41 @@ dist/SLIP39.pkg.notarization-status: dist/SLIP39.pkg.notarization FORCE
166213
dist/SLIP39.zip.notarization: dist/SLIP39.zip
167214
jq -r '.["notarization-upload"]["RequestUUID"]' $@ 2>/dev/null \
168215
|| xcrun altool --notarize-app -f $< \
216+
--primary-bundle-id $(BUNDLEID) \
169217
--team-id $(TEAMID) \
170-
--primary-bundle-id ca.kundert.perry.SLIP39 \
171218
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
172219
--output-format json \
173220
> $@
174221

175222
dist/SLIP39.zip.notarization-status: dist/SLIP39.zip.notarization FORCE
223+
176224
xcrun altool \
177225
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
178226
--notarization-info $$( jq -r '.["notarization-upload"]["RequestUUID"]' $< ) \
179227
| tee -a $@
180228

181-
182-
229+
dist/SLIP39-$(VERSION)-final.zip: dist/SLIP39.zip.notarization-status
230+
grep "Status: success" $< || \
231+
( tail -10 $<; echo "\n\n!!! App not yet notarized; cannot produce $@"; false )
232+
( [ -r $@ ] ) \
233+
&& ( echo "\n\n*** Notarization compete; not re-generating $@"; true ) \
234+
|| ( \
235+
xcrun stapler staple dist/SLIP39.app; \
236+
xcrun stapler validate dist/SLIP39.app; \
237+
echo "\n\n*** Notarization attached; creating $@"; \
238+
/usr/bin/ditto -c -k --keepParent "dist/SLIP39.app" "$@"; \
239+
ls -last dist; \
240+
)
241+
#
242+
# macOS App Upload: Unless the ...zip.upload file exists and is non-zero
243+
#
244+
dist/SLIP39-$(VERSION)-final.zip.upload: dist/SLIP39-$(VERSION)-final.zip FORCE
245+
[ -s $@ ] || xcrun altool --upload-package $< \
246+
--type macos \
247+
--bundle-id $(BUNDLEID) --bundle-version $(VERSION) --bundle-short-version-string $(VERSION) \
248+
--apple-id $(APPLEID) \
249+
--apiKey $(APIKEY) --apiIssuer $(APIISSUER) \
250+
| tee -a $@
183251
#
184252
# Package the macOS App as a Zip file for Notarization
185253
#
@@ -242,7 +310,7 @@ dist/SLIP39.app-checkids: SLIP39.spec
242310
dist/SLIP39.app: SLIP39.spec \
243311
SLIP39.metadata/entitlements.plist \
244312
images/SLIP39.icns
245-
@echo "\n\n*** Rebuilding $@..."
313+
@echo "\n\n*** Rebuilding $@, version $(VERSION)..."
246314
rm -rf build $@*
247315
sed -I "" -E "s/version=.*/version='$(VERSION)',/" $<
248316
sed -I "" -E "s/'CFBundleVersion':.*/'CFBundleVersion':'$(VERSION)',/" $<

SLIP39.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ coll = COLLECT(exe,
4949
app = BUNDLE(coll,
5050
name='SLIP39.app',
5151
icon='images/SLIP39.icns',
52-
version='6.5.5',
52+
version='6.6.2',
5353
info_plist={
54-
'CFBundleVersion':'6.5.5',
54+
'CFBundleVersion':'6.6.2',
5555
'LSApplicationCategoryType':'public.app-category.finance',
5656
'LSMinimumSystemVersion':'10.15.0',
5757
},

slip39/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ( 6, 5, 5 )
1+
__version_info__ = ( 6, 6, 2 )
22
__version__ = '.'.join( map( str, __version_info__ ))

0 commit comments

Comments
 (0)