Created
February 5, 2016 15:57
-
-
Save thevirtualforge/0102c73ff22f21cd26e7 to your computer and use it in GitHub Desktop.
Appcelerator Titanium build script. Uses Jason Kneen's tich (https://github.com/jasonkneen/TiCh) to switch tiapp.xml "profiles" on the fly (requires profiles named "ios" & "android").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
command -v tich >/dev/null 2>&1 || { echo >&2 "I require tich but it's not installed. Please run '[sudo] npm install -g tich'. Aborting."; exit 1; } | |
command -v appc >/dev/null 2>&1 || { echo >&2 "I require appc but it's not installed. Please run '[sudo] npm install -g appcelerator'. Aborting."; exit 1; } | |
HELP="Usage: ./build.sh ios|android prod|test|device|emu|help [device-id]" | |
# Exit if no args passed and display help message | |
if [ $# -eq 0 ]; then | |
echo >&2 $HELP | |
exit 2 | |
fi | |
# The location of your Android keystore file | |
ANDROID_KEYSTORE="xxxxxxxx.keystore" | |
# The password for your Android keystore file | |
ANDROID_KEYSTORE_PW="xxxxxxxx" | |
# The name of your iOS distribution certificate. ie. Joe Bloggs (1233455667) | |
IOS_DIST_CERT="xxxxxxxx" | |
# The ID of your iOS appstore distribution provisioning profile. ie. 1a3d5d78c0-1bc4-b2a4-f2e4-1e24c6a89009 | |
IOS_DIST_PP="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" | |
# The ID of your iOS adhoc distribution provisioning profile. ie. 1a3d5d78c0-1bc4-b2a4-f2e4-1e24c6a89009 | |
IOS_ADHOC_PP="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" | |
# Install tich with '[sudo] npm install -g tich' | |
SWITCH="tich select $1" | |
# Install appc with '[sudo] npm install -g appcelerator'. Change 'appc ti clean' to 'ti clean' for open source Titanium CLI | |
CLEAN="appc ti clean" | |
# Change 'appc run' to 'ti build' for open source Titanium CLI | |
BUILD="appc run -p $1" | |
# Build for playstore / appstore | |
if [ "$2" = "prod" ]; then | |
if [ "$1" = "android" ]; then | |
echo >&2 "Building for Android Playstore..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T dist-playstore -K $ANDROID_KEYSTORE -P $ANDROID_KEYSTORE_PW -O dist | |
else | |
echo >&2 "Building for iOS AppStore..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T dist-appstore -R "$IOS_DIST_CERT" -P "$IOS_DIST_PP" -O dist | |
fi | |
# Build to device | |
elif [ "$2" = "device" ]; then | |
# Check for 3rd arg which should be device id. Bail out, if missing. | |
if [ $# -lt 3 ]; then | |
echo 1>&2 "$0: required device id missing." | |
echo >&2 $HELP | |
exit 2 | |
fi | |
# Bail out if dev cert environment variable is not set | |
if [ "$IOS_DEV_CERT" = "" ]; then | |
echo >&2 "IOS_DEV_CERT environment variable missing. Please set IOS_DEV_CERT to you developer certificate name. ie. Joe Bloggs (1233455667)" | |
exit | |
fi | |
# Bail out if dev provisioning profile environment variable is not set | |
if [ "$IOS_DEV_PP" = "" ]; then | |
echo >&2 "IOS_DEV_PP environment variable missing. Please set IOS_DEV_PP to you developer provisiong profile ID. ie. 1a3d5d78c0-1bc4-b2a4-f2e4-1e24c6a89009" | |
exit | |
fi | |
if [ "$1" = "android" ]; then | |
echo >&2 "Building for Android device $3..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T device --device-id "$3" | |
else | |
echo >&2 "Building for iOS device $3..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T device --device-id "$3" -V "$IOS_DEV_CERT" -P "$IOS_DEV_PP" | |
fi | |
# Build for adhoc testing / Installr distribution | |
elif [ "$2" = "test" ]; then | |
if [ "$1" = "android" ]; then | |
echo >&2 "Building for Android test (APK will be output to /build/android/bin )..." | |
$SWITCH | |
$CLEAN | |
$BUILD --build-only -O dist | |
else | |
echo >&2 "Building for iOS adhoc..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T dist-adhoc -R "$IOS_DIST_CERT" -P "$IOS_ADHOC_PP" -O dist | |
fi | |
# Build for simulator / emulator | |
elif [ "$2" = "emu" ]; then | |
if [ $# -eq 3 ]; then | |
if [ "$1" = "android" ]; then | |
echo >&2 "Building for Android emulator $3..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T emulator --device-id "$3" | |
else | |
echo >&2 "Building for iOS simulator $3..." | |
$SWITCH | |
$CLEAN | |
$BUILD -T simulator --device-id "$3" | |
fi | |
else | |
echo >&2 "Building for default emulator / simulator..." | |
$SWITCH | |
$CLEAN | |
$BUILD | |
fi | |
# Show help message | |
elif [ "$1" = "help" ] || [ "$2" = "help" ]; then | |
echo >&2 $HELP | |
# Default to standard build options (default simulator etc.) | |
else | |
echo >&2 "Performing default build for $1..." | |
$SWITCH | |
$CLEAN | |
$BUILD | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment