Skip to content

Instantly share code, notes, and snippets.

@AGulev
Forked from britzl/bundle.sh
Last active December 10, 2020 13:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AGulev/75d8f5c5ef83dfce40611fc7eaaf1bcc to your computer and use it in GitHub Desktop.
Save AGulev/75d8f5c5ef83dfce40611fc7eaaf1bcc to your computer and use it in GitHub Desktop.
Script to build and bundle a Defold project for multiple platforms
#!/bin/bash
readonly java_path='java'
readonly output_path='build'
readonly email='my@email.com'
readonly auth_key='my_key'
readonly texture_compresstion='false'
readonly andr_key_path='key.pk8'
readonly andr_cert_path='certificate.pem'
title=$(less game.project | grep "^title = " | cut -d "=" -f2 | sed -e 's/^[[:space:]]*//')
title_no_space=$(echo "${title}" | tr -d '[[:space:]]')
andr_package=$(less game.project | grep "^package = " | cut -d "=" -f2 | sed -e 's/^[[:space:]]*//')
andr_package_no_space=$(echo "${andr_package}" | tr -d '[[:space:]]')
echo "Project: ${title}"
if [ ! -f bob.jar ]
then
echo "Unable to find bob.jar. Download it from d.defold.com."
exit 1
fi
bob() {
$java_path -jar bob.jar $@
}
build() {
platform=$1
echo "${platform}"
shift 1
bob --platform ${platform} --archive build $@
}
bundle() {
platform=$1
echo "${platform}"
shift 1
bob --platform ${platform} --bundle-output $output_path${platform} $@ bundle
}
archive() {
platform=$1
if [ "${platform}" == "armv7-android" ]
then
echo "${title_no_space}.apk"
mv "$output_path${platform}/${title}/${title}.apk" "${title_no_space}.apk"
elif [ "${platform}" == "armv7-darwin" ]
then
echo "${title_no_space}.ipa"
mv "$output_path${platform}/${title}.ipa" "${title_no_space}.ipa"
else
echo "${title_no_space}_${platform}.zip"
rm -rf "${title_no_space}_${platform}.zip"
cd $output_path${platform}
zip -r -q "../../${title_no_space}_${platform}.zip" *
cd ../..
fi
}
deploy(){
if [ "${platform}" == "armv7-darwin" ]
then
echo "${title_no_space}.ipa"
ipa-deploy "$output_path${platform}/${title}.ipa"
elif [ "${platform}" == "armv7-android" ]
then
echo "${title_no_space}.apk"
adb uninstall "${andr_package}"
adb install -r "$output_path${platform}/${title}/${title}.apk"
fi
}
# update libs
echo "\n[Downloading]"
bob --email $email --auth $auth_key resolve
# clear
echo "\n[Clear]"
bob distclean
# build
echo "\n[Building]"
rm -rf build
build armv7-android -tc $texture_compresstion
# bundle platforms
echo "\n[Bundling]"
bundle armv7-android --private-key $andr_key_path --certificate $andr_cert_path
# bundle armv7-darwin --identity YOUR_IDENTITY --mobileprovisioning comagulevtest.mobileprovision
# bundle x86-win32
# bundle x86-darwin
# bundle x86-linux
# bundle js-web
# archive bundled platforms
echo "\n[Archiving]"
# archive armv7-android
# archive x86-win32
# archive x86-darwin
# archive x86-linux
# archive js-web
# archive armv7-darwin
echo "\n[Installing]"
deploy armv7-android
# archive x86-win32
# archive x86-darwin
# archive x86-linux
# archive js-web
# deploy armv7-darwin #using https://www.npmjs.com/package/ipa-deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment