Skip to content

Commit

Permalink
Merge pull request #7 from julienbordet/cicd-improve-app-preparation
Browse files Browse the repository at this point in the history
script for py2app, codesign, notarization and package building
  • Loading branch information
julienbordet authored Feb 8, 2022
2 parents 6998646 + 6ddf1ae commit 96b1933
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 10 deletions.
6 changes: 3 additions & 3 deletions menuping.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def manage_persistant(self, sender):
self.is_persistant = not self.is_persistant

def change_target(self, sender):
window = rumps.Window('Expected format : www.something.com', "Enter new address", cancel=True)
window = rumps.Window('Current target : ' + self.target_url, "Enter new address", cancel=True)

response = window.run()

Expand All @@ -91,7 +91,7 @@ def on_tick(self, sender):

def about(self, sender):
rumps.alert(title='MenuPing',
message="""Version 0.0.3 - FEV 2022 by J. Bordet
message="""Version 0.2 - FEV 2022 by J. Bordet
https://github.com/julienbordet/MenuPing
Simple Menubar app to monitor Internet connexion through ping
Expand All @@ -105,4 +105,4 @@ def about(self, sender):

if __name__ == "__main__":
app = MenuPingApp()
app.run()
app.run()
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
altgraph==0.17.2
macholib==1.15.2
modulegraph==0.19.2
ping3==3.0.2
py2app==0.27
pyobjc-core==8.2
pyobjc-framework-Cocoa==8.2
rumps==0.3.0
7 changes: 1 addition & 6 deletions resources/com.zejames.MenuPing-model.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
<array>
<string>#ownpath#</string>
</array>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<true/>
</dict>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
</plist>
8 changes: 8 additions & 0 deletions resources/entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
</dict>
</plist>
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
'argv_emulation': True,
'iconfile': 'icon.icns',
'plist': {
'CFBundleShortVersionString': '0.2.0',
'CFBundleShortVersionString': '0.2',
'CFBundleIdentifier': 'info.bordet.menuping',
'LSUIElement': True,
},
'packages': ['rumps', 'ping3'],
Expand Down
69 changes: 69 additions & 0 deletions utils/build_and_sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

export IDENTITY="Developer ID Application: Julien Bordet (3HLJ4AW5AX)"
export NAME="MenuPing"
export YOUR_BUNDLE_ID="info.bordet.menuping"

echo "------------------------------------"
echo "| Building and codesigning the app |"
echo "------------------------------------"

echo "Building through py2app"
python3 setup.py py2app >/dev/null 2>&1

echo "Signing librairies code"
cd dist

find "${NAME}.app" -iname '*.so' -or -iname '*.dylib' |
while read libfile; do
codesign --sign "${IDENTITY}" \
--entitlements ../resources/entitlements.plist \
--deep "${libfile}" \
--force \
--timestamp \
--options runtime;
done;

echo "Done"

echo "Signing the bundle"
codesign --sign "${IDENTITY}" \
--entitlements ../resources/entitlements.plist \
--deep "${NAME}.app" \
--force \
--timestamp \
--options runtime;

cd ..

#
# Creating archive for
#

echo "Creating archive"
ditto -c -k --keepParent "dist/${NAME}.app" dist/${NAME}.zip

#
# @keychain:AC_PASSWORD must have been inserte into keychain thanks to
# xcrun altool --store-password-in-keychain-item "AC_PASSWORD" -u "xxxx@gmail.com" -p "password"
#
# password must have been created in https://appleid.apple.com/account/manage / "App-Specific Passwords"
#

echo "Sending for notarization (can be a bit long)"
xcrun altool --notarize-app -t osx -f dist/${NAME}.zip --primary-bundle-id ${YOUR_BUNDLE_ID} \
-u zejames@gmail.com --password "@keychain:AC_PASSWORD"

echo "You should check the notarization result before creating the image for distribution"

#
# Notarization logs can be showed by
#
# xcrun altool --notarization-history 0 -u zejames@gmail.com --password "@keychain:AC_PASSWORD"
# or
# xcrun altool --verbose --notarization-history 0 -u zejames@gmail.com --password "@keychain:AC_PASSWORD"
#
#
# Staple the App
echo "After notarization, you should staple the app, with"
echo " # xcrun stapler staple " "dist/${NAME}.app"
61 changes: 61 additions & 0 deletions utils/create_img.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

echo "-----------------------------------------------"
echo "| Creating image for application distribution |"
echo "-----------------------------------------------"

echo ""
echo "Are you sure you did : "
echo " - update every occurence of the version number in code and interface"
echo " - launch build_and_sign"
echo ""
echo -n "Confirm (Y/n) "

read answer

if [ "$answer" = "n" ]; then
exit 1
fi

echo "Creating working directory"
cur_dir=`pwd`
temp_dir=`mktemp -d`
temp_vol=`mktemp`

if [ ! -d dist/MenuPing.app ]; then
echo " --> You lied, you did not create build the app"
exit 1
fi

if [ -f $cur_dir"/dist/MenuPing.dmg" ]; then
echo -n " --> Warning : target file dist/MenuPing.dmg already exists. Are you sure you want to overwrite ? (Y/n) "
read answer

if [ "$answer" = "n" ]; then
exit 1
else
rm $cur_dir"/dist/MenuPing.dmg"
fi
fi

cp -a dist/MenuPing.app $temp_dir
cd $temp_dir
ln -s /Applications/ Applications

echo -n "Creating dmgfile. "
hdiutil create $temp_vol.dmg -ov -volname "MenuPing" -fs HFS+ -srcfolder $cur_dir"/dist/MenuPing.app/" >/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Error creating the dmgfile"
exit 1
fi
echo "Done"

echo -n "Converting to application dmg. "
hdiutil convert $temp_vol.dmg -format UDZO -o $cur_dir"/dist/MenuPing.dmg" >/dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Error in conversion"
exit 1
fi
echo "Done"

0 comments on commit 96b1933

Please sign in to comment.