#!/bin/zsh set -euo pipefail PROJECT_DIR="${PROJECT_DIR:-/Volumes/Developer/Applications/WorkbenchReplacement}" PHASE="${1:-57}" LABEL="${2:-Development}" RELEASE_DIR="${RELEASE_DIR:-$PROJECT_DIR/releases}" SCHEME="WorkbenchReplacement" if [[ ! "$PHASE" =~ '^[0-9]+$' ]]; then echo 'Usage: ./release-workbench.sh PHASE [Release-Label]' >&2 exit 2 fi if [[ ! -f "$PROJECT_DIR/WorkbenchReplacement.xcodeproj/project.pbxproj" ]]; then echo "Xcode project not found: $PROJECT_DIR" >&2 exit 1 fi if [[ ! -d "$PROJECT_DIR/docs" ]]; then echo 'docs/ directory is required.' >&2 exit 1 fi mkdir -p "$RELEASE_DIR" SAFE_LABEL=$(printf '%s' "$LABEL" | tr -cs 'A-Za-z0-9._-' '-') NAME="WorkbenchReplacement-Phase${PHASE}-${SAFE_LABEL}" DERIVED="$PROJECT_DIR/build" APP="$DERIVED/Build/Products/Release/${SCHEME}.app" echo "Building ${NAME}..." xcodebuild \ -project "$PROJECT_DIR/WorkbenchReplacement.xcodeproj" \ -scheme "$SCHEME" \ -configuration Release \ -destination 'platform=macOS,arch=arm64' \ -derivedDataPath "$DERIVED" \ CODE_SIGNING_ALLOWED=NO \ clean build if [[ ! -d "$APP" ]]; then echo "Build succeeded but app was not found: $APP" >&2 exit 1 fi # Source release excludes local build artifacts, git internals, and prior releases. SOURCE_ZIP="$RELEASE_DIR/${NAME}-Source.zip" ( cd "$PROJECT_DIR" /usr/bin/zip -qry "$SOURCE_ZIP" \ WorkbenchReplacement WorkbenchReplacement.xcodeproj docs \ -x '*.DS_Store' '*/.build/*' '*/DerivedData/*' ) APP_ZIP="$RELEASE_DIR/${NAME}-App-Unsigned.zip" ( cd "${APP:h}" /usr/bin/ditto -c -k --sequesterRsrc --keepParent "$APP:t" "$APP_ZIP" ) /usr/bin/unzip -tq "$SOURCE_ZIP" >/dev/null /usr/bin/unzip -tq "$APP_ZIP" >/dev/null printf '\nRelease completed:\n%s\n%s\n' "$SOURCE_ZIP" "$APP_ZIP" printf 'Note: App ZIP is unsigned and not notarized; intended for local testing.\n'