notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

macos_build.sh (2378B)


      1 #!/bin/bash
      2 
      3 set -e  # Exit immediately if a command exits with a non-zero status
      4 set -u  # Treat unset variables as an error
      5 set -o pipefail  # Catch errors in pipelines
      6 
      7 # Ensure the script is running in the correct directory
      8 NAME="Notedeck"
      9 REQUIRED_DIR="notedeck"
     10 ARCH=${ARCH:-"aarch64"}
     11 TARGET=${TARGET:-${ARCH}-apple-darwin}
     12 CURRENT_DIR=$(basename "$PWD")
     13 
     14 if [ "$CURRENT_DIR" != "$REQUIRED_DIR" ]; then
     15     echo "Error: This script must be run from the '$REQUIRED_DIR' directory."
     16     exit 1
     17 fi
     18 
     19 # Ensure all required variables are set
     20 REQUIRED_VARS=(NOTEDECK_APPLE_RELEASE_CERT_ID NOTEDECK_RELEASE_APPLE_ID NOTEDECK_APPLE_APP_SPECIFIC_PW NOTEDECK_APPLE_TEAM_ID)
     21 for VAR in "${REQUIRED_VARS[@]}"; do
     22     if [ -z "${!VAR:-}" ]; then
     23         echo "Error: Required variable '$VAR' is not set." >&2
     24         exit 1
     25     fi
     26 done
     27 
     28 # Ensure required tools are installed
     29 if ! command -v cargo &> /dev/null; then
     30     echo "Error: cargo is not installed." >&2
     31     exit 1
     32 fi
     33 
     34 if ! command -v xcrun &> /dev/null; then
     35     echo "Error: xcrun is not installed." >&2
     36     exit 1
     37 fi
     38 
     39 if ! command -v create-dmg &> /dev/null; then
     40     echo "Error: create-dmg is not installed." >&2
     41     exit 1
     42 fi
     43 
     44 # Build the .app bundle
     45 echo "Building .app bundle..."
     46 cargo bundle --release --target $TARGET
     47 
     48 # Sign the app
     49 echo "Codesigning the app..."
     50 codesign \
     51   --deep \
     52   --force \
     53   --verify \
     54   --options runtime \
     55   --entitlements entitlements.plist \
     56   --sign "$NOTEDECK_APPLE_RELEASE_CERT_ID" \
     57   target/${TARGET}/release/bundle/osx/$NAME.app
     58 
     59 # Create a zip for notarization
     60 echo "Creating zip for notarization..."
     61 zip -r notedeck.zip target/${TARGET}/release/bundle/osx/$NAME.app
     62 
     63 # Submit for notarization
     64 echo "Submitting for notarization..."
     65 xcrun notarytool submit \
     66   --apple-id "$NOTEDECK_RELEASE_APPLE_ID" \
     67   --password "$NOTEDECK_APPLE_APP_SPECIFIC_PW" \
     68   --team-id "$NOTEDECK_APPLE_TEAM_ID" \
     69   --wait \
     70   notedeck.zip
     71 
     72 # Staple the notarization
     73 echo "Stapling notarization to the app..."
     74 xcrun stapler staple target/${TARGET}/release/bundle/osx/$NAME.app
     75 
     76 echo "Removing notedeck.zip"
     77 rm notedeck.zip
     78 
     79 # Create the .dmg package
     80 echo "Creating .dmg package..."
     81 mkdir -p packages
     82 create-dmg \
     83   --window-size 600 400 \
     84   --app-drop-link 400 100 \
     85   packages/$NAME-${ARCH}.dmg \
     86   target/${TARGET}/release/bundle/osx/$NAME.app
     87 
     88 echo "Build and signing process completed successfully."