Sourcehut Android Gradle Continuous Integration
Published 2019-11-14 on Anjan's Homepage
Introduction to Sourcehut
Sourcehut is my git hosting platform of choice. Sourcehut offers a continious integration platform called builds.sr.ht. Here is how to setup build.sr.ht to compile android projects with gradle.
Secrets
Before we begin, we need to create the android-sdk-license
build secret.
This file will tell the android build service (gradle in this guide) that you have
agreed to all the required licenses for the dependancies upon which your project
depends.
If you have built your android apps on your pc, you already have this file and
are ready to go. Open up sr.ht build secrets. Select Secret Type: File
and
enter the following details for your new secret:
Name: androidLicense Path: ~/android/licenses/android-sdk-license Mode: 644
Click browse and navigate to where you have installed the android
sdk on your local machine. Upload the file called android-sdk-license
in the folder licenses
.
Finally, in sr.ht build secrets, click Add Secret
.
On the right pane, a new secret should appear. There should be a UUID that
represents the license file you just uploaded. When you include this UUID in
your build manifest, android-sdk-license
will be copied to the correct folder
in your build environment.
If you would like to send your built apks to a vps, make sure you add your ssh config (nonstandard ports) and a new ssh private key to your secrets.
.build.yml
Finally, we have to make the .build.yml
file on the root of your git
repository on your local machine. You can use
sr.ht to lint and check whether your app will build on a clean machine with the
latest version of gradle (build). I take it one step further and upload my unsigned
build to my vps (deploy). This creates fresh unsigned builds for the latest commit of my
app.
Here is my .build.yml from my own project lift: a free software workout app.
# I use archlinux for my image because I want to test whether my app # builds with the latest release of gradle. Features are often deprecated on # android and I did not know that my app was using alot of deprecated features # until I tried to build with the latest version of gradle. image: archlinux packages: - gradle - rsync # The sr.ht git repo that contains my application. Enter your own app's git repo here sources: - https://git.sr.ht/~anjan/lift environment: deploy: deploy@momi.ca secrets: # UUIDs for ssh and android license secrets - 88e37d5a-6a50-4a14-b9d5-a944dc17bf50 - b0ee6bc9-84d5-4962-a8cb-fc0a9e002bfa - 336f1246-50a2-464a-b3fe-1b54cba37a45 # Tell builds to send me an email if the build fails triggers: - action: email condition: failure to: Anjandev Momi <anjan -at- momi.ca> tasks: - build: | export ANDROID_SDK_ROOT=~/android cd lift gradle assemble - deploy: | cd lift/app/build/outputs/apk/debug sshopts="-o StrictHostKeyChecking=no" rsync --rsh="ssh $sshopts" -rP . ${deploy}:/srv/http/android/android
Finally, add this file in git, commit, and push to sr.ht. Your build should begin!
Installing the rsynced app
Be advised, you will not be able to install the apk that is rsynced by your
.build.yml until you sign it using something like jarsigner
. I do not sign my
latest commit builds because they are strictly for myself.
You could generate a keystore using jarsigner
, upload it as a secret to
sr.ht build secrets, and then add a couple extra lines before rsyncing to sign
the app using jarsigner. However, I would prefer to use fdroid’s build tools at
that point. Please do not store large files on sr.ht - use a different git
host. The documentation for fdroid’s build tools are here: f-droid: publishing nightly builds
When sr.ht supports large files, I will write a blog post about using f-droid build tools on sr.ht.
Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~anjan/public-inbox@lists.sr.ht [mailing list etiquette]
Articles from blogs I follow around the net
These articles/blogs do not represent my own opinions or views.Text processing on the Command Line - sharing my tools
Text processing on the command line - sharing my tools Introduction I'm quite fond of the command-line and spend a larger chunk of my life in a terminal emulator than I dare admit. I try to embrace the unix philosophy of using tools that "do one thing…
via Proycon's website July 7, 2024Linux phones are not automatically secure
A common point in the Linux community is that escaping the walled garden of ecosystems like Android or iOS is already a means to higher security. Having no contact with Google or Apple servers ever again, nor cloud providers ever snooping on your private …
via TuxPhones - Linux phones, tablets and portable devices January 25, 2023Generated by openring