ooni-probe-cli/build-android.bash
Simone Basso 04ea3fca43
chore: adapt android scripts to use maven central (#307)
The main changes here are two. First, tweak some bits of the POM template
to make sure it's current, including referencing the correct repo. (We were
still referencing probe-engine in there, weirdly enough).

Second, change the android build script to create the same bundle that
mavan would build. What remains to do is uploading manually.

(Because it seems my PGP key is required, I guess this development rules
out automatically generating releases at GitHub. We will see about it
later on and possibly zap the publish-android.sh script.)

Reference issue: https://github.com/ooni/probe/issues/1437.

The release 2021.04.07-180801 has been created by me using this
diff from the v3.9.0 tag. I will update the release notes as soon
as this new release becomes available from Maven Central.
2021-04-07 20:46:11 +02:00

43 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
if [ -z "$ANDROID_HOME" -o "$1" = "--help" ]; then
echo ""
echo "usage: $0 [--sign]"
echo ""
echo "Please set ANDROID_HOME. We assume you have installed"
echo "the Android SDK. You can do that on macOS using:"
echo ""
echo " brew install --cask android-sdk"
echo ""
echo "Then make sure you install the required packages:"
echo ""
echo "sdkmanager --install 'build-tools;29.0.3' 'ndk-bundle'"
echo ""
echo "or, if you already installed, that you're up to date:"
echo ""
echo "sdkmanager --update"
echo ""
echo "Once you have done that, please export ANDROID_HOME to"
echo "point to /usr/local/Caskroom/android-sdk/<version>."
echo ""
exit 1
fi
topdir=$(cd $(dirname $0) && pwd -P)
set -x
export PATH=$(go env GOPATH)/bin:$PATH
go get -u golang.org/x/mobile/cmd/gomobile
gomobile init
version=$(date -u +%Y.%m.%d-%H%M%S)
aarfile=MOBILE/android/oonimkall-$version.aar
gomobile bind -target=android -o $aarfile -ldflags="-s -w" ./pkg/oonimkall
pomfile=./MOBILE/android/oonimkall-$version.pom
pomtemplate=./MOBILE/template.pom
cat $pomtemplate|sed "s/@VERSION@/$version/g" > $pomfile
if [ "$1" == "--sign" ]; then
cd ./MOBILE/android
for file in `ls *`; do
gpg -ab -u simone@openobservatory.org $file
done
jar -cvf bundle.jar oonimkall-$version*
fi