Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2013 21:12
Show Gist options
  • Select an option

  • Save anonymous/5595148 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/5595148 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist May 16, 2013.
    30 changes: 30 additions & 0 deletions continuous_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    folder="bin/classes/"
    package="$1"

    inotifywait -m -q -e close_write "$folder" | while read f; do
    # take only the filename
    f=`awk '{print $3}' <<< "$f"`

    # rebuild the full path
    path="$folder$f"

    # if it's not an apk or is the unaligned one, skip it
    if [[ $f =~ ^.*unaligned\.apk$ || ! $f =~ ^.*apk$ ]]; then
    echo "Skipping $f"
    continue;
    fi

    # Get the list of device names. This ignores whether they're online or not.
    devices=`adb devices | sed '1d' | awk '{print $1;}'`
    echo "Sending $f.."
    echo "$devices" | (parallel adb -s {} install -r "$path" | sed 's/^/ /') 2> /dev/null
    echo "done"

    # If we provided an activity name, start it on all devices
    if [ $package ]; then
    echo "Starting activity $package.."
    echo "$devices" | (parallel adb -s {} shell am start "$package" | sed 's/^/ /') 2> /dev/null
    echo "done"
    fi
    done