In my previous post I’ve explained how to integrate your translations into development process using Continuous Integration.

Today we’ll see how to set up a daily channel for your Android App using again Travis with a little help from GH Pages. It may sound difficult, but actually this is something pretty easy to do, specially if you already have Travis testing your builds (read here how to get started).

Write the Script

Copy the apk(s)

Again, we need to write a simple script that takes the apk generated by Travis and uploads it somewhere on GitHub or your server.

In fact, if you use

./gradlew clean build

in your travis.yml, you’ll end up having an unused apk each time a new build is triggered. So, how can we save it?

Let’s start making a new directory that will contain our precious apk.

#!/usr/bin/env bash mkdir $HOME/daily/

Travis puts all compiled files in a new directory <module_name>/build/outputs/apk/app-debug.apk

With this command, we copy the apk from the build directory to our folder.

cp -R app/build/outputs/apk/app-debug.apk $HOME/daily/

If you want, you can also copy other files you want to save in that folder. At Glucosio for example, we have 2 different modules: one for mobile and the other one for Android Wear: each time we save 2 different apks.

Save to GH Pages(or your server)

The most difficult part is done. We now have our apk stored safe and sound in /daily directory. You could just upload it on your server but, what if you don’t have one? Don’t worry, GH Pages are here for you.

Set up a new GH Pages repo, read here how. Add some fancy HTML and CSS stuff to make your daily page look nice or just do the basics.

When your new website and repo is up, upload the saved apk.

# go to home and setup git

cd $HOME

git config --global user.email "my_email@example.com"

git config --global user.name "my_GH_username"

cp -Rf $HOME/daily/* .



# add, commit and push files

git remote add origin https://github.com/Example/example.github.io.git

git add -f .

git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed in daily channel"

git push -fq origin master > /dev/null

Don’t forget to run your script after each Travis build.

# travis.yml after_success:

- chmod +x ./upload-gh-pages.sh

- ./upload-gh-pages.sh

Now check your git repo. You’ll see your first apk uploaded after the build. Copy its link and update your HTML.

(example: http://glucosio.github.io/app-debug.apk)

The final result should be something like this.

Your web page will be automatically uploaded by Travis and will always point to latest apk available.

Next time, I’ll experiment how to push daily builds directly in Google Play’s Alpha channel.