70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BUILD_DIR="$ROOT_DIR/build"
|
|
ARTIFACTS_DIR="$ROOT_DIR/dist"
|
|
SCHEME="iKeyMon"
|
|
PROJECT="iKeyMon.xcodeproj"
|
|
CREDENTIALS_FILE="$ROOT_DIR/.signing.env"
|
|
|
|
if [[ -f "$CREDENTIALS_FILE" ]]; then
|
|
# shellcheck disable=SC1090
|
|
source "$CREDENTIALS_FILE"
|
|
fi
|
|
|
|
rm -rf "$BUILD_DIR" "$ARTIFACTS_DIR"
|
|
mkdir -p "$ARTIFACTS_DIR"
|
|
|
|
xcodebuild \
|
|
-project "$ROOT_DIR/$PROJECT" \
|
|
-scheme "$SCHEME" \
|
|
-configuration Release \
|
|
-derivedDataPath "$BUILD_DIR" \
|
|
clean build
|
|
|
|
APP_PATH="$BUILD_DIR/Build/Products/Release/iKeyMon.app"
|
|
if [[ ! -d "$APP_PATH" ]]; then
|
|
echo "❌ Failed to find built app at $APP_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n "${CODESIGN_IDENTITY:-}" ]]; then
|
|
echo "🔏 Codesigning app with identity: $CODESIGN_IDENTITY"
|
|
codesign --deep --force --options runtime --sign "$CODESIGN_IDENTITY" "$APP_PATH"
|
|
else
|
|
echo "⚠️ Skipping codesign (CODESIGN_IDENTITY not set)."
|
|
fi
|
|
|
|
VERSION=$(xcodebuild \
|
|
-project "$ROOT_DIR/$PROJECT" \
|
|
-scheme "$SCHEME" \
|
|
-configuration Release \
|
|
-showBuildSettings | awk '/MARKETING_VERSION/ {print $3; exit}')
|
|
if [[ -z "$VERSION" ]]; then
|
|
VERSION="dev"
|
|
fi
|
|
ZIP_NAME="iKeyMon-${VERSION}.zip"
|
|
pushd "$(dirname "$APP_PATH")" >/dev/null
|
|
zip -r "$ARTIFACTS_DIR/$ZIP_NAME" "$(basename "$APP_PATH")"
|
|
popd >/dev/null
|
|
|
|
DMG_NAME="iKeyMon-${VERSION}.dmg"
|
|
hdiutil create -volname "iKeyMon" -srcfolder "$APP_PATH" -ov -format UDZO "$ARTIFACTS_DIR/$DMG_NAME"
|
|
|
|
if [[ -n "${NOTARY_APPLE_ID:-}" && -n "${NOTARY_TEAM_ID:-}" && -n "${NOTARY_PASSWORD:-}" ]]; then
|
|
echo "📝 Submitting DMG for notarization..."
|
|
xcrun notarytool submit "$ARTIFACTS_DIR/$DMG_NAME" \
|
|
--apple-id "$NOTARY_APPLE_ID" \
|
|
--team-id "$NOTARY_TEAM_ID" \
|
|
--password "$NOTARY_PASSWORD" \
|
|
--wait
|
|
xcrun stapler staple "$ARTIFACTS_DIR/$DMG_NAME"
|
|
else
|
|
echo "⚠️ Skipping notarization (NOTARY_* variables not set)."
|
|
fi
|
|
|
|
echo "✅ Build complete. Artifacts:"
|
|
echo " - $ARTIFACTS_DIR/$ZIP_NAME"
|
|
echo " - $ARTIFACTS_DIR/$DMG_NAME"
|