forked from mullvad/mullvadvpn-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·140 lines (105 loc) · 3.96 KB
/
build.sh
File metadata and controls
executable file
·140 lines (105 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
# This script is used to build and ship the iOS app
set -eu
shopt -s nullglob
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
###########################################
# Verify environment configuration
###########################################
if [[ -z ${IOS_APPLE_ID-} ]]; then
echo "The variable IOS_APPLE_ID is not set."
exit
fi
if [[ -z ${IOS_APPLE_ID_PASSWORD-} ]]; then
echo "The variable IOS_APPLE_ID_PASSWORD is not set."
read -sp "IOS_APPLE_ID_PASSWORD = " IOS_APPLE_ID_PASSWORD
echo ""
export IOS_APPLE_ID_PASSWORD
fi
# Provisioning profiles directory
if [[ -z ${IOS_PROVISIONING_PROFILES_DIR-} ]]; then
IOS_PROVISIONING_PROFILES_DIR="$SCRIPT_DIR/iOS Provisioning Profiles"
echo "The variable IOS_PROVISIONING_PROFILES_DIR is not set."
echo "Default: $IOS_PROVISIONING_PROFILES_DIR"
export IOS_PROVISIONING_PROFILES_DIR
fi
###########################################
# Build configuration
###########################################
# The Xcode project name without file extension
# The folder with all sources is expected to hold the same name
PROJECT_NAME="MullvadVPN"
# Xcode project directory
XCODE_PROJECT_DIR="$SCRIPT_DIR/$PROJECT_NAME.xcodeproj"
# Build output directory without trailing slash
BUILD_OUTPUT_DIR="$SCRIPT_DIR/Build"
# Xcode archive output
XCODE_ARCHIVE_DIR="$BUILD_OUTPUT_DIR/$PROJECT_NAME.xcarchive"
# Export options file used for producing .xcarchive
EXPORT_OPTIONS_PATH="$SCRIPT_DIR/ExportOptions.plist"
# Path to generated IPA file produced after .xcarchive export
IPA_PATH="$BUILD_OUTPUT_DIR/$PROJECT_NAME.ipa"
# Xcodebuild intermediate files directory
DERIVED_DATA_DIR="$BUILD_OUTPUT_DIR/DerivedData"
# System provisioning profiles directory
SYSTEM_PROVISIONING_PROFILES_DIR="$HOME/Library/MobileDevice/Provisioning Profiles"
###########################################
# Install provisioning profiles
###########################################
get_mobile_provisioning_uuid() {
security cms -D -i "$1" | grep -aA1 UUID | grep -o "[-a-zA-Z0-9]\{36\}"
}
install_mobile_provisioning() {
echo "Install system provisioning profiles into $SYSTEM_PROVISIONING_PROFILES_DIR"
if [[ ! -d "$SYSTEM_PROVISIONING_PROFILES_DIR" ]]; then
echo "Missing system provisioning profiles directory. Creating one."
mkdir -p "$SYSTEM_PROVISIONING_PROFILES_DIR"
fi
for mobile_provisioning_path in "$IOS_PROVISIONING_PROFILES_DIR"/*.mobileprovision; do
local profile_uuid=$(get_mobile_provisioning_uuid "$mobile_provisioning_path")
local target_path="$SYSTEM_PROVISIONING_PROFILES_DIR/$profile_uuid.mobileprovision"
if [[ -f "$target_path" ]]; then
echo "Skip installing $mobile_provisioning_path"
else
echo "Install $mobile_provisioning_path -> $target_path"
cp "$mobile_provisioning_path" "$target_path"
fi
done
}
install_mobile_provisioning
###########################################
# Build Xcode project
###########################################
release_build() {
xcodebuild \
-project "$XCODE_PROJECT_DIR" \
-scheme "$PROJECT_NAME" \
-sdk iphoneos \
-configuration Release \
-derivedDataPath "$DERIVED_DATA_DIR" \
$@
}
# Clean build directory
release_build clean
# Archive project
release_build archive -archivePath "$XCODE_ARCHIVE_DIR"
# Export IPA for distribution
xcodebuild \
-exportArchive \
-archivePath "$XCODE_ARCHIVE_DIR" \
-exportOptionsPlist "$EXPORT_OPTIONS_PATH" \
-exportPath "$BUILD_OUTPUT_DIR"
###########################################
# Deploy to AppStore
###########################################
if [[ "${1:-""}" == "--deploy" ]]; then
xcrun altool \
--upload-app --verbose \
--type ios \
--file "$IPA_PATH" \
--username "$IOS_APPLE_ID" \
--password "$IOS_APPLE_ID_PASSWORD"
else
echo "Deployment to AppStore will not be performed."
echo "Run with --deploy to upload the binary."
fi