[16776] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | set -Eeou pipefail |
---|
| 4 | |
---|
| 5 | # Don't show one time passwords |
---|
| 6 | set +x |
---|
| 7 | |
---|
| 8 | SIGNING_KEY_NAME="Developer ID Application: FOSSGIS e.V. (P8AAAGN2AM)" |
---|
| 9 | IMPORT_AND_UNLOCK_KEYCHAIN=${IMPORT_AND_UNLOCK_KEYCHAIN:-1} |
---|
| 10 | |
---|
| 11 | if [ -z "${1-}" ] |
---|
| 12 | then |
---|
| 13 | echo "Usage: $0 josm_revision" |
---|
| 14 | exit 1 |
---|
| 15 | fi |
---|
| 16 | |
---|
| 17 | echo "Building JOSM.app" |
---|
| 18 | |
---|
[17239] | 19 | mkdir app |
---|
[16776] | 20 | jpackage -n "JOSM" --input dist --main-jar josm-custom.jar \ |
---|
| 21 | --main-class org.openstreetmap.josm.gui.MainApplication \ |
---|
[17239] | 22 | --icon ./native/macosx/JOSM.icns --type app-image --dest app \ |
---|
[16776] | 23 | --java-options "-Xmx8192m" --app-version $1 \ |
---|
| 24 | --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" \ |
---|
| 25 | --vendor "https://josm.openstreetmap.de" \ |
---|
| 26 | --file-associations native/macosx/bz2.properties \ |
---|
| 27 | --file-associations native/macosx/geojson.properties \ |
---|
| 28 | --file-associations native/macosx/gpx.properties \ |
---|
| 29 | --file-associations native/macosx/gz.properties \ |
---|
| 30 | --file-associations native/macosx/jos.properties \ |
---|
| 31 | --file-associations native/macosx/joz.properties \ |
---|
| 32 | --file-associations native/macosx/osm.properties \ |
---|
| 33 | --file-associations native/macosx/zip.properties \ |
---|
| 34 | --add-modules java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom |
---|
| 35 | |
---|
| 36 | echo "Building done." |
---|
| 37 | |
---|
| 38 | if [[ $IMPORT_AND_UNLOCK_KEYCHAIN == 1 ]]; then |
---|
| 39 | if [ -z "$CERT_MACOS_P12" ] |
---|
| 40 | then |
---|
| 41 | echo "CERT_MACOS_P12 must be set in the environment. Won't sign app." |
---|
| 42 | exit 1 |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | if [ -z "$CERT_MACOS_PW" ] |
---|
| 47 | then |
---|
| 48 | echo "CERT_MACOS_P12 must be set in the environment. Won't sign app." |
---|
| 49 | exit 1 |
---|
| 50 | fi |
---|
| 51 | |
---|
| 52 | echo "Preparing certificates/keychain for signing…" |
---|
| 53 | |
---|
| 54 | KEYCHAIN=build.keychain |
---|
| 55 | KEYCHAIN_PW=`head /dev/urandom | base64 | head -c 20` |
---|
| 56 | CERTIFICATE_P12=certificate.p12 |
---|
| 57 | |
---|
| 58 | echo $CERT_MACOS_P12 | base64 --decode > $CERTIFICATE_P12 |
---|
| 59 | security create-keychain -p $KEYCHAIN_PW $KEYCHAIN |
---|
| 60 | security default-keychain -s $KEYCHAIN |
---|
| 61 | security unlock-keychain -p $KEYCHAIN_PW $KEYCHAIN |
---|
| 62 | security import $CERTIFICATE_P12 -k $KEYCHAIN -P $CERT_MACOS_PW -T /usr/bin/codesign |
---|
| 63 | security set-key-partition-list -S apple-tool:,apple: -s -k $KEYCHAIN_PW $KEYCHAIN |
---|
| 64 | rm $CERTIFICATE_P12 |
---|
| 65 | |
---|
| 66 | echo "Signing preparation done." |
---|
| 67 | fi |
---|
| 68 | |
---|
| 69 | echo "Signing App Bundle…" |
---|
| 70 | |
---|
| 71 | codesign -vvv --timestamp --options runtime --deep --force --sign "$SIGNING_KEY_NAME" \ |
---|
[17239] | 72 | app/JOSM.app/Contents/MacOS/JOSM \ |
---|
| 73 | app/JOSM.app/Contents/runtime/Contents/Home/lib/*.jar \ |
---|
| 74 | app/JOSM.app/Contents/runtime/Contents/Home/lib/*.dylib \ |
---|
| 75 | app/JOSM.app/Contents/runtime/Contents/MacOS/libjli.dylib |
---|
[16776] | 76 | |
---|
[17239] | 77 | codesign -vvv --timestamp --entitlements native/macosx/josm.entitlements --options runtime --force --sign "$SIGNING_KEY_NAME" app/JOSM.app |
---|
[16776] | 78 | |
---|
[17239] | 79 | codesign -vvv app/JOSM.app |
---|
[16776] | 80 | |
---|
| 81 | echo "Preparing for notarization" |
---|
[17239] | 82 | ditto -c -k --zlibCompressionLevel 9 --keepParent app/JOSM.app app/JOSM.zip |
---|
[16776] | 83 | |
---|
| 84 | echo "Uploading to Apple" |
---|
[17239] | 85 | xcrun altool --notarize-app -f app/JOSM.zip -p "$APPLE_ID_PW" -u "thomas.skowron@fossgis.de" --primary-bundle-id de.openstreetmap.josm |
---|