This commit is contained in:
Pfeil, Scott Robert 2021-06-30 12:02:42 -04:00
parent fbe37cc7be
commit 40785aee63
4 changed files with 180 additions and 4 deletions

92
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,92 @@
stages:
# - test
- download
# - build
# - deploy
#test:
# stage: test
# script:
# - echo "This job tests something"
# tags:
# - xcode_12_2
download_artifacts:
stage: download
script:
- cd Scripts && ./download_dependencies.sh
# - ./Scripts/download_dependencies.sh
only:
- branches
- feature/script_to_upload
tags:
- bash_shell
environment:
name: oneartifactory
url: https://oneartifactoryprod.verizon.com/artifactory
variables:
ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory
#build_project:
# stage: build
# script:
# - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty
# - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR)
# only:
# - branches
# - develop
# tags:
# - xcode_12_2
#
#deploy_snapshot:
# stage: deploy
# script:
# - cd Scripts && ./upload_core_frameworks.sh
# only:
# - branches
# - develop
# tags:
# - bash_shell
# environment:
# name: oneartifactory
# url: https://oneartifactoryprod.verizon.com/artifactory
# variables:
# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory
#promote_snapshot:
# stage: go live
# # Prevent artifacts from needing to re-download. Everything we need is in Artifactory.
# dependencies: []
# script:
# # Grab the framework version from the xcode project.
# - framework_ver=$(cd RemoteView && agvtool vers -terse)
# - cd Scripts && ./promote_remote_view_frameworks.sh $framework_ver
# only:
# - tags
# tags:
# - bash_shell
# environment:
# name: oneartifactory
# url: https://oneartifactoryprod.verizon.com/artifactory
# variables:
# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory
#
#create_version_tag:
# stage: tag
# when: manual
# # Prevent artifacts from needing to re-download.
# dependencies: []
# script:
# # Grab the framework version from the xcode project and create a tag of the version.
# - framework_ver=$(cd RemoteView && agvtool vers -terse)
# - git tag -a "v${framework_ver}" -m "Version ${framework_ver} created by gitlab-ci Build"
# # Extract the git repo url to ssh version (git@gitlab.verizon.com)
# - ci_push_repo="git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git"
# - echo $ci_push_repo
# # Set the remote url for pushing assuming the gitlab runner has SSH access to the repo.
# - git remote set-url --push origin $ci_push_repo
# - git push origin "v${framework_ver}"
# only:
# - develop
# tags:
# - bash_shell

View File

@ -2545,7 +2545,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n";
shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCoreUI\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\n#xcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\n#mkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\n#rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\n#cp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\n#lipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\n#mv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n";
};
/* End PBXShellScriptBuildPhase section */

View File

@ -4,7 +4,6 @@
#
# Downloads all compiled framework flavors in from Artifactory.
#
#
# Create new aggregate builds
@ -13,5 +12,5 @@ if [ -z $ARTIFACTORY_URL ]; then
fi
# Remote View Versions
BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-)
./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT
#BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-)
./download_framework.sh $ARTIFACTORY_URL "./MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/1.0/MVMCore-1.0-Debug-SNAPSHOT

85
Scripts/download_framework.sh Executable file
View File

@ -0,0 +1,85 @@
#!/bin/bash -e
# upload_framework.sh
#
# Downloads an iOS framework from Artificatory.
#
# An API key from Artifcatory is required in the api_key.private file before uploading.
#
URL=$1
LOCALPATH="${2}"
REMOTEPATH="${3}"
LOGFILE=$3
LOCALDIR=$(dirname "${LOCALPATH}")
LOCALBASE=$(basename "${LOCALPATH}")
NEWFILEPATH="${LOCALDIR}"/$(basename "${REMOTEPATH}")
VERSIONFILE=./Checksums/"${LOCALBASE}".txt
if [ -z $URL ]; then
echo "The artifactory instance url must be specified as the first argument!"
exit 1
fi
if [ -z $LOGFILE ]; then
LOGFILE="/tmp/${LOCALBASE}.txt"
fi
#first argument is error message.
exit_with_error () {
echo "Error: $1" >> "${LOGFILE}"
if [ -f "${NEWFILEPATH}" ]; then
rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}"
fi
exit 1
}
echo "----------------------------------------------------------" >> $LOGFILE
echo "Logs for ${LOCALBASE}" >> $LOGFILE
echo -e "Local Target: ${LOCALPATH}" >> $LOGFILE
echo -e "Remote Source: ${REMOTEPATH}" >> $LOGFILE
if [ -z "$LOCALPATH" ]; then
exit_with_error "Missing local path argument"
fi
if [ -z "$REMOTEPATH" ]; then
exit_with_error "Missing filename path argument"
fi
#get local and remote checksums for comparison
echo -e "Getting checksums..." >> $LOGFILE
echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" >> $LOGFILE
JSON=$(curl --header "X-JFrog-Art-Api: ${APITOKEN}" -X GET "${URL}/api/storage/${REMOTEPATH}" 2>>"${LOGFILE}")
CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') 2>>"${LOGFILE}"
if [[ -z "$CHECKSUM" ]]; then
exit_with_error "No Checksum found in json: ${JSON}"
fi
echo "Remote checksum ${CHECKSUM}" >> "${LOGFILE}"
OLDCHECKSUM=$(cat "${VERSIONFILE}" 2>/dev/null)
echo "Local checksum ${OLDCHECKSUM}" >> "${LOGFILE}"
#get new framework if no original framework, no local checksum, or remote checksum is different from local.
if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then
echo "Downloading..." >> "${LOGFILE}"
echo -e "URL: ${URL}/${REMOTEPATH}" >> $LOGFILE
curl --header "X-JFrog-Art-Api: ${APITOKEN}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" 2>>"${LOGFILE}"
if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then
echo "Finished Downloading, begin unzip" >> "${LOGFILE}"
unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" 2>>"${LOGFILE}"
if [ $? -eq 0 ]; then
echo "Finished unzipping, remove zip" >> "${LOGFILE}"
rm -rf "${NEWFILEPATH}" 2>>"${LOGFILE}"
echo "Writing new checksum to file" >> "${LOGFILE}"
echo "${CHECKSUM}" > "${VERSIONFILE}" 2>>"${LOGFILE}"
echo "Successfully downloaded and unzipped archive." >> "${LOGFILE}"
else
exit_with_error "Error unzipping"
fi
else
exit_with_error "Failed to download"
fi
else
echo "Successful, No New Version" >> "${LOGFILE}"
fi