Skip to content

Instantly share code, notes, and snippets.

@sbellver
Created October 2, 2018 08:07
Show Gist options
  • Save sbellver/688172e0b0542865e3e2fdf45372e4bf to your computer and use it in GitHub Desktop.
Save sbellver/688172e0b0542865e3e2fdf45372e4bf to your computer and use it in GitHub Desktop.
#!/bin/bash
clear
echo
echo " .d8888b. .d88888b. 888b d8888888888b.8888888888 d8888 "
echo " d88P Y88bd88P. .Y88b8888b d8888888 Y88b 888 888 d88888 "
echo " 888 888888 88888888b.d88888888 888 888 888 d88P888 "
echo " 888 888 888888Y88888P888888 d88P 888 888 d88P 888 "
echo " 888 888 888888 Y888P 8888888888P. 888 888 d88P 888 "
echo " 888 888888 888888 Y8P 888888 888 888 d88P 888 "
echo " Y88b d88PY88b. .d88P888 . 888888 888 888 d8888888888 "
echo " .Y8888P. .Y88888P. 888 888888 888888888888888d88P 888 "
echo
echo
echo
echo " 8888888 .d88888b. 888b 8888888888 .d8888b. "
echo " 888 d88P. .Y88b8888b 888 888 d88P Y88b "
echo " 888 888 88888888b 888 888 888 888 "
echo " 888 888 888888Y88b 888 888 888 "
echo " 888 888 888888 Y88b888 888 888 "
echo " 888 888 888888 Y88888 888 888 888 "
echo " 888 Y88b. .d88P888 Y8888 888 Y88b d88P "
echo " 8888888 .Y88888P. 888 Y8888888888 .Y8888P. "
echo
if [ $# -lt 2 ]
then
echo "Atención : Necesitamos el nombre del proyecto y plataforma"
echo
echo "Ejemplo: $0 gmaotecnicos ios"
echo "Ejemplo: $0 gmaotecnicos android prod"
echo
exit
fi
cd ~/git/$1/
rm -rf *.apk
git pull
echo '¿Has cambiado la versión? s/n'
echo
echo 'Si no lo has cambido pulsa N y ejecuta el script de nuevo al acabar'
echo
read temp
if [[ $temp == "N" || $temp == "n" ]];
then
vim config.xml
fi
if [[ $3 == "--force" || $4 == "--force" ]];
then
rm -rf node_modules platforms plugins
fi
npm i
case "$2" in
android)
if [[ $3 == prod ]];
then
echo
echo '-> Recuerda que necesitamos un fichero password con la contraseña para el jarsigned <-'
echo
if [ ! -d "platforms/android" ]; then
ionic cordova platform add [email protected]
ionic cordova resources
fi
ionic cordova build --release $2
mv ~/git/$1/platforms/android/build/outputs/apk/release/android-release-unsigned.apk ~/git/$1/$1.apk
#Generar clave
#keytool -genkey -v -keystore FILE.keystore -alias ALIAS -keyalg RSA -keysize 2048 -validity 10000
#Cambiar alias a key
#keytool -changealias -keystore FILE.keystore -alias OLDALIAS -destalias NEWALIAS
PASSWORD=$( cat password )
expect -c "spawn jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $1.keystore $1.apk $1 ; expect \"Enter Passphrase for keystore:\" ; send $PASSWORD\n ; interact"
../zipalign -v 4 $1.apk $1-produccion.apk
else
# Si hay errores de compilado por versiones de plugins
if [ ! -d "platforms/android" ]; then
ionic cordova platform add [email protected]
ionic cordova resources
fi
ionic cordova build android
fi;;
ios)
if [ ! -d "platforms/ios" ]; then
ionic cordova platform add $2
ionic cordova resources
fi
find resources/ios -name "*.png" -exec convert "{}" -alpha off "{}" \;
ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0";;
esac;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment