+
+ java_determinism:
+ runs-on: ubuntu-latest
+ # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
+ # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
+ container: debian:bullseye
+ strategy:
+ fail-fast: false
+ steps:
+ - name: Install native Rust toolchain, Valgrind, and build utilitis
+ run: |
+ apt-get update
+ apt-get -y dist-upgrade
+ apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - name: Install cbindgen
+ run: cargo install --version 0.20.0 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.106
+ - name: Rebuild C bindings, and check the sample app builds + links
+ run: |
+ cd ldk-c-bindings
+ ./genbindings.sh ../rust-lightning true
+ - name: Checkout latest MacOS binaries
+ run: |
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+ # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
+ SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | 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}"
+ 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-*
+ cd ../..
+ mkdir -p src/main/resources/
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/
+ rm src/main/resources/liblightningjni_MacOSX-*-leaktracking.nativelib
+ - name: Build Java Release Bindings
+ run: |
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
+ - name: Build deterministic release jar
+ run: ./build-release-jar.sh
+ - name: Check latest library and jars are in bins repo
+ run: |
+ export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+ mkdir ldk-java-bins/new/
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
+ # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism
+ cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/
+ cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
+ cp ldk-java-sources.jar ldk-java-bins/new/
+ cp ldk-java.jar ldk-java-bins/new/
+ cp ldk-java-classes.jar ldk-java-bins/new/
+ cp ldk-java-javadoc.jar ldk-java-bins/new/
+ cd ldk-java-bins
+ if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
+ apt-get -y install diffoscope
+ diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
+ diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
+ diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
+ diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
+ exit 1
+ fi