Travis is a useful service for building and testing your code. Once you are familiar with Travis, you will likely start building with Travis because it is very easy to start with. Usually, when building Android Project, you want a resulting APK to ship. As Travis builds your APK, you are able to extract that APK through Gradle script and publish it somewhere (even GitHub). But you can do exactly the same with just a few lines in
3 steps to start publishing APK to GitHub releases through Travis:
Configure your repository on GitHub and make sure that
.travis.yml is present in the root of your repository. Here’s sample
Download the Travis CI command line client and run
travis setup releases in the root directory of your repository.
- Type in your username and password.
- When asked for file to upload insert
- Deploy only from
- Encrypt API key? Yes! This is an important part of keeping access to your repo private.
Now you will be able to see that
travis added several lines of script in your
They are as follows:
Everything is almost OK by now but there are several nuances.
- At this time Travis will treat
yourapp*release*.apkand not like
yourapp...something...release...something.apk. So there is a parameter in Travis called
file_globwhich should be enabled if you want files to be interpreted as globs (* and ** wildcards).
- You should supply
skip_cleanup: "true"because otherwise Travis may clean all APKs.
- (optional) You may want to specify the branch on which Travis is supposed to build APKs. This should be inserted in the
In order to successfully push your APK to GitHub, you need to put a tag on the commit that has just been built. To do that, we will add a new section called
after_success: where we will execute custom script which sets current build tag. The script
set_tags.sh is as follows:
Place this script in the root directory of your project. And then add this 2 lines to
By now you should be able to build and publish your APKs to GitHub releases sections. It will look like this:
Now you can publish your APKs to GitHub releases with no hassle! A sample project can be found here.
Happy publishing!comments powered by Disqus