133 lines
3.2 KiB
Bash
Executable File
133 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
unlock_login_keychain() {
|
|
if [ -z "$1" ]; then
|
|
echo "Password parameter must be exists"
|
|
return 1
|
|
fi
|
|
local timeout=3600
|
|
if [ -n "$2" ]; then
|
|
timeout=$2
|
|
fi
|
|
|
|
security list-keychains -s ~/Library/Keychains/login.keychain-db
|
|
security unlock-keychain -p $1 ~/Library/Keychains/login.keychain-db
|
|
security set-keychain-settings -t $timeout -l ~/Library/Keychains/login.keychain-db
|
|
}
|
|
|
|
#Passed external variables
|
|
DEPLOY_TYPE=$1
|
|
if [ "$DEPLOY_TYPE" == "PRODUCTION" ]; then
|
|
DEPLOY_TYPE="PROD"
|
|
else
|
|
DEPLOY_TYPE="BETA"
|
|
fi
|
|
|
|
# Detect configuration for building
|
|
CONFIG=""
|
|
if [ "$CI_COMMIT_REF_SLUG" == "master" ]; then
|
|
CONFIG="Production"
|
|
else
|
|
CONFIG="Release"
|
|
fi
|
|
|
|
ROOT=$(pwd)
|
|
IOS_PATH=$ROOT/iOS
|
|
DEVELOPER_SIGNATURE="iPhone Distribution: PRIVADO NETWORKS LLC (4D7YV49724)"
|
|
|
|
#Remove Delivered data
|
|
rm -rf ~/Library/Developer/Xcode/DerivedData
|
|
|
|
APPLICATION_NAME=PrivadoVPN
|
|
|
|
DERIVED_PATH=$ROOT/DERIVED
|
|
ARCHIVE_PATH=$ROOT/$APPLICATION_NAME.xcarchive
|
|
IPA_PATH=$ROOT/PrivadoIPA
|
|
FULL_IPA_PATH=$IPA_PATH/$DEPLOY_TYPE
|
|
|
|
if [ "$DEPLOY_TYPE" == "PROD" ]; then
|
|
PLIST_PATH=$ROOT/BuildTools/Privado-iOS-ExportOptions.plist
|
|
else
|
|
PLIST_PATH=$ROOT/BuildTools/Privado-Beta-iOS-ExportOptions.plist
|
|
fi
|
|
|
|
|
|
#Remove old results
|
|
rm -rf $DERIVED_PATH
|
|
rm -rf $ARCHIVE_PATH
|
|
|
|
mkdir $DERIVED_PATH
|
|
|
|
#Generate xcodeproj file
|
|
$(dirname "$0")/generate.swift --path=iOS/project.yml --type=$DEPLOY_TYPE
|
|
|
|
if [ "$?" != "0" ]; then
|
|
echo >&2 "Error: xcodeproj generation failed";
|
|
exit 1
|
|
fi
|
|
|
|
cd $IOS_PATH
|
|
|
|
#Sync versions and change build number for upload to TestFlight
|
|
BUNDLE_SHORT_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$IOS_PATH/Privado/Info.plist")
|
|
#Privado
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CI_PIPELINE_IID" $IOS_PATH/Privado/Info.plist
|
|
#OpenVPN
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $BUNDLE_SHORT_VERSION" $IOS_PATH/OpenVPN/Info.plist
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CI_PIPELINE_IID" $IOS_PATH/OpenVPN/Info.plist
|
|
#WireGuard
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $BUNDLE_SHORT_VERSION" $IOS_PATH/WireGuard/Info.plist
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CI_PIPELINE_IID" $IOS_PATH/WireGuard/Info.plist
|
|
|
|
unlock_login_keychain "$K8S_SECRET_JARVIS"
|
|
|
|
#Create Archive
|
|
xcodebuild -project $APPLICATION_NAME.xcodeproj \
|
|
-scheme PrivadoVPN \
|
|
-sdk iphoneos \
|
|
-archivePath $ARCHIVE_PATH \
|
|
-derivedDataPath $DERIVED_PATH \
|
|
-configuration $CONFIG \
|
|
archive \
|
|
ENABLE_SWIFTLINT=NO | xcpretty
|
|
|
|
if [ "${PIPESTATUS[0]}" != "0" ]; then
|
|
echo >&2 "Error: xcodebuild failed";
|
|
exit 1
|
|
fi
|
|
|
|
unlock_login_keychain "$K8S_SECRET_JARVIS"
|
|
|
|
echo $FULL_IPA_PATH
|
|
|
|
mkdir -p $IPA_PATH
|
|
|
|
#Create ipa
|
|
xcodebuild \
|
|
-exportArchive \
|
|
-archivePath $ARCHIVE_PATH \
|
|
-exportPath $FULL_IPA_PATH \
|
|
-exportOptionsPlist $PLIST_PATH | xcpretty
|
|
|
|
if [ "${PIPESTATUS[0]}" != "0" ]; then
|
|
echo >&2 "Error: xcodebuild failed";
|
|
exit 1
|
|
fi
|
|
|
|
# Upload to Sentry
|
|
|
|
DSYMS_PATH=$ARCHIVE_PATH/dSYMs
|
|
TOKEN=ecd2667998c54ea9b8dd1fc640b54549aa09c161b53d4e6f96de4761682f366e
|
|
|
|
sentry-cli \
|
|
--url https://sentry.privado.io/ \
|
|
--auth-token $TOKEN \
|
|
--log-level debug \
|
|
upload-dsym $DSYMS_PATH \
|
|
--org sentry \
|
|
--project ios
|
|
|
|
# Clean after
|
|
|
|
rm -rf $DERIVED_PATH
|
|
rm -rf $ARCHIVE_PATH |