caipivara
12/11/2015 - 8:34 PM

Android / Gradle / Script - Assemble the app and do backup using https://gist.github.com/danielgomezrico/bfb2fb5732d760e766f5 and release to

Android / Gradle / Script - Assemble the app and do backup using https://gist.github.com/danielgomezrico/bfb2fb5732d760e766f5 and release to fabric if the params are passed. (Update the fabric tasks based on your buildTypes and Flavors)

#!/usr/bin/env bash
#
# Assemble the app, backup it and upload the apks to crashlytics
#

if [ $1 = '--help' ] || [ $1 = '--h' ] || [ $1 = '-help' ] || [ $1 = '-h' ] || [ $1 = '-?' ] ; then
    echo "Usage: sh assemble.sh [option]"
    echo ""
    echo "Options:"
    echo "-?, -h, --h, -help, --help            print help."
    echo "-releaseStaging                       release the staging apk to fabric."
    echo "-releaseProduction                    release the production apk to fabric."
    exit 0
fi

echo "Assembling apks..."
sh gradlew assemble

if [ $? -eq 0 ]; then
  echo "Trying to backup apks..."
  sh gradlew backupApks

  if [ $1 = '-releaseStaging' ]; then
    echo "Releasing staging..."
    sh gradlew crashlyticsUploadDistributionDevStaging
  fi

  if [ $1 = '-releaseProduction' ]; then
    echo "Releasing prod..."
    sh gradlew crashlyticsUploadDistributionProdRelease
  fi
else
    echo "Something went wrong, no backup or released can be done."
fi