+ android:
+ runs-on: ubuntu-latest
+ # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
+ container: debian:bullseye
+ env:
+ TOOLCHAIN: stable
+ strategy:
+ fail-fast: false
+ steps:
+ - name: Install rust targets
+ run: |
+ apt-get update
+ apt-get -y dist-upgrade
+ apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
+ chmod +x ./rustup.sh
+ ./rustup.sh -y
+ . $HOME/.cargo/env
+ rustup target add armv7-linux-androideabi
+ rustup target add aarch64-linux-android
+ rustup target add i686-linux-android
+ rustup target add x86_64-linux-android
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - name: Install android NDK compilers
+ run: |
+ curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
+ if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
+ echo "Bad hash"
+ exit 1
+ fi
+ unzip android-ndk-r22b-linux-x86_64.zip
+ - name: Install cbindgen
+ run: |
+ . $HOME/.cargo/env
+ cargo install --force cbindgen
+ - name: Checkout Rust-Lightning and LDK-C-Bindings git
+ run: |
+ git config --global user.email "ldk-ci@example.com"
+ git config --global user.name "LDK CI"
+ # Note this is a different endpoint, as we need one non-upstream commit!
+ git clone https://git.bitcoin.ninja/rust-lightning
+ cd rust-lightning
+ git checkout origin/2021-03-java-bindings-base
+ cd ..
+ git clone https://github.com/lightningdevkit/ldk-c-bindings
+ cd ldk-c-bindings
+ git checkout 0.0.103
+ - name: Checkout Android AAR binaries and artifacts
+ run: |
+ # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+ RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
+ SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+ curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+
+ ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
+ SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+ curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+
+ mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+ cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+ tar xvvf ../../bins-snapshot.tgz
+ mv ldk-java-bins-*/* ./
+ rm -r ldk-java-bins-*
+
+ mkdir -p ../android-artifacts
+ cd ../android-artifacts
+ tar xvvf ../../android-snapshot.tgz
+ mv ldk-java-bins-*/* ./
+ rm -r ldk-java-bins-*
+ - name: Build Android aar
+ run: |
+ . $HOME/.cargo/env
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
+ export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
+ export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
+ ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
+ - name: Check latest library and jars are in bins repo
+ run: |
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
+ apt-get -y install diffoscope
+ diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
+ exit 1
+ fi
+