#!/usr/bin/env bash # Build, sign, notarise, staple and package Sprachmittler. Use --dry-run first. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" DRY_RUN=0 SKIP_NOTARIZE=0 VERSION="${MARKETING_VERSION:-0.1.0}" BUILD="$ROOT/build/release" ARCHIVE="$BUILD/Sprachmittler.xcarchive" APP="$ARCHIVE/Products/Applications/Sprachmittler.app" IDENTITY="${DEVELOPER_ID_APPLICATION:-}" PROFILE="${SPRACHMITTLER_NOTARY_PROFILE:-sprachmittler-notary}" for arg in "$@"; do case "$arg" in --dry-run) DRY_RUN=1 ;; --skip-notarize) SKIP_NOTARIZE=1 ;; --version=*) VERSION="${arg#*=}" ;; -h|--help) echo "usage: scripts/release.sh [--dry-run] [--skip-notarize] [--version=X.Y.Z]" echo "env: DEVELOPER_ID_APPLICATION, SPRACHMITTLER_NOTARY_PROFILE" exit 0 ;; *) echo "unknown argument: $arg" >&2; exit 2 ;; esac done run() { if [[ "$DRY_RUN" -eq 1 ]]; then printf '+ %s\n' "$*" else "$@" fi } if [[ "$DRY_RUN" -eq 0 && -z "$IDENTITY" ]]; then echo "DEVELOPER_ID_APPLICATION is required for a real release (Developer ID Application identity)." >&2 exit 2 fi for tool in xcodegen xcodebuild codesign ditto xcrun hdiutil; do command -v "$tool" >/dev/null || { echo "missing tool: $tool" >&2; exit 2; } done run mkdir -p "$BUILD" run xcodegen generate --spec project.yml run xcodebuild -project Sprachmittler.xcodeproj -scheme Sprachmittler -configuration Release \ -archivePath "$ARCHIVE" -destination 'platform=macOS,arch=arm64' \ CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO archive run codesign --force --deep --options runtime \ --entitlements App/Sprachmittler.entitlements --sign "$IDENTITY" "$APP" run codesign --verify --deep --strict --verbose=2 "$APP" if [[ "$SKIP_NOTARIZE" -eq 0 ]]; then run ditto -c -k --keepParent "$APP" "$BUILD/Sprachmittler.zip" run xcrun notarytool submit "$BUILD/Sprachmittler.zip" --keychain-profile "$PROFILE" --wait run xcrun stapler staple "$APP" run xcrun stapler validate "$APP" run spctl --assess --type execute --verbose=2 "$APP" else echo "warning: notarisation skipped (--skip-notarize)" >&2 fi run hdiutil create -volname "Sprachmittler $VERSION" -srcfolder "$APP" -ov -format UDZO \ "$BUILD/Sprachmittler-$VERSION.dmg" echo "Release artifacts: $BUILD"