#!/bin/sh -e

#  upload_core_ui_frameworks.sh
#
#  Uploads all compiled framework flavors in MVMCoreUI to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release.
#
#  Copied from Hedden, Kyle Matthew on 3/2/18.
#

FRAMEWORK_VERSION=$(cd .. && agvtool vers -terse)
if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then
    echo This version tag has already been committed! Aborting!
    exit 1
fi

# Create new aggregate builds

if [ -z $ARTIFACTORY_URL ]; then
    ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory"
fi

# Upload
BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\  -f3-)
./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCoreUI.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCoreUI/[VER]/MVMCoreUI-[VER]-Debug-SNAPSHOT
