Voxley / app · voxley.si / Scripts / release-dmg.sh
| 1 | #!/bin/bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | root="$(cd "$(dirname "$0")/.." && pwd)" |
| 5 | output="${1:?Usage: Scripts/release-dmg.sh RELEASE_DIRECTORY NOTARYTOOL_OPTIONS...}" |
| 6 | shift |
| 7 | [[ "$output" == /Volumes/Expand/* && -d "$output/Voxley.app" && $# -gt 0 ]] || { |
| 8 | echo 'Supply a signed release directory on Expand and notarytool authentication options.' >&2 |
| 9 | exit 1 |
| 10 | } |
| 11 | base='/Volumes/Expand/Projects/Voxley/app-work/Build' |
| 12 | mkdir -p "$base/tmp" |
| 13 | export TMPDIR="$base/tmp/" |
| 14 | python="${VOXLEY_DMG_PYTHON:-$base/dmg-tools/bin/python}" |
| 15 | app="$output/Voxley.app" |
| 16 | version=$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$app/Contents/Info.plist") |
| 17 | identity="$(codesign -d --verbose=2 "$app" 2>&1 | sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p')" |
| 18 | [[ -n "$identity" ]] || { echo 'A Developer ID signed Voxley.app is required.' >&2; exit 1; } |
| 19 | image="$output/Voxley-$version.dmg" |
| 20 | packager=("$python" "$root/Scripts/package-mac-dmg.py" --app "$app" --output "$image") |
| 21 | if [[ -f "$image" ]]; then |
| 22 | "${packager[@]}" --verify-only |
| 23 | else |
| 24 | "${packager[@]}" |
| 25 | fi |
| 26 | if ! xcrun stapler validate "$image" >/dev/null 2>&1; then |
| 27 | codesign --force --timestamp --sign "$identity" "$image" |
| 28 | xcrun notarytool submit "$image" "$@" --wait --output-format json > "${image%.dmg}.notarization.json" |
| 29 | /usr/bin/plutil -extract status raw -expect string "${image%.dmg}.notarization.json" | /usr/bin/grep -Fx Accepted |
| 30 | xcrun stapler staple "$image" |
| 31 | fi |
| 32 | codesign --verify --strict "$image" |
| 33 | xcrun stapler validate "$image" |
| 34 | spctl --assess --type open --context context:primary-signature --verbose=2 "$image" |
| 35 | "${packager[@]}" --verify-only |
| 36 | |
| 37 | sparkle="$(bash "$root/Scripts/prepare-sparkle.sh" "$base")" |
| 38 | account=voxley-direct |
| 39 | public_key=$(/usr/libexec/PlistBuddy -c 'Print SUPublicEDKey' "$app/Contents/Info.plist") |
| 40 | [[ "$("$sparkle/bin/generate_keys" --account "$account" -p)" == "$public_key" ]] || { |
| 41 | echo 'The Sparkle signing key does not match this app.' >&2 |
| 42 | exit 1 |
| 43 | } |
| 44 | "$sparkle/bin/generate_appcast" --account "$account" --maximum-deltas 0 \ |
| 45 | --download-url-prefix https://voxley.si/downloads/ "$output" |
| 46 | signature="$(xmllint --xpath 'string(//enclosure/@*[local-name()="edSignature"])' "$output/appcast.xml")" |
| 47 | "$sparkle/bin/sign_update" --account "$account" --verify "$image" "$signature" |
| 48 | "$sparkle/bin/sign_update" --account "$account" --verify "$output/appcast.xml" |
| 49 | (cd "$output" && shasum -a 256 "$(basename "$image")" > SHA256SUMS) |
| 50 | printf '%s\n' "$image" |