-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-packages
executable file
·96 lines (76 loc) · 4.25 KB
/
make-packages
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
#!/bin/sh
# Created by Michael Baltaks
# Build release pair script: build a pair of release candidate packages
# - apply build config
# - run tests
# - bump the build number
# - clean and build
# - package and sign for appstore and adhoc
# - keep both packages and debug symbols, just for debugging test crash logs, or for later storing the final build and symbols.
# - commit
# Don't allow using unset vars (-u)
set -o nounset
# Exit on error (-e)
set -o errexit
if [ $# -lt 2 ]; then
script_name=$(basename $0)
echo "usage: ${script_name} workspace_folder packages_folder" >&2
exit 1
fi
# To use an old toolchain, set DEVELOPER_DIR=/Applications/Xcode4.app/Contents/Developer
workspace_folder="$1"
packages_folder="$2"
plistbuddy="/usr/libexec/PlistBuddy"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
script_folder="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
info_plist_full_prefix=""
current_folder="$(pwd)"
cd "${packages_folder}"
packages_folder="$(pwd)"
cd "${current_folder}"
cd "${workspace_folder}"
repo_folder="$(pwd)"
# TODO: this expects the app config files to live in a scripts folder.
app_config="${workspace_folder}/scripts/app.config"
if [ ! -f "${app_config}" ];
then
[ $# -lt 3 ] && echo "You must supply a config name" && exit 1
source "${workspace_folder}/scripts/$3-app.config"
if [ ! -z ${INFO_PLIST_PREFIX} ]; then info_plist_full_prefix="${INFO_PLIST_PREFIX}-"; fi
info_plist="${repo_folder}/${RESOURCES_FOLDER}/${info_plist_full_prefix}Info.plist"
# Now edit the info plist to use customer specific settings.
${plistbuddy} -c "set :CFBundleDisplayName '${CFBundleDisplayName}'" "$info_plist"
${plistbuddy} -c "set :CFBundleIdentifier '${CFBundleIdentifier}'" "$info_plist"
if [ ! -z ${UILaunchImageFile} ]; then ${plistbuddy} -c "set :UILaunchImageFile '${UILaunchImageFile}'" "$info_plist"; fi
else
source "${app_config}"
fi
CONFIGURATION=Release
SDK="${BUILDSDK:=iphoneos}"
RELEASE_BUILD_FOLDER="${repo_folder}/build/${CONFIGURATION}-${SDK}"
if [ ! -z ${INFO_PLIST_PREFIX} ]; then info_plist_full_prefix="${INFO_PLIST_PREFIX}-"; fi
info_plist="${repo_folder}/${RESOURCES_FOLDER}/${info_plist_full_prefix}Info.plist"
if [ -z ${TEST_SDK+x} ];
then
echo "No test config found, skipping tests"
else
xcodebuild -workspace "${WORKSPACE}.xcworkspace" -scheme "${SCHEME}" -configuration "${TEST_CONFIGURATION}" -sdk "${TEST_SDK}" clean test -destination "${TEST_DESTINATION}"
fi
agvtool bump -all
#version=`agvtool mvers -terse1`
version=`${plistbuddy} -c "print :CFBundleShortVersionString" "$info_plist"`
buildnumber=`agvtool vers -terse`
xcodebuild -workspace "${WORKSPACE}.xcworkspace" -scheme "${SCHEME}" -configuration "${CONFIGURATION}" -sdk "${SDK}" clean CONFIGURATION_BUILD_DIR="${RELEASE_BUILD_FOLDER}"
xcodebuild -workspace "${WORKSPACE}.xcworkspace" -scheme "${SCHEME}" -configuration "${CONFIGURATION}" -sdk "${SDK}" CODE_SIGN_IDENTITY="${APPSTORE_CERTIFICATE_NAME}" build CONFIGURATION_BUILD_DIR="${RELEASE_BUILD_FOLDER}"
BUNDLE_ID=`codesign -d --verbose "${RELEASE_BUILD_FOLDER}/${APPLICATION_BUNDLE_NAME}.app" 2>&1 >/dev/null | grep ^Identifier | sed "s/^Identifier=//"`
ADHOC_PACKAGE_FOLDER="${packages_folder}/${APPLICATION_PACKAGE_NAME}-${BUNDLE_ID}/${version}-${buildnumber}/adhoc"
APPSTORE_PACKAGE_FOLDER="${packages_folder}/${APPLICATION_PACKAGE_NAME}-${BUNDLE_ID}/${version}-${buildnumber}/appstore"
# AdHoc build
mkdir -p "${ADHOC_PACKAGE_FOLDER}"
xcrun -log -verbose -sdk "${SDK}" PackageApplication -v "${RELEASE_BUILD_FOLDER}/${APPLICATION_BUNDLE_NAME}.app" -o "${ADHOC_PACKAGE_FOLDER}/${APPLICATION_PACKAGE_NAME}.ipa" --sign "${ADHOC_CERTIFICATE_NAME}" --embed "${HOME}/Library/MobileDevice/Provisioning Profiles/${ADHOC_PROVISONING_PROFILE}.mobileprovision"
# App Store build
mkdir -p "${APPSTORE_PACKAGE_FOLDER}"
xcrun -log -verbose -sdk "${SDK}" PackageApplication -v "${RELEASE_BUILD_FOLDER}/${APPLICATION_BUNDLE_NAME}.app" -o "${APPSTORE_PACKAGE_FOLDER}/${APPLICATION_PACKAGE_NAME}.ipa" --sign "${APPSTORE_CERTIFICATE_NAME}" --embed "${HOME}/Library/MobileDevice/Provisioning Profiles/${APPSTORE_PROVISONING_PROFILE}.mobileprovision"
cp -rp "${RELEASE_BUILD_FOLDER}/${APPLICATION_BUNDLE_NAME}.app.dSYM" "${APPSTORE_PACKAGE_FOLDER}"
git commit -a -m "Release $version build $buildnumber"